-
Notifications
You must be signed in to change notification settings - Fork 22
Description
✨ Objective
Improve the DeVote AI Agent by integrating contextual proposal data before answering questions. This MVP will simulate loading proposal context from a structured JSON file (acting as mock data from the blockchain, database, and blob storage) into the AI Agent session context before user interaction.
🛠 Tasks
🔧 Backend / AI Layer
Create a mock JSON file (e.g., proposalContextMock.json) to simulate the combined data from:
Proposal metadata in the DB
On-chain proposal state
File links or summaries from blob storage (PDF/Word/image)
Example JSON structure:
{
"proposalId": "abc123",
"title": "Solar Panel Installation in Community X",
"summary": "Install renewable solar energy in rural area",
"status": "Active",
"blockchain": {
"votesFor": 12,
"votesAgainst": 5,
"deployed": true
},
"blob": {
"contextFileUrl": "https://vercel-blob.com/abc123/context.pdf"
}
}
Update the AI Agent invocation logic to:
Load this JSON at the start of a session.
Inject the content into the AI context using OpenAI’s realtime sessions API as preloaded context:
OpenAI API - Realtime Sessions: Create
Ensure the AI can access and reference this context in its responses.
Keep the session stateless with clear comments, as this is an MVP. No real DB or blockchain calls are needed yet — just mock injection.
🧠 AI Behavior
AI should respond to simple prompts like:
“What is the proposal about?”
“How many votes does it have?”
“Can I read the full document?”
All answers must come from the injected mock JSON data.
✅ Acceptance Criteria
Proposal context from the mock JSON is successfully injected into the AI session.
The AI agent can answer questions using this data exclusively.
No live data fetching is needed — mock only.
MVP is modular so it can later be replaced with real data sources.
📦 Resources
Agent Logic Base: Check DevoteApp/components/AIAgent.tsx