Skip to content

Commit

Permalink
Make openai getting started optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole White committed Oct 28, 2023
1 parent 2e57aa7 commit 701df74
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 13 deletions.
71 changes: 62 additions & 9 deletions JavaScript/langchain/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion JavaScript/langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 4 additions & 0 deletions JavaScript/spans/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</p>
<!-- banner end -->

<!-- getting started start -->

## Getting started

- Sign up for an Autoblocks account at https://app.autoblocks.ai
Expand All @@ -29,6 +31,8 @@
AUTOBLOCKS_INGESTION_KEY=<your-ingestion-key>
```

<!-- getting started end -->

## Creating spans

This example shows how you can establish parent / child relationships between your events by sending the `spanId` and `parentSpanId` properties.
Expand Down
2 changes: 1 addition & 1 deletion Python/langchain/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
Expand Down
33 changes: 31 additions & 2 deletions tools/make-readmes.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ const BANNER_START_COMMENT = '<!-- banner start -->';
const BANNER_END_COMMENT = '<!-- banner end -->';

// 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
Expand All @@ -68,6 +70,20 @@ OPENAI_API_KEY=<your-api-key>
AUTOBLOCKS_INGESTION_KEY=<your-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=<your-ingestion-key>
\`\`\`
`;
}
};

const GETTING_STARTED_START_COMMENT = '<!-- getting started start -->';
const GETTING_STARTED_END_COMMENT = '<!-- getting started end -->';
Expand All @@ -83,6 +99,7 @@ const GETTING_STARTED_END_COMMENT = '<!-- getting started end -->';

for (const project of projects) {
let description;
let includeOpenAIInGettingStartedChecklist = false;

if (section === 'JavaScript') {
// Get description from package.json
Expand All @@ -91,13 +108,23 @@ const GETTING_STARTED_END_COMMENT = '<!-- getting started end -->';
'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(
`${section}/${project}/pyproject.toml`,
'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
Expand All @@ -120,7 +147,9 @@ const GETTING_STARTED_END_COMMENT = '<!-- getting started end -->';
content: projectReadme,
startComment: GETTING_STARTED_START_COMMENT,
endComment: GETTING_STARTED_END_COMMENT,
replacement: GETTING_STARTED,
replacement: makeGettingStartedChecklist(
includeOpenAIInGettingStartedChecklist,
),
});

// Write the new project README
Expand Down

0 comments on commit 701df74

Please sign in to comment.