Documentation Index Fetch the complete documentation index at: https://docs.getbindu.com/llms.txt
Use this file to discover all available pages before exploring further.
Simple Q&A agent powered by DSPy framework.
Code
"""DSPy Agent Example — Bindu Integration
=======================================
WHAT EXISTED BEFORE:
Only Agno, CrewAI, LangChain examples existed.
No DSPy integration existed anywhere in the repo.
WHAT IS NEW:
- First DSPy example in the Bindu ecosystem
- Uses DSPy Signatures for structured, typed prompting
- Supports multi-turn conversation history
- Works with any OpenAI-compatible model
"""
import dspy
from bindu.penguin.bindufy import bindufy
# Configure DSPy with your preferred LLM
lm = dspy.LM( "openai/gpt-4o-mini" )
dspy.configure( lm = lm)
# Define a DSPy Signature (typed prompt template)
class QASignature ( dspy . Signature ):
"""Answer the user's question clearly and concisely."""
question: str = dspy.InputField( desc = "The user's question" )
answer: str = dspy.OutputField( desc = "A clear and concise answer" )
# Build the DSPy program
qa_program = dspy.Predict(QASignature)
config = {
"author" : "varshayadav1722@gmail.com" ,
"name" : "dspy_agent" ,
"description" : "A DSPy-powered question answering agent" ,
"deployment" : {
"url" : "http://localhost:3773" ,
"expose" : True ,
"cors_origins" : [ "http://localhost:5173" ]
},
}
def handler ( messages : list[ dict ]) -> list[ dict ]:
last_message = messages[ - 1 ][ "content" ]
result = qa_program( question = last_message)
return [{ "role" : "assistant" , "content" : result.answer}]
if __name__ == "__main__" :
bindufy(config, handler)
How It Works
Instructions
Defines agent through DSPy Signature class
Provides clear and concise answers to questions
Uses structured prompting for consistent responses
Maintains helpful and informative tone
Tools
dspy.Signature: Typed prompt template for Q&A
dspy.Predict: Program execution framework
dspy.LM: Language model configuration
Model
gpt-4o-mini: Cost-effective model for Q&A
Via OpenAI-compatible API integration
Configurable through DSPy LM configuration
Dependencies
uv init
uv add bindu dspy-ai
Environment Setup
Create .env file:
OPENAI_API_KEY = your_openai_api_key_here
Run
Examples:
“What are the main benefits of using DSPy for prompting?”
“How do I create a DSPy signature for my function?”
“What are the key components of DSPy?”
Example API Calls
{
"jsonrpc" : "2.0" ,
"method" : "message/send" ,
"params" : {
"message" : {
"role" : "user" ,
"kind" : "message" ,
"messageId" : "9f11c870-5616-49ad-b187-d93cbb100001" ,
"contextId" : "9f11c870-5616-49ad-b187-d93cbb100002" ,
"taskId" : "9f11c870-5616-49ad-b187-d93cbb100003" ,
"parts" : [
{
"kind" : "text" ,
"text" : "What are the main benefits of using DSPy for prompting?"
}
]
},
"configuration" : {
"acceptedOutputModes" : [ "application/json" ]
}
},
"id" : "9f11c870-5616-49ad-b187-d93cbb100003"
}
{
"jsonrpc" : "2.0" ,
"method" : "tasks/get" ,
"params" : {
"taskId" : "9f11c870-5616-49ad-b187-d93cbb100003"
},
"id" : "9f11c870-5616-49ad-b187-d93cbb100004"
}
Frontend Setup
# Clone the Bindu repository
git clone https://github.com/GetBindu/Bindu
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start frontend development server
npm run dev
Open http://localhost:5173 and try to chat with the DSPy agent