From 15d31e12a3c4ef67cf7218e1765303fbd21d4d8e Mon Sep 17 00:00:00 2001
From: Nicole White
Date: Mon, 23 Oct 2023 08:52:21 -0400
Subject: [PATCH] Cleanup examples (#14)
* automated table of contents
* automated banner in each project README
* CI to catch broken examples
---
.env.example | 2 +
.github/workflows/ci.yml | 134 ++++++++++++++++++
JavaScript/chatbot-nextjs/README.md | 53 ++++---
JavaScript/chatbot-nextjs/package.json | 5 +-
JavaScript/langchain/README.md | 40 +++---
JavaScript/langchain/package.json | 5 +-
JavaScript/novel-ai-text-editor/README.md | 44 +++---
JavaScript/novel-ai-text-editor/package.json | 5 +-
JavaScript/openai-automated/README.md | 34 +++++
JavaScript/openai-automated/package.json | 7 +-
JavaScript/openai-automated/readme.md | 42 ------
JavaScript/openai-manual/README.md | 34 +++++
.../package-lock.json | 0
.../{openai => openai-manual}/package.json | 9 +-
.../{openai => openai-manual}/src/index.js | 0
JavaScript/openai/readme.md | 42 ------
Python/langchain/README.md | 40 ++----
Python/langchain/main.py | 2 +-
Python/langchain/pyproject.toml | 2 +-
Python/openai-manual/README.md | 34 +++++
Python/{openai => openai-manual}/main.py | 2 +-
Python/{openai => openai-manual}/poetry.lock | 0
.../{openai => openai-manual}/pyproject.toml | 4 +-
Python/openai/README.md | 46 ------
README.md | 51 ++++++-
tools/make-toc.js | 87 ++++++++++++
26 files changed, 473 insertions(+), 251 deletions(-)
create mode 100644 .env.example
create mode 100644 .github/workflows/ci.yml
create mode 100644 JavaScript/openai-automated/README.md
delete mode 100644 JavaScript/openai-automated/readme.md
create mode 100644 JavaScript/openai-manual/README.md
rename JavaScript/{openai => openai-manual}/package-lock.json (100%)
rename JavaScript/{openai => openai-manual}/package.json (55%)
rename JavaScript/{openai => openai-manual}/src/index.js (100%)
delete mode 100644 JavaScript/openai/readme.md
create mode 100644 Python/openai-manual/README.md
rename Python/{openai => openai-manual}/main.py (97%)
rename Python/{openai => openai-manual}/poetry.lock (100%)
rename Python/{openai => openai-manual}/pyproject.toml (77%)
delete mode 100644 Python/openai/README.md
create mode 100644 tools/make-toc.js
diff --git a/.env.example b/.env.example
new file mode 100644
index 00000000..3d3a0a48
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,2 @@
+OPENAI_API_KEY=
+AUTOBLOCKS_INGESTION_KEY=
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 00000000..e302d06f
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,134 @@
+name: CI
+
+on:
+ push:
+ schedule:
+ # Every day at ~7:17am Chicago time.
+ #
+ # Using a non-zero minute offset since GitHub Actions suggests
+ # running jobs at a random minute to avoid overloading their
+ # servers.
+ #
+ # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
+ - cron: "17 12 * * *"
+
+jobs:
+ test-table-of-contents-up-to-date:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Setup Node
+ uses: actions/setup-node@v3
+ with:
+ node-version: 20
+
+ - name: Make table of contents
+ run: node tools/make-toc.js
+
+ - name: Ensure table of contents is up to date
+ run: |
+ if [[ -n $(git status --porcelain) ]]; then
+ echo "::error::The table of contents is out of date. Please run 'node tools/make-toc.js' and commit the changes."
+ exit 1
+ else
+ echo "Table of contents is up to date!"
+ fi
+
+ test-python:
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ project:
+ - Python/langchain
+ - Python/openai-manual
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Create .env file
+ run: |
+ touch .env
+ echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
+ echo "AUTOBLOCKS_INGESTION_KEY=${{ secrets.AUTOBLOCKS_INGESTION_KEY }}" >> .env
+
+ - name: Setup Python
+ uses: actions/setup-python@v3
+ with:
+ python-version: 3.11
+
+ - name: Install poetry
+ run: curl -sSL https://install.python-poetry.org | python3 -
+
+ - name: Check pyproject.toml & poetry.lock are in sync
+ run: poetry lock --check
+ working-directory: ${{ matrix.project }}
+
+ - name: Install dependencies
+ run: poetry install
+ working-directory: ${{ matrix.project }}
+
+ - name: Run script
+ run: poetry run python main.py
+ working-directory: ${{ matrix.project }}
+
+ test-javascript:
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ project:
+ # - JavaScript/chatbot-nextjs
+ - JavaScript/langchain
+ # - JavaScript/novel-ai-text-editor
+ - JavaScript/openai-automated
+ - JavaScript/openai-manual
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Create .env file
+ run: |
+ touch .env
+ echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
+ echo "AUTOBLOCKS_INGESTION_KEY=${{ secrets.AUTOBLOCKS_INGESTION_KEY }}" >> .env
+
+ - name: Setup Node
+ uses: actions/setup-node@v3
+ with:
+ node-version: 20
+
+ - name: Install dependencies
+ run: npm ci
+ working-directory: ${{ matrix.project }}
+
+ - name: Run script
+ run: npm run start
+ working-directory: ${{ matrix.project }}
+
+ notify:
+ needs:
+ - test-python
+ - test-javascript
+
+ if: always() && contains(needs.*.result, 'failure') && github.event_name == 'schedule'
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: slackapi/slack-github-action@v1.24.0
+ with:
+ payload: |
+ {
+ "text": ":warning: Workflow `${{ github.workflow }}` in repository `${{ github.repository }}` failed. <${{ env.run-url }}|Logs>"
+ }
+ env:
+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
+ SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
+
+ run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
diff --git a/JavaScript/chatbot-nextjs/README.md b/JavaScript/chatbot-nextjs/README.md
index beddb644..46a2fcb1 100644
--- a/JavaScript/chatbot-nextjs/README.md
+++ b/JavaScript/chatbot-nextjs/README.md
@@ -1,50 +1,49 @@
+
-# Chatbot Autoblocks Example
+
+ Documentation
+ |
+ Application
+ |
+ Home
+
-## Quick Start
+
+ :bangbang:
+ Make sure you've read the getting started section in the main README.
+
+
-Example chatbot using [Autoblocks](https://www.autoblocks.ai).
+# Chatbot Example
+This is a Next.js app that uses openai and Autoblocks to power and monitor a chatbot.
-View deployed app at https://chatbot-example.autoblocks.ai
+View the deployed application at https://chatbot-example.autoblocks.ai
-### Install Dependencies
+## Copy the root `.env` file to this directory
+```bash
+cp ../../.env .
```
-npm install
-```
-
-### Sign up for Autoblocks
-
-Sign up for an Autoblocks account at https://app.autoblocks.ai and grab your ingestion key from [settings](https://app.autoblocks.ai/settings/api-keys).
-### Set environment variables
+## Install dependencies
-Create a `.env` file in the `chatbot-nextjs` directory with the following environment variables:
-
-```
-OPENAI_API_KEY=
-AUTOBLOCKS_INGESTION_KEY=
+```bash
+npm install
```
-### Run the app
+## Run the app
-```
+```bash
npm run dev
```
Visit http://localhost:3000 to see the app.
-### View logs in Autoblocks
+## View logs in Autoblocks
-As you interact with the app, you will see traces appear in the Autoblocks explore page.
+As you interact with the app, you will see traces appear in the Autoblocks [explore page](https://app.autoblocks.ai/explore).
![Autoblocks Explore](https://github.com/autoblocksai/novel-autoblocks-example/blob/main/novel-autoblocks-example.png?raw=true)
-
-## More Information
-
-For more information on how to use Autoblocks, visit the [Autoblocks documentation](https://docs.autoblocks.ai/).
-
-For more information on how to use Novel, visit the [Novel repository](https://github.com/steven-tey/novel).
diff --git a/JavaScript/chatbot-nextjs/package.json b/JavaScript/chatbot-nextjs/package.json
index 5c99fa78..d3e53bc5 100644
--- a/JavaScript/chatbot-nextjs/package.json
+++ b/JavaScript/chatbot-nextjs/package.json
@@ -1,6 +1,7 @@
{
- "name": "autoblocks-examples",
- "version": "0.1.0",
+ "name": "chatbot-nextjs",
+ "description": "A Next.js app that uses openai and Autoblocks to power and monitor a chatbot",
+ "version": "0.0.0",
"private": true,
"scripts": {
"dev": "next dev",
diff --git a/JavaScript/langchain/README.md b/JavaScript/langchain/README.md
index b1c14b04..a73b1c25 100644
--- a/JavaScript/langchain/README.md
+++ b/JavaScript/langchain/README.md
@@ -1,42 +1,34 @@
+
-# Langchain Autoblocks Example
-
-Example using [Autoblocks](https://www.autoblocks.ai) and [Langchain JS](https://js.langchain.com/docs/get_started/introduction).
+
+ Documentation
+ |
+ Application
+ |
+ Home
+
-## Quick Start
+
+ :bangbang:
+ Make sure you've read the getting started section in the main README.
+
+
-### Install Dependencies
+## Install dependencies
```
npm install
```
-### Sign up for Autoblocks
-
-Sign up for an Autoblocks account at https://app.autoblocks.ai and grab your ingestion key from [settings](https://app.autoblocks.ai/settings/api-keys).
-
-### Set environment variables
-
-Create a `.env` file in this directory with the following environment variables:
-
-```
-OPENAI_API_KEY=
-AUTOBLOCKS_INGESTION_KEY=
-```
-
-### Run the script
+## Run the script
```
npm run start
```
-### View logs in Autoblocks
+## View logs in Autoblocks
After you run the script, you can find the trace on the [explore page](https://app.autoblocks.ai/explore).
-
-## More Information
-
-For more information on how to use Autoblocks, visit the [Autoblocks documentation](https://docs.autoblocks.ai/).
diff --git a/JavaScript/langchain/package.json b/JavaScript/langchain/package.json
index e180e1d4..0ce28827 100644
--- a/JavaScript/langchain/package.json
+++ b/JavaScript/langchain/package.json
@@ -1,5 +1,6 @@
{
- "name": "langchain-autoblocks-example",
+ "name": "langchain",
+ "description": "Automatic tracing of a LangChain pipeline",
"version": "0.0.0",
"private": true,
"engines": {
@@ -7,7 +8,7 @@
},
"type": "module",
"scripts": {
- "start": "dotenv -e .env -- node ./src/index.js"
+ "start": "dotenv -e ../../.env -- node ./src/index.js"
},
"author": "",
"license": "MIT",
diff --git a/JavaScript/novel-ai-text-editor/README.md b/JavaScript/novel-ai-text-editor/README.md
index b35f9d4f..1db023e1 100644
--- a/JavaScript/novel-ai-text-editor/README.md
+++ b/JavaScript/novel-ai-text-editor/README.md
@@ -1,35 +1,39 @@
+
-# Novel Autoblocks Example
+
+ Documentation
+ |
+ Application
+ |
+ Home
+
-Example Next.js application using [Novel](https://github.com/steven-tey/novel) and [Autoblocks](https://www.autoblocks.ai).
+
+ :bangbang:
+ Make sure you've read the getting started section in the main README.
+
+
-Based on [novella](https://github.com/steven-tey/novella).
+# Novel Example
-## Quick Start
+Example Next.js application using [Novel](https://github.com/steven-tey/novel). Based on [novella](https://github.com/steven-tey/novella).
-### Install Dependencies
+## Copy the root `.env` file to this directory
-```
-npm install
+```bash
+cp ../../.env .
```
-### Sign up for Autoblocks
-
-Sign up for an Autoblocks account at https://app.autoblocks.ai and grab your ingestion key from [settings](https://app.autoblocks.ai/settings/api-keys).
-
-### Set environment variables
-
-Create a `.env.local` file in the root directory of the project with the following environment variables:
+## Install Dependencies
```
-OPENAI_API_KEY=
-AUTOBLOCKS_INGESTION_KEY=
+npm install
```
-### Run the app
+## Run the app
```
npm run dev
@@ -37,14 +41,12 @@ npm run dev
Visit http://localhost:3000 to see the app.
-### View logs in Autoblocks
+## View logs in Autoblocks
-As you interact with the app, you will see traces appear in the Autoblocks explore page.
+As you interact with the app, you will see traces appear in the Autoblocks [explore page](https://app.autoblocks.ai/explore).
![Autoblocks Explore](https://github.com/autoblocksai/novel-autoblocks-example/blob/main/novel-autoblocks-example.png?raw=true)
## More Information
-For more information on how to use Autoblocks, visit the [Autoblocks documentation](https://docs.autoblocks.ai/).
-
For more information on how to use Novel, visit the [Novel repository](https://github.com/steven-tey/novel).
diff --git a/JavaScript/novel-ai-text-editor/package.json b/JavaScript/novel-ai-text-editor/package.json
index 988b4c32..f6f6ee2a 100644
--- a/JavaScript/novel-ai-text-editor/package.json
+++ b/JavaScript/novel-ai-text-editor/package.json
@@ -1,6 +1,7 @@
{
- "name": "novel-autoblocks-example",
- "version": "0.1.0",
+ "name": "novel-ai-text-editor",
+ "description": "A Next.js app that uses [Novel](https://github.com/steven-tey/novel) and Autoblocks to power an AI-enabled text editor",
+ "version": "0.0.0",
"private": true,
"scripts": {
"dev": "next dev",
diff --git a/JavaScript/openai-automated/README.md b/JavaScript/openai-automated/README.md
new file mode 100644
index 00000000..62e846f4
--- /dev/null
+++ b/JavaScript/openai-automated/README.md
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ Documentation
+ |
+ Application
+ |
+ Home
+
+
+
+ :bangbang:
+ Make sure you've read the getting started section in the main README.
+
+
+
+## Install Dependencies
+
+```
+npm install
+```
+
+## Run the script
+
+```
+npm run start
+```
+
+## View trace in Autoblocks
+
+Go to the [explore page](https://app.autoblocks.ai/explore) to see the trace.
diff --git a/JavaScript/openai-automated/package.json b/JavaScript/openai-automated/package.json
index ce82d507..bcc4ac5c 100644
--- a/JavaScript/openai-automated/package.json
+++ b/JavaScript/openai-automated/package.json
@@ -1,11 +1,12 @@
{
- "name": "openai-automated-autoblocks-example",
- "version": "1.0.0",
+ "name": "openai-automated",
+ "description": "Automatic tracing of openai calls",
+ "version": "0.0.0",
"private": true,
"type": "module",
"main": "src/index.js",
"scripts": {
- "start": "dotenv -e .env -- node ./src/index.js"
+ "start": "dotenv -e ../../.env -- node ./src/index.js"
},
"license": "MIT",
"dependencies": {
diff --git a/JavaScript/openai-automated/readme.md b/JavaScript/openai-automated/readme.md
deleted file mode 100644
index 05a87acb..00000000
--- a/JavaScript/openai-automated/readme.md
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-# Automated OpenAI Tracing
-
-Automated OpenAI tracing using [Autoblocks](https://www.autoblocks.ai).
-
-## Quick Start
-
-### Sign up for Autoblocks
-
-Sign up for an Autoblocks account at https://app.autoblocks.ai and grab your ingestion key from [settings](https://app.autoblocks.ai/settings/api-keys).
-
-### Install Dependencies
-
-```
-npm install
-```
-
-### Set environment variables
-
-Create a `.env` file in this directory with the following environment variables:
-
-```
-OPENAI_API_KEY=
-AUTOBLOCKS_INGESTION_KEY=
-```
-
-### Run the script
-
-```
-npm run start
-```
-
-### View trace in Autoblocks
-
-Go to the [explore page](https://app.autoblocks.ai/explore) to see the trace.
-
-## More Information
-
-For more information on how to use Autoblocks, visit the [Autoblocks documentation](https://docs.autoblocks.ai/).
diff --git a/JavaScript/openai-manual/README.md b/JavaScript/openai-manual/README.md
new file mode 100644
index 00000000..43d33a27
--- /dev/null
+++ b/JavaScript/openai-manual/README.md
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ Documentation
+ |
+ Application
+ |
+ Home
+
+
+
+ :bangbang:
+ Make sure you've read the getting started section in the main README.
+
+
+
+## Install Dependencies
+
+```
+npm install
+```
+
+## Run the script
+
+```
+npm run start
+```
+
+## View logs in Autoblocks
+
+After you run the script, you will see a link to view the trace in your console. You can also navigate directly to the [explore page](https://app.autoblocks.ai/explore) to see the trace.
diff --git a/JavaScript/openai/package-lock.json b/JavaScript/openai-manual/package-lock.json
similarity index 100%
rename from JavaScript/openai/package-lock.json
rename to JavaScript/openai-manual/package-lock.json
diff --git a/JavaScript/openai/package.json b/JavaScript/openai-manual/package.json
similarity index 55%
rename from JavaScript/openai/package.json
rename to JavaScript/openai-manual/package.json
index 869122ef..d717a54f 100644
--- a/JavaScript/openai/package.json
+++ b/JavaScript/openai-manual/package.json
@@ -1,13 +1,12 @@
{
- "name": "openai-autoblocks-example",
- "version": "1.0.0",
- "description": "",
+ "name": "openai-manual",
+ "version": "0.0.0",
+ "description": "Manual tracing of openai calls",
"type": "module",
"main": "src/index.js",
"scripts": {
- "start": "dotenv -e .env -- node ./src/index.js"
+ "start": "dotenv -e ../../.env -- node ./src/index.js"
},
- "author": "Adam Nolte",
"license": "MIT",
"dependencies": {
"@autoblocks/client": "^0.0.14",
diff --git a/JavaScript/openai/src/index.js b/JavaScript/openai-manual/src/index.js
similarity index 100%
rename from JavaScript/openai/src/index.js
rename to JavaScript/openai-manual/src/index.js
diff --git a/JavaScript/openai/readme.md b/JavaScript/openai/readme.md
deleted file mode 100644
index 18e16e60..00000000
--- a/JavaScript/openai/readme.md
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-# Node Autoblocks Example
-
-Example Node application using [Autoblocks](https://www.autoblocks.ai).
-
-## Quick Start
-
-### Install Dependencies
-
-```
-npm install
-```
-
-### Sign up for Autoblocks
-
-Sign up for an Autoblocks account at https://app.autoblocks.ai and grab your ingestion key from [settings](https://app.autoblocks.ai/settings/api-keys).
-
-### Set environment variables
-
-Create a `.env` file in this directory with the following environment variables:
-
-```
-OPENAI_API_KEY=
-AUTOBLOCKS_INGESTION_KEY=
-```
-
-### Run the app
-
-```
-npm run start
-```
-
-### View logs in Autoblocks
-
-After you run the app, you will see a link to view the trace in your console. You can also navigate directly to the [explore page](https://app.autoblocks.ai/explore) to see the trace.
-
-## More Information
-
-For more information on how to use Autoblocks, visit the [Autoblocks documentation](https://docs.autoblocks.ai/).
diff --git a/Python/langchain/README.md b/Python/langchain/README.md
index dcb29eb2..8f5f1816 100644
--- a/Python/langchain/README.md
+++ b/Python/langchain/README.md
@@ -1,36 +1,28 @@
+
-# Python Langchain Autoblocks Example
-
-Example script using [Autoblocks](https://www.autoblocks.ai) to trace Langchain pipelines.
-
-## Setup
-
-### Install `poetry`
+
+ Documentation
+ |
+ Application
+ |
+ Home
+
-https://python-poetry.org/docs/#installation
+
+ :bangbang:
+ Make sure you've read the getting started section in the main README.
+
+
-### Install dependencies:
+## Install dependencies
```bash
poetry install
```
-## Sign up for Autoblocks
-
-Sign up for an Autoblocks account at https://app.autoblocks.ai and grab your ingestion key from [settings](https://app.autoblocks.ai/settings/api-keys).
-
-## Set environment variables
-
-Create a `.env` file in this directory with the following environment variables:
-
-```
-OPENAI_API_KEY=
-AUTOBLOCKS_INGESTION_KEY=
-```
-
## Run the script
```bash
@@ -40,7 +32,3 @@ poetry run python main.py
## View logs in Autoblocks
Go to the [explore page](https://app.autoblocks.ai/explore) to see the trace.
-
-## More Information
-
-For more information on how to use Autoblocks, visit the [Autoblocks documentation](https://docs.autoblocks.ai/).
diff --git a/Python/langchain/main.py b/Python/langchain/main.py
index 81955cbc..bc130d9b 100644
--- a/Python/langchain/main.py
+++ b/Python/langchain/main.py
@@ -2,7 +2,7 @@
from autoblocks.vendor.langchain import AutoblocksCallbackHandler
from langchain.llms import OpenAI
-dotenv.load_dotenv()
+dotenv.load_dotenv("../../.env")
if __name__ == "__main__":
diff --git a/Python/langchain/pyproject.toml b/Python/langchain/pyproject.toml
index ef48cc87..c8550fdb 100644
--- a/Python/langchain/pyproject.toml
+++ b/Python/langchain/pyproject.toml
@@ -1,7 +1,7 @@
[tool.poetry]
name = "python-openai-autoblocks-example"
version = "0.0.0"
-description = ""
+description = "Automatic tracing of a LangChain pipeline"
authors = ["Autoblocks Engineering "]
license = "MIT"
readme = "README.md"
diff --git a/Python/openai-manual/README.md b/Python/openai-manual/README.md
new file mode 100644
index 00000000..d08f79cd
--- /dev/null
+++ b/Python/openai-manual/README.md
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ Documentation
+ |
+ Application
+ |
+ Home
+
+
+
+ :bangbang:
+ Make sure you've read the getting started section in the main README.
+
+
+
+## Install dependencies:
+
+```bash
+poetry install
+```
+
+## Run the script
+
+```bash
+poetry run python main.py
+```
+
+## View logs in Autoblocks
+
+After you run the script, you will see a link to view the trace in your console. You can also navigate directly to the [explore page](https://app.autoblocks.ai/explore) to see the trace.
diff --git a/Python/openai/main.py b/Python/openai-manual/main.py
similarity index 97%
rename from Python/openai/main.py
rename to Python/openai-manual/main.py
index 32abbb8c..712684aa 100644
--- a/Python/openai/main.py
+++ b/Python/openai-manual/main.py
@@ -7,7 +7,7 @@
import openai
from autoblocks.tracer import AutoblocksTracer
-dotenv.load_dotenv()
+dotenv.load_dotenv("../../.env")
openai.api_key = os.environ["OPENAI_API_KEY"]
diff --git a/Python/openai/poetry.lock b/Python/openai-manual/poetry.lock
similarity index 100%
rename from Python/openai/poetry.lock
rename to Python/openai-manual/poetry.lock
diff --git a/Python/openai/pyproject.toml b/Python/openai-manual/pyproject.toml
similarity index 77%
rename from Python/openai/pyproject.toml
rename to Python/openai-manual/pyproject.toml
index 81322bd7..a62edfe5 100644
--- a/Python/openai/pyproject.toml
+++ b/Python/openai-manual/pyproject.toml
@@ -1,7 +1,7 @@
[tool.poetry]
-name = "python-openai-autoblocks-example"
+name = "openai-manual"
+description = "Manual tracing of openai calls"
version = "0.0.0"
-description = ""
authors = ["Autoblocks Engineering "]
license = "MIT"
readme = "README.md"
diff --git a/Python/openai/README.md b/Python/openai/README.md
deleted file mode 100644
index 10154edf..00000000
--- a/Python/openai/README.md
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-# Python OpenAI Autoblocks Example
-
-Example Python and OpenAI application using [Autoblocks](https://www.autoblocks.ai).
-
-## Setup
-
-### Install `poetry`
-
-https://python-poetry.org/docs/#installation
-
-### Install dependencies:
-
-```bash
-poetry install
-```
-
-## Sign up for Autoblocks
-
-Sign up for an Autoblocks account at https://app.autoblocks.ai and grab your ingestion key from [settings](https://app.autoblocks.ai/settings/api-keys).
-
-## Set environment variables
-
-Create a `.env` file in this directory with the following environment variables:
-
-```
-OPENAI_API_KEY=
-AUTOBLOCKS_INGESTION_KEY=
-```
-
-## Run the app
-
-```bash
-poetry run python main.py
-```
-
-## View logs in Autoblocks
-
-After you run the app, you will see a link to view the trace in your console. You can also navigate directly to the [explore page](https://app.autoblocks.ai/explore) to see the trace.
-
-## More Information
-
-For more information on how to use Autoblocks, visit the [Autoblocks documentation](https://docs.autoblocks.ai/).
diff --git a/README.md b/README.md
index 0a540427..987a64cd 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,53 @@
-# Autoblocks Examples
+
+ Documentation
+ |
+ Application
+ |
+ Home
+
+
+
+ This repository contains examples of how to use Autoblocks with various frameworks, libraries, and languages.
+
+
+## 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
+- Grab your OpenAI API key from https://platform.openai.com/account/api-keys
+- Create a `.env` file at the root of this repository with the following environment variables (**Tip**: Run `cp .env.example .env` for extra quick setup)
+
+```
+OPENAI_API_KEY=
+AUTOBLOCKS_INGESTION_KEY=
+```
+
+All examples will pull environment variables from this file!
+
+## JavaScript
+
+> **_NOTE:_** All JavaScript examples require `npm` and `node` >= 16 to be installed.
+
+
+| Name | Description |
+| -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
+| [chatbot-nextjs](/JavaScript/chatbot-nextjs) | A Next.js app that uses openai and Autoblocks to power and monitor a chatbot |
+| [langchain](/JavaScript/langchain) | Automatic tracing of a LangChain pipeline |
+| [novel-ai-text-editor](/JavaScript/novel-ai-text-editor) | A Next.js app that uses [Novel](https://github.com/steven-tey/novel) and Autoblocks to power an AI-enabled text editor |
+| [openai-automated](/JavaScript/openai-automated) | Automatic tracing of openai calls |
+| [openai-manual](/JavaScript/openai-manual) | Manual tracing of openai calls |
+
-This repository contains examples of how to use Autoblocks with various frameworks, libraries, and languages.
+## Python
-## More Information
+> **_NOTE:_** All Python examples require [`poetry`](https://python-poetry.org/docs/#installation) to be installed.
-For more information on how to use Autoblocks, visit the [Autoblocks documentation](https://docs.autoblocks.ai/).
+
+| Name | Description |
+| -------------------------------------- | ----------------------------------------- |
+| [langchain](/Python/langchain) | Automatic tracing of a LangChain pipeline |
+| [openai-manual](/Python/openai-manual) | Manual tracing of openai calls |
+
diff --git a/tools/make-toc.js b/tools/make-toc.js
new file mode 100644
index 00000000..b22e7cd0
--- /dev/null
+++ b/tools/make-toc.js
@@ -0,0 +1,87 @@
+const fs = require('fs/promises');
+
+const makeMarkdownTable = (headers, rows) => {
+ const columnWidths = [headers, ...rows].reduce((acc, row) => {
+ return row.map((cell, i) => Math.max(acc[i] || 0, cell.length));
+ }, []);
+ const headerSeparator = columnWidths.map((width) => '-'.repeat(width));
+ const table = [headers, headerSeparator, ...rows];
+ return table.map((row) => {
+ return `| ${row.map((cell, i) => cell.padEnd(columnWidths[i])).join(' | ')} |`;
+ }).join('\n');
+};
+
+// Text we add to the top of each individual README
+const BANNER = `
+
+
+
+
+ Documentation
+ |
+ Application
+ |
+ Home
+
+
+
+ :bangbang:
+ Make sure you've read the getting started section in the main README.
+
`;
+
+(async function () {
+ let readme = await fs.readFile('README.md', 'utf-8');
+
+ const headers = ['Name', 'Description'];
+
+ for (const section of ['JavaScript', 'Python']) {
+ const rows = [];
+ const projects = await fs.readdir(section);
+
+ for (const project of projects) {
+ let description;
+
+ if (section === 'JavaScript') {
+ // Get description from package.json
+ const packageJson = await fs.readFile(`${section}/${project}/package.json`, 'utf-8');
+ description = JSON.parse(packageJson).description;
+ } 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];
+ }
+
+ // Add name and description to table
+ rows.push([`[${project}](/${section}/${project})`, description]);
+
+ // Add banner to top of README
+ let projectReadme = await fs.readFile(`${section}/${project}/README.md`, 'utf-8');
+
+ // Find start and end of banner in project README
+ const startComment = '';
+ const endComment = '';
+ const startIdx = projectReadme.indexOf(startComment) + startComment.length;
+ const endIdx = projectReadme.indexOf(endComment);
+
+ // Replace the content between the comments with the banner
+ projectReadme = `${projectReadme.slice(0, startIdx)}\n${BANNER}\n${projectReadme.slice(endIdx)}`;
+
+ // Write the new project README
+ await fs.writeFile(`${section}/${project}/README.md`, projectReadme);
+ }
+
+ const table = makeMarkdownTable(headers, rows);
+
+ // Look for comments that looks like "" and ""
+ const startComment = ``;
+ const endComment = ``;
+ const startIdx = readme.indexOf(startComment) + startComment.length;
+ const endIdx = readme.indexOf(endComment);
+
+ // Replace the content between the comments with the table in the README
+ readme = `${readme.slice(0, startIdx)}\n${table}\n${readme.slice(endIdx)}`;
+ }
+
+ // Write the new README
+ await fs.writeFile('README.md', readme);
+})();