Uses [[AI Embeddings]]
When a file is passed, it will automatically chunk, index, and store embeddings, and impelement vector search for user queries
## Upload file
Can get information in files or based on user-provided info during thread
$0.20Â / GB / assistant / day
#### Assistant
```python
# Upload a file with an "assistants" purpose
file = client.files.create(
file=open("knowledge.pdf", "rb"),
purpose='assistants'
)
# Add the file to the assistant
assistant = client.beta.assistants.create(
instructions="You are a customer support chatbot. Use your knowledge base to best respond to customer queries.",
model="gpt-4-1106-preview",
tools=[{"type": "retrieval"}],
file_ids=[file.id]
)
```
#### Thread
```python
message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content="I can't find in the PDF manual how to turn off this device.",
file_ids=[file.id]
)
```
### Chunking
https://platform.openai.com/docs/assistants/tools/knowledge-retrieval
- Done when file is uploaded
- Used to answer relevant queries
## Retrieval Process
- Retrieval methods
- Passes file content in prompt for short documents
- Vector search for long documents
## Annotations
Can convert to corresponding file download using annotations
https://platform.openai.com/docs/assistants/how-it-works/managing-threads-and-messages
Markdown is supported