Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit e086ecf

Browse files
authored
Merge pull request #150 from davidatbraintrust/patch-1
Add braintrust integration tutorial
2 parents 09b3a34 + 2874cad commit e086ecf

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

docs/integrations/braintrust.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
slug: /integrations/braintrust
3+
title: Braintrust
4+
---
5+
6+
[Braintrust](braintrustdata.com) is an enterprise-grade stack for building AI products including: evaluations, prompt playground, dataset management, tracing, etc.
7+
8+
Braintrust provides a Typescript and Python library to run and log evaluations and integrates well with Chroma.
9+
10+
- [Tutorial: Evaluate Chroma Retrieval app w/ Braintrust](https://www.braintrustdata.com/docs/examples/rag)
11+
12+
Example evaluation script in Python:
13+
(refer to the tutorial above to get the full implementation)
14+
```python
15+
from autoevals.llm import *
16+
from braintrust import Eval
17+
18+
PROJECT_NAME="Chroma_Eval"
19+
20+
from openai import OpenAI
21+
22+
client = OpenAI()
23+
leven_evaluator = LevenshteinScorer()
24+
25+
async def pipeline_a(input, hooks=None):
26+
# Get a relevant fact from Chroma
27+
relevant = collection.query(
28+
query_texts=[input],
29+
n_results=1,
30+
)
31+
relevant_text = ','.join(relevant["documents"][0])
32+
prompt = """
33+
You are an assistant called BT. Help the user.
34+
Relevant information: {relevant}
35+
Question: {question}
36+
Answer:
37+
""".format(question=input, relevant=relevant_text)
38+
messages = [{"role": "system", "content": prompt}]
39+
response = client.chat.completions.create(
40+
model="gpt-3.5-turbo",
41+
messages=messages,
42+
temperature=0,
43+
max_tokens=100,
44+
)
45+
46+
result = response.choices[0].message.content
47+
return result
48+
49+
# Run an evaluation and log to Braintrust
50+
await Eval(
51+
PROJECT_NAME,
52+
# define your test cases
53+
data = lambda:[{"input": "What is my eye color?", "expected": "Brown"}],
54+
# define your retrieval pipeline w/ Chroma above
55+
task = pipeline_a,
56+
# use a prebuilt scoring function or define your own :)
57+
scores=[leven_evaluator],
58+
)
59+
```
60+
61+
Learn more: [docs](https://www.braintrustdata.com/docs).

docs/integrations/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ We welcome pull requests to add new Integrations to the community.
1616
|--------------|-----------|---------------|
1717
| [🦜️🔗 Langchain](/integrations/langchain) |||
1818
| [🦙 LlamaIndex](/integrations/llama-index) || :soon: |
19+
| [Braintrust](/integrations/braintrust) |||
1920
| [🔭 OpenLLMetry](/integrations/openllmetry) || :soon: |
2021

21-
*Coming soon* - integrations with LangSmith, JinaAI, Braintrust and more.
22+
*Coming soon* - integrations with LangSmith, JinaAI, and more.
2223

2324
***
2425

docs/integrationsold.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ import TabItem from '@theme/TabItem';
4141
</TabItem>
4242
<TabItem value="js" label="JavaScript">
4343

44+
## Braintrust
45+
46+
Braintrust is the enterprise-grade stack for building AI products. From evaluations, to prompt playground, to data management,
47+
we take uncertainty and tedium out of incorporating AI into
48+
your business.
49+
50+
- [Evaluate a Chroma RAG app using Braintrust](https://www.braintrustdata.com/docs/examples/rag)
51+
4452
## 🦜️🔗 LangchainJS
4553

4654
Here is an [example in LangChainJS](https://github.com/hwchase17/langchainjs/blob/main/examples/src/chains/chat_vector_db_chroma.ts)

sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const sidebars = {
6565
items: [
6666
'integrations/langchain',
6767
'integrations/llama-index',
68+
'integrations/braintrust',
6869
'integrations/openllmetry',
6970
],
7071
},

0 commit comments

Comments
 (0)