Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added README. Fixes issue #13 #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Sugar AI: Child-Friendly AI Assistant & Python Coding Helper

A dual-purpose AI system combining child-friendly question answering with Python coding assistance using Retrieval-Augmented Generation (RAG).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "dual-purpose"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By dual purpose, I meant child-friendly and a coding assistant. Is that wrong?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't clear at first what it was, it also doesn't just help with Python, it specifically can help with Sugar and GTK related questions.


## Features

### 🌟 Child-Friendly QA (main.py)
- Answers children's questions using simple language
- Automatically explains complex terms for 3-year-old understanding
- GPT-2 model with response limit (60 words)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're no longer using this, see #12 and #11.

- Safety-focused content generation

### 💻 Python Coding Assistant (rag_agent.py)
- Specialized in Pygame, GTK+, and Sugar Toolkit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugar Toolkit Gtk3, because there's a Sugar Toolkit and that's not what this specializes on.

Just noticed that the docs have it named that way, but the content is different.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I change it to
-Uses Sugar Toolkit and Gtk3

I'm not sure about this so please help

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Sugar Toolkit Gtk3" not "Sugar Toolkit and Gtk3", one refers to sugar-toolkit-gtk3 and the other refers to sugar-tookit and Gtk3.

- RAG system with Llama3.1 model
- Documentation sources:
- Pygame Documentation
- Python GTK+3 Documentation
- Sugar Toolkit Documentation
- Step-by-step explanations
- Context-aware error troubleshooting

## Installation

### Prerequisites
- Python 3.10+
- Ollama (for Llama3.1 model)
- GPU recommended for better performance

```bash
# Clone repository
git clone https://github.com/sugarlabs/sugar-ai.git
cd sugar-ai

# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows

# Install dependencies
pip install -r requirements.txt

# Set up Ollama
ollama pull llama3.1
```

## Usage

### Child-Friendly QA
```python
from main import AI_Test

assistant = AI_Test()
response = assistant.generate_bot_response("Why is the sky blue?")
print(response)
```

### Coding Assistant
Start the assistant:
```bash
python rag_agent.py
```

Example session:
```
> How to create a window in GTK+3?
Let's think step by step.
1. Import Gtk module
2. Create Window object
3. Set title and size
4. Connect delete event
5. Show all elements
...
```
Comment on lines +49 to +74
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing as this is supposed to be an API, it's not to be used this way, not even when developing.

For local development, you'd have a local server running which you can then send requests to and get a response.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I just remove this Usage part or just write use as an API? I have not worked on this project and my understanding comes from just reading the code and documentation so I might be wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this part for now.

@kshitijdshah99 might write this better.


## Project Structure
```
sugar-ai/
├── main.py - Child QA with GPT-2
├── rag_agent.py - Coding assistant with RAG
├── docs/ - Documentation PDFs
└── requirements.txt - Dependency list
```

## Configuration

### Document Paths (rag_agent.py)
```python
document_paths = [
'./docs/Pygame Documentation.pdf',
'./docs/Python GTK+3 Documentation.pdf',
'./docs/Sugar Toolkit Documentation.pdf'
]
```
Comment on lines +76 to +94
Copy link
Member

@chimosky chimosky Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should come under a contributing section, here it just seems like bloat and a bit out of place.


### Prompt Templates
**Child QA:**
```python
prompt = '''
Your task is to answer children's questions using simple language.
Explain any difficult words in a way a 3-year-old can understand.
Keep responses under 60 words.
\n\nQuestion:
'''
```

**Coding Assistant:**
```python
PROMPT_TEMPLATE = """
You are a highly intelligent Python coding assistant built for kids.
You are ONLY allowed to answer Python and GTK-based coding questions.
1. Focus on coding-related problems...
"""
```

## Dependencies

### Core Technologies
- Transformers (Hugging Face)
- LangChain
- FAISS (Vector Store)
- Ollama
- PyMuPDF (PDF processing)
Comment on lines +116 to +123
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like bloat because it focuses on just one part of the API, while the other one is ignored.

We're yet to trim our requirements.txt at the moment but this just focuses on one side, I'd rather it not exist that focus on one side.


### Key Libraries
```txt
transformers==4.45.2
torch==2.4.1
langchain-ollama==0.3.3
faiss-cpu==1.9.0
sentence-transformers==3.1.1
```

## Contributing

1. Fork the repository
2. Create feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Open Pull Request

## License

GNU General Public License v3.0
See [LICENSE](COPYING) for full text.

---

> **Note:** Ensure Ollama service is running before using the RAG agent
> `ollama serve`