From a7a80becb2d8fcd3cd1cf1c0f7911557d1a02dd3 Mon Sep 17 00:00:00 2001
From: Nicole White
Date: Thu, 19 Oct 2023 22:55:24 -0400
Subject: [PATCH] Add ToC & CI
---
.env.example | 2 +
.github/workflows/ci.yml | 134 ++++++++++++++++++
JavaScript/chatbot-nextjs/README.md | 35 +----
JavaScript/chatbot-nextjs/package.json | 5 +-
JavaScript/langchain/README.md | 29 +---
JavaScript/langchain/package.json | 5 +-
JavaScript/novel-ai-text-editor/README.md | 23 +--
JavaScript/novel-ai-text-editor/package.json | 5 +-
JavaScript/openai-automated/package.json | 7 +-
JavaScript/openai-automated/readme.md | 29 +---
.../package-lock.json | 0
.../{openai => openai-manual}/package.json | 9 +-
JavaScript/openai-manual/readme.md | 19 +++
.../{openai => openai-manual}/src/index.js | 0
JavaScript/openai/readme.md | 42 ------
Python/langchain/README.md | 29 +---
Python/langchain/main.py | 2 +-
Python/langchain/pyproject.toml | 2 +-
Python/openai-manual/README.md | 19 +++
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 | 44 ++++++
tools/make-toc.js | 54 +++++++
25 files changed, 309 insertions(+), 237 deletions(-)
create mode 100644 .env.example
create mode 100644 .github/workflows/ci.yml
rename JavaScript/{openai => openai-manual}/package-lock.json (100%)
rename JavaScript/{openai => openai-manual}/package.json (55%)
create mode 100644 JavaScript/openai-manual/readme.md
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..7c358207
--- /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."
+ 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')
+ # 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..8bdd6afb 100644
--- a/JavaScript/chatbot-nextjs/README.md
+++ b/JavaScript/chatbot-nextjs/README.md
@@ -2,34 +2,13 @@
-# Chatbot Autoblocks Example
-
-## Quick Start
-
-Example chatbot using [Autoblocks](https://www.autoblocks.ai).
-
-View deployed app at https://chatbot-example.autoblocks.ai
-
-### 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 the `chatbot-nextjs` directory with the following environment variables:
-
-```
-OPENAI_API_KEY=
-AUTOBLOCKS_INGESTION_KEY=
-```
-
-### Run the app
+## Run the app
```
npm run dev
@@ -37,14 +16,8 @@ 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..19580e76 100644
--- a/JavaScript/langchain/README.md
+++ b/JavaScript/langchain/README.md
@@ -2,41 +2,18 @@
-# Langchain Autoblocks Example
-
-Example using [Autoblocks](https://www.autoblocks.ai) and [Langchain JS](https://js.langchain.com/docs/get_started/introduction).
-
-## Quick Start
-
-### 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..f7a96e20 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 LangChain",
"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..d6ef9fd4 100644
--- a/JavaScript/novel-ai-text-editor/README.md
+++ b/JavaScript/novel-ai-text-editor/README.md
@@ -10,26 +10,13 @@ Based on [novella](https://github.com/steven-tey/novella).
## Quick Start
-### 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.local` file in the root directory of the project with the following environment variables:
-
-```
-OPENAI_API_KEY=
-AUTOBLOCKS_INGESTION_KEY=
-```
-
-### Run the app
+## Run the app
```
npm run dev
@@ -37,14 +24,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/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
index 05a87acb..2d343120 100644
--- a/JavaScript/openai-automated/readme.md
+++ b/JavaScript/openai-automated/readme.md
@@ -2,41 +2,18 @@
-# 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
+## 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
+## Run the script
```
npm run start
```
-### View trace in Autoblocks
+## 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/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-manual/readme.md b/JavaScript/openai-manual/readme.md
new file mode 100644
index 00000000..5884277f
--- /dev/null
+++ b/JavaScript/openai-manual/readme.md
@@ -0,0 +1,19 @@
+
+
+
+
+## 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/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..332c9bf3 100644
--- a/Python/langchain/README.md
+++ b/Python/langchain/README.md
@@ -2,35 +2,12 @@
-# Python Langchain Autoblocks Example
-
-Example script using [Autoblocks](https://www.autoblocks.ai) to trace Langchain pipelines.
-
-## Setup
-
-### Install `poetry`
-
-https://python-poetry.org/docs/#installation
-
-### 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 +17,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..9cc131ec 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 LangChain"
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..21c384de
--- /dev/null
+++ b/Python/openai-manual/README.md
@@ -0,0 +1,19 @@
+
+
+
+
+## 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..f53b611a 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,50 @@
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 your `.env` file
+
+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 LangChain |
+| [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 |
+
+
+## Python
+
+> **_NOTE:_** All Python examples require [`poetry`](https://python-poetry.org/docs/#installation) to be installed.
+
+
+| Name | Description |
+| -------------------------------------- | ------------------------------ |
+| [langchain](/Python/langchain) | Automatic tracing of LangChain |
+| [openai-manual](/Python/openai-manual) | Manual tracing of openai calls |
+
+
## More Information
For more information on how to use Autoblocks, visit the [Autoblocks documentation](https://docs.autoblocks.ai/).
diff --git a/tools/make-toc.js b/tools/make-toc.js
new file mode 100644
index 00000000..3e3bea4e
--- /dev/null
+++ b/tools/make-toc.js
@@ -0,0 +1,54 @@
+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');
+};
+
+(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]);
+ }
+
+ 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);
+})();