From 701df74f8ad2ed70ef5a9dba85091afe64729dc7 Mon Sep 17 00:00:00 2001
From: Nicole White
Date: Sat, 28 Oct 2023 10:12:36 -0400
Subject: [PATCH] Make openai getting started optional
---
JavaScript/langchain/package-lock.json | 71 ++++++++++++++++++++++----
JavaScript/langchain/package.json | 3 +-
JavaScript/spans/README.md | 4 ++
Python/langchain/pyproject.toml | 2 +-
tools/make-readmes.js | 33 +++++++++++-
5 files changed, 100 insertions(+), 13 deletions(-)
diff --git a/JavaScript/langchain/package-lock.json b/JavaScript/langchain/package-lock.json
index c95d539b..e56ddd84 100644
--- a/JavaScript/langchain/package-lock.json
+++ b/JavaScript/langchain/package-lock.json
@@ -11,7 +11,8 @@
"dependencies": {
"@autoblocks/client": "^0.0.15",
"dotenv-cli": "^7.3.0",
- "langchain": "^0.0.173"
+ "langchain": "^0.0.173",
+ "openai": "^4.14.1"
},
"engines": {
"node": ">=18"
@@ -813,6 +814,24 @@
}
}
},
+ "node_modules/langchain/node_modules/openai": {
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/openai/-/openai-4.4.0.tgz",
+ "integrity": "sha512-JN0t628Kh95T0IrXl0HdBqnlJg+4Vq0Bnh55tio+dfCnyzHvMLiWyCM9m726MAJD2YkDU4/8RQB6rNbEq9ct2w==",
+ "dependencies": {
+ "@types/node": "^18.11.18",
+ "@types/node-fetch": "^2.6.4",
+ "abort-controller": "^3.0.0",
+ "agentkeepalive": "^4.2.1",
+ "digest-fetch": "^1.3.0",
+ "form-data-encoder": "1.7.2",
+ "formdata-node": "^4.3.2",
+ "node-fetch": "^2.6.7"
+ },
+ "bin": {
+ "openai": "bin/cli"
+ }
+ },
"node_modules/langchainhub": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/langchainhub/-/langchainhub-0.0.6.tgz",
@@ -972,9 +991,9 @@
}
},
"node_modules/openai": {
- "version": "4.4.0",
- "resolved": "https://registry.npmjs.org/openai/-/openai-4.4.0.tgz",
- "integrity": "sha512-JN0t628Kh95T0IrXl0HdBqnlJg+4Vq0Bnh55tio+dfCnyzHvMLiWyCM9m726MAJD2YkDU4/8RQB6rNbEq9ct2w==",
+ "version": "4.14.1",
+ "resolved": "https://registry.npmjs.org/openai/-/openai-4.14.1.tgz",
+ "integrity": "sha512-aBb7DVdzSnEUBFHTbnVoitauefvjRuUHS5pa7lm1m5JmHifD+1Hff1RzxYC12ogugVcCmWT99NZNfzyD6n/0IQ==",
"dependencies": {
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.4",
@@ -983,12 +1002,21 @@
"digest-fetch": "^1.3.0",
"form-data-encoder": "1.7.2",
"formdata-node": "^4.3.2",
- "node-fetch": "^2.6.7"
+ "node-fetch": "^2.6.7",
+ "web-streams-polyfill": "^3.2.1"
},
"bin": {
"openai": "bin/cli"
}
},
+ "node_modules/openai/node_modules/web-streams-polyfill": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
+ "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
+ "engines": {
+ "node": ">= 8"
+ }
+ },
"node_modules/openapi-types": {
"version": "12.1.3",
"resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.3.tgz",
@@ -1466,6 +1494,23 @@
"yaml": "^2.2.1",
"zod": "^3.22.3",
"zod-to-json-schema": "^3.20.4"
+ },
+ "dependencies": {
+ "openai": {
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/openai/-/openai-4.4.0.tgz",
+ "integrity": "sha512-JN0t628Kh95T0IrXl0HdBqnlJg+4Vq0Bnh55tio+dfCnyzHvMLiWyCM9m726MAJD2YkDU4/8RQB6rNbEq9ct2w==",
+ "requires": {
+ "@types/node": "^18.11.18",
+ "@types/node-fetch": "^2.6.4",
+ "abort-controller": "^3.0.0",
+ "agentkeepalive": "^4.2.1",
+ "digest-fetch": "^1.3.0",
+ "form-data-encoder": "1.7.2",
+ "formdata-node": "^4.3.2",
+ "node-fetch": "^2.6.7"
+ }
+ }
}
},
"langchainhub": {
@@ -1582,9 +1627,9 @@
"integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw=="
},
"openai": {
- "version": "4.4.0",
- "resolved": "https://registry.npmjs.org/openai/-/openai-4.4.0.tgz",
- "integrity": "sha512-JN0t628Kh95T0IrXl0HdBqnlJg+4Vq0Bnh55tio+dfCnyzHvMLiWyCM9m726MAJD2YkDU4/8RQB6rNbEq9ct2w==",
+ "version": "4.14.1",
+ "resolved": "https://registry.npmjs.org/openai/-/openai-4.14.1.tgz",
+ "integrity": "sha512-aBb7DVdzSnEUBFHTbnVoitauefvjRuUHS5pa7lm1m5JmHifD+1Hff1RzxYC12ogugVcCmWT99NZNfzyD6n/0IQ==",
"requires": {
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.4",
@@ -1593,7 +1638,15 @@
"digest-fetch": "^1.3.0",
"form-data-encoder": "1.7.2",
"formdata-node": "^4.3.2",
- "node-fetch": "^2.6.7"
+ "node-fetch": "^2.6.7",
+ "web-streams-polyfill": "^3.2.1"
+ },
+ "dependencies": {
+ "web-streams-polyfill": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
+ "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q=="
+ }
}
},
"openapi-types": {
diff --git a/JavaScript/langchain/package.json b/JavaScript/langchain/package.json
index b95efa00..5260678f 100644
--- a/JavaScript/langchain/package.json
+++ b/JavaScript/langchain/package.json
@@ -15,6 +15,7 @@
"dependencies": {
"@autoblocks/client": "^0.0.15",
"dotenv-cli": "^7.3.0",
- "langchain": "^0.0.173"
+ "langchain": "^0.0.173",
+ "openai": "^4.14.1"
}
}
diff --git a/JavaScript/spans/README.md b/JavaScript/spans/README.md
index 5063713d..851939d0 100644
--- a/JavaScript/spans/README.md
+++ b/JavaScript/spans/README.md
@@ -19,6 +19,8 @@
+
+
## Getting started
- Sign up for an Autoblocks account at https://app.autoblocks.ai
@@ -29,6 +31,8 @@
AUTOBLOCKS_INGESTION_KEY=
```
+
+
## Creating spans
This example shows how you can establish parent / child relationships between your events by sending the `spanId` and `parentSpanId` properties.
diff --git a/Python/langchain/pyproject.toml b/Python/langchain/pyproject.toml
index 35797ed0..b37faa91 100644
--- a/Python/langchain/pyproject.toml
+++ b/Python/langchain/pyproject.toml
@@ -1,5 +1,5 @@
[tool.poetry]
-name = "python-openai-autoblocks-example"
+name = "langchain"
version = "0.0.0"
description = "Automatic tracing of a LangChain pipeline"
authors = ["Autoblocks Engineering "]
diff --git a/tools/make-readmes.js b/tools/make-readmes.js
index 3586d07a..dbac44ee 100644
--- a/tools/make-readmes.js
+++ b/tools/make-readmes.js
@@ -55,7 +55,9 @@ const BANNER_START_COMMENT = '';
const BANNER_END_COMMENT = '';
// Getting started checklist we add to each individual project README
-const GETTING_STARTED = `
+const makeGettingStartedChecklist = (includeOpenAI) => {
+ if (includeOpenAI) {
+ return `
## Getting started
- Sign up for an Autoblocks account at https://app.autoblocks.ai
@@ -68,6 +70,20 @@ OPENAI_API_KEY=
AUTOBLOCKS_INGESTION_KEY=
\`\`\`
`;
+ } else {
+ return `
+## Getting started
+
+- Sign up for an Autoblocks account at https://app.autoblocks.ai
+- Grab your Autoblocks ingestion key from https://app.autoblocks.ai/settings/api-keys
+- Create a file named \`.env\` in this folder and include the following environment variables:
+
+\`\`\`
+AUTOBLOCKS_INGESTION_KEY=
+\`\`\`
+`;
+ }
+};
const GETTING_STARTED_START_COMMENT = '';
const GETTING_STARTED_END_COMMENT = '';
@@ -83,6 +99,7 @@ const GETTING_STARTED_END_COMMENT = '';
for (const project of projects) {
let description;
+ let includeOpenAIInGettingStartedChecklist = false;
if (section === 'JavaScript') {
// Get description from package.json
@@ -91,6 +108,11 @@ const GETTING_STARTED_END_COMMENT = '';
'utf-8',
);
description = JSON.parse(packageJson).description;
+
+ // Check if openai is a dependency
+ if (packageJson.includes('openai')) {
+ includeOpenAIInGettingStartedChecklist = true;
+ }
} else if (section === 'Python') {
// Get description from pyproject.toml
const pyprojectToml = await fs.readFile(
@@ -98,6 +120,11 @@ const GETTING_STARTED_END_COMMENT = '';
'utf-8',
);
description = pyprojectToml.match(/description = "(.*)"/)[1];
+
+ // Check if openai is a dependency
+ if (pyprojectToml.includes('openai')) {
+ includeOpenAIInGettingStartedChecklist = true;
+ }
}
// Add name and description to table
@@ -120,7 +147,9 @@ const GETTING_STARTED_END_COMMENT = '';
content: projectReadme,
startComment: GETTING_STARTED_START_COMMENT,
endComment: GETTING_STARTED_END_COMMENT,
- replacement: GETTING_STARTED,
+ replacement: makeGettingStartedChecklist(
+ includeOpenAIInGettingStartedChecklist,
+ ),
});
// Write the new project README