An AI-powered coding assistant for the Sugar Learning Platform
Sugar-AI is a specialized coding assistant designed to help children learn programming with the Sugar Learning Platform. It uses advanced AI to provide child-friendly explanations and code examples.
Sugar-AI helps students and teachers learn coding with Sugar Labs tools:
Integrate Sugar-AI with your applications using our simple API:
Manage Sugar-AI and monitor usage through the admin panel:
The Sugar-AI Dashboard is your personal control center, accessible after signing in with OAuth or an API key. Here's what you can do:
Ask questions directly to the AI and receive instant responses about Sugar development
Switch between knowledge-enhanced responses and direct language model responses
Track your API usage, remaining quota.
Integrate Sugar-AI's capabilities into your own applications with our straightforward API:
import requests
# Make a request to the Sugar-AI API
api_key = "YOUR_API_KEY"
url = "https://sugar-ai.sugarlabs.org/ask"
params = {"question": "How do I create a Pygame window?"}
headers = {"X-API-Key": api_key}
response = requests.post(url, params=params, headers=headers)
result = response.json()
print(result["answer"])
Ask a coding question using Retrieval-Augmented Generation for enhanced context and precision.
X-API-Key: your_api_key
curl -X POST "http://localhost:8000/ask?question=How%20do%20I%20create%20a%20Python%20class?" \
-H "X-API-Key: your_api_key"
{
"answer": "Detailed explanation about Python classes...",
"user": "Your Username",
"quota": {"remaining": 95, "total": 100}
}
Send your python code to get debugging suggestions, with context mode for kid-friendly code explanations.
X-API-Key: your_api_key
code: your_python_code, context: true | false # turn on context mode (explains code in a kid-friendly way)
curl -X POST "http://localhost:8000/debug?code=How%20do%20I%20create%20a%20Python%20class&context=False?" \
-H "X-API-Key: your_api_key"
{
"answer": "Debugging suggestions for your python code....",
"user": "Your Username",
"quota": {"remaining": 95, "total": 100}
}
Ask a question directly to the LLM without RAG enhancement.
X-API-Key: your_api_key
curl -X POST "http://localhost:8000/ask-llm?question=What%20is%20the%20difference%20between%20lists%20and%20tuples?" \
-H "X-API-Key: your_api_key"
A powerful endpoint that allows custom system prompts and configurable generation parameters for maximum flexibility.
X-API-Key: your_api_key Content-Type: application/json
curl -X POST "http://localhost:8000/ask-llm-prompted" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"question": "How do I create a Pygame window?",
"custom_prompt": "You are a Python expert. Provide detailed code examples with explanations."
}'
curl -X POST "http://localhost:8000/ask-llm-prompted" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"question": "Write a function to calculate fibonacci numbers",
"custom_prompt": "You are a coding tutor. Explain step-by-step with comments.",
"max_length": 1024,
"truncation": true,
"repetition_penalty": 1.1,
"temperature": 0.7,
"top_p": 0.9,
"top_k": 50
}'
{
"answer": "Here's how to create a Pygame window:...",
"user": "Your Username",
"quota": {"remaining": 95, "total": 100},
"generation_params": {
"max_length": 1024,
"truncation": true,
"repetition_penalty": 1.1,
"temperature": 0.7,
"top_p": 0.9,
"top_k": 50
}
}
Different activities can use different system prompts and generation parameters to achieve a model that is personalized to specific activity needs. Some example are:
Change the LLM model being used for responses. Requires admin API key and password.
curl -X POST "http://localhost:8000/change-model?model=Qwen/Qwen2-1.5B-Instruct&api_key=admin_key&password=admin_password"