# {{name}} - RAG Assistant

{{description}}

## Overview

This project contains a RAG (Retrieval-Augmented Generation) assistant that can answer questions based on your documents.

## Configuration

- **Assistant Name**: {{name}}
- **Model**: {{model}}
- **Embedding Model**: {{embedding_model}}
- **Documents Directory**: ./{{documents_dir}}/

## Setup Instructions

### 1. Add Your Documents

Place your documents in the `./{{documents_dir}}/` directory:

```bash
cp /path/to/your/documents/* ./{{documents_dir}}/
```

Supported formats:
- PDF (.pdf)
- Text files (.txt, .md)
- Word documents (.docx)
- And more...

### 2. Create the RAG Assistant

Run the creation script:

```bash
python create_{{name}}.py
```

This will:
- Create the RAG assistant in your GEAI project
- Configure the LLM and embedding models
- Set up chunk size and retrieval parameters

### 3. Upload Documents

Upload your documents to the assistant's knowledge base:

```bash
python upload_documents.py
```

This will process and index all documents from the `./{{documents_dir}}/` directory.

### 4. Chat with Your Assistant

Start an interactive chat session:

```bash
python chat_{{name}}.py
```

## Usage Examples

### Interactive Chat

```bash
$ python chat_{{name}}.py

You: What is the main topic of the documents?
Assistant: [Answer based on your documents...]

You: Tell me more about...
Assistant: [Detailed response...]

You: exit
Goodbye!
```

### Programmatic Usage

```python
from pygeai.assistant.rag.clients import RAGAssistantClient

client = RAGAssistantClient()

response = client.chat_with_assistant(
    assistant_name="{{name}}",
    message="Your question here"
)

print(response)
```

## Project Structure

```
.
├── README.md                    # This file
├── create_{{name}}.py          # Script to create the assistant
├── chat_{{name}}.py            # Interactive chat interface
├── upload_documents.py          # Document upload script
└── {{documents_dir}}/          # Your source documents
```

## Customization

You can modify the assistant configuration in `create_{{name}}.py`:

- **Temperature**: Controls randomness (0.0-1.0)
- **Max Tokens**: Maximum response length
- **Chunk Size**: Size of document chunks for retrieval
- **k**: Number of relevant chunks to retrieve
- **Score Threshold**: Minimum relevance score for chunks

## Troubleshooting

### No Documents Found

Make sure you've added documents to the `./{{documents_dir}}/` directory before running `upload_documents.py`.

### Assistant Not Found

If you get an "assistant not found" error, make sure you've run `create_{{name}}.py` first.

### Connection Errors

Verify your GEAI credentials are configured:

```bash
geai configure
```

## Next Steps

- Add more documents to improve knowledge coverage
- Experiment with different chunk sizes and retrieval parameters
- Try different LLM models for varying response styles
- Integrate the assistant into your applications

## Learn More

- [PyGEAI Documentation](https://pygeai-sdk.readthedocs.io/)
- [RAG Assistant Guide](https://pygeai-sdk.readthedocs.io/en/latest/content/assistants/rag.html)
- [GEAI Platform](https://geai.globant.com/)
