Skip to content

Commit 4e30ae4

Browse files
copy guide from notion
1 parent 7cb5e62 commit 4e30ae4

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

README.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,114 @@
11
# Agility Python API library
2+
3+
# Installation
4+
5+
You can install the Agility python client from [our internal repo](https://github.com/cleanlab/agility-python) with:
6+
7+
```python
8+
pip install git+ssh://git@github.com/cleanlab/agility-python.git
9+
```
10+
11+
# Overview
12+
13+
This user guide goes over the basic concepts of Agility and includes an example of how to create an Agility assistant.
14+
15+
Cleanlab Agility is an end-to-end API that allows you to create trustworthy AI applications. The API allows you to build reliable RAG systems by ingesting data from a wide variety of sources into Knowledge Bases and by creating AI Assistants that can respond to user queries while accessing the relevant data and providing reliable, interpretable answers.
16+
17+
## Concepts
18+
19+
### Knowledge Bases
20+
21+
- **Knowledge Bases** -
22+
- **Sources** -
23+
- **Documents** -
24+
25+
### Assistants
26+
27+
- **Assistant** - An AI Assistant that will respond to user queries, while referencing user-supplied data sources and instructions.
28+
- **Threads -** A conversation session between a user and Assistant. Threads store Messages and retrieve context from Knowledge Bases to provide trustworthy results
29+
- **Messages -** A message created by a user or Assistant. Messages are represented as text and are attached to a parent Thread
30+
- **Runs -** Invokes the Assistant for a specific Thread. It uses the configuration for the Assistant as part of the context, including the data sources from its Knowledge Base and provided instructions. A Run will add Messages to the Thread
31+
32+
33+
# Quick Start
34+
35+
## Step 0: Initialize python client
36+
37+
```python
38+
from agility import Agility
39+
40+
api_key = "your_agility_api_key"
41+
42+
client = Agility(api_key=api_key)
43+
```
44+
45+
## Step 1: Create a Knowledge Base
46+
47+
```python
48+
knowledge_base = client.knowledge_bases.create(
49+
name="Cleanlab docs",
50+
description="Developer-facing docs for using Cleanlab",
51+
ingestion_pipeline_params={
52+
"curate": {},
53+
"curate_document_store": {},
54+
"transform": {},
55+
"vector_store": {
56+
"weaviate_collection_name": "weaviate_collection_name"
57+
},
58+
},
59+
)
60+
```
61+
62+
## Step 2: Add a source to a Knowledge Base
63+
64+
```python
65+
source = client.knowledge_bases.sources.create(
66+
knowledge_base_id=knowledge_base.id,
67+
name="Cleanlab docs URLs",
68+
description="APIs and tutorials for Studio and TLM",
69+
source_params={
70+
"urls": ["https://help.cleanlab.ai", "https://help.cleanlab.ai/tlm"]
71+
},
72+
source_schedule={
73+
"cron": "cron",
74+
"utc_offset": 0,
75+
},
76+
)
77+
```
78+
79+
## ?? Step x: figure out if there are any other necessary actions related to sources and documents, such as source syncing
80+
81+
## Step 3: Create an Assistant
82+
83+
```python
84+
assistant = client.assistants.create(
85+
knowledge_base_id=knowledge_base.id,
86+
name="Chat with Cleanlab Docs",
87+
description="Chat with Cleanlab Docs for Studio and TLM",
88+
)
89+
```
90+
91+
## Step 4: Create a Thread
92+
93+
```python
94+
thread = client.threads.create()
95+
```
96+
97+
## Step 5: Add a Message to a Thread
98+
99+
```python
100+
message = client.threads.messages.create(
101+
thread_id=thread.id,
102+
role="user",
103+
content="I need to run TLM in batch-mode on a large number of datapoints. Can you help me?",
104+
)
105+
```
106+
107+
## Step 6: Create a Run
108+
109+
```python
110+
run = client.threads.runs.create(
111+
thread_id=thread.id,
112+
assistant_id=assistant.id,
113+
)
114+
```

0 commit comments

Comments
 (0)