Gemini AI Sandbox is an application designed to manage pairs of questions and answers utilized by Gemini AI to provide responses based on predefined information.
- GO as the programming language
- Gin as the HTTP Framework
- MySQL as the Database
- Generative AI SDK package from Google for interacting with Gemini AI
- User Asking: Users submit questions via the
POST /chat
endpoint to the system. - Pre-stored Information: The application querying stored information in the database.
- Populated Information: The database provides the stored information to the application.
- Gemini Integration: The application forwards the user's question, along with the retrieved information, to Gemini Pro.
- Gemini Response: Gemini Pro generates an answer to the user's question based on the provided information.
- User Response: Finally, the user receives the answer to their question.
Before using the Chat API, you need to set pairs of questions and answers using the Informations API.
For example, if you want Gemini to answer questions about personal information, you need to set up relevant information.
Store this pair of questions and expected answers using Informations API:
Question: What is your name?
Answer: John Doe
The expected behavior for Gemini when using the Chat API after storing this information would be:
// Your Question
What is your last name?
// Gemini Answer
Doe
Ensure you have a Google Cloud Project API Key.
Note: Update the
API_KEY
in the docker-compose.yml with your API key.
Follow these steps to run Gemini AI Sandbox as a Docker container:
docker-compose up -d
docker exec gemini-api "./migration"
Here are list of available API
Add New Information
Store new pair of question and answer used later by gemini to provide an answer
POST /informations
{
"question": string, // user question
"answer": string // answer expectation
}
{
"data":{
"id": int,
"question": string,
"answer": string
},
"success": boolean
}
Get Stored Information List
Return stored information
GET /informations
{
"data": [
{
"id": int,
"question": string,
"answer": string
}
],
"success": boolean
}
Get Stored Information By ID
Return stored information by id
GET /informations/:id
id
: integer
{
"data":{
"id": int,
"question": string,
"answer": string
},
"success": boolean
}
Edit Information
Edit stored pair of question and answer
PUT /informations/:id
id
: integer
{
"question": string, // user question
"answer": string // answer expectation
}
{
"data":{
"id": int,
"question": string,
"answer": string
},
"success": boolean
}
Delete Stored Information
Delete stored information
DELETE /informations/:id
id
: integer
{
"data":{
"id": int,
"question": string,
"answer": string
},
"success": boolean
}