Skip to content

Load Proposal Context into AI Agent from Mock JSON (Simulated DB + Blockchain + Blob Data) #71

@pmora3003

Description

@pmora3003

✨ 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

OpenAI Realtime Sessions API

Intro to GPT Integration

Agent Logic Base: Check DevoteApp/components/AIAgent.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededonlydust-waveContribute to awesome OSS repos during OnlyDust's open source week

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions