Chat With GitHub
LLM app with RAG to chat with GitHub Repo in just 30 lines of Python Code. The app uses Retrieval Augmented Generation (RAG) to provide accurate answe…
- OpenAI
- Llama
- local
Chat with Your Data ·Easy
A minimal example demonstrating real-time AI streaming and conversation state management using the Motia framework. streaming-ai-chatbot(docs/images/streaming-ai-chatbot.gif)
AZURE_OPENAI_API_KEYOPENAI_API_KEYLicense Apache-2.0 · content curated and maintained by Doutor AI.
A minimal example demonstrating real-time AI streaming and conversation state management using the Motia framework.
streaming-ai-chatbot/
├── steps/
│ ├── conversation.stream.ts # Real-time conversation state
│ ├── chat-api.step.ts # Simple chat API endpoint
│ └── ai-response.step.ts # Streaming AI response handler
├── package.json # Dependencies
├── .env.example # Configuration template
└── README.md # This file
# Clone the repository
git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
cd advanced_llm_apps/chat_with_X_tutorials/chat_with_llms
# Install dependencies
npm install
# Start the development server
npm run dev
cp .env.example .env
# Edit .env and add your OpenAI API key
Open Motia Workbench:
Navigate to http://localhost:3000 to interact with the chatbot
POST /chat
{
"message": "Hello, how are you?",
"conversationId": "optional-conversation-id" // Optional: If not provided, a new conversation will be created
}
Response:
{
"conversationId": "uuid-v4",
"message": "Message received, AI is responding...",
"status": "streaming"
}
The response will update as the AI processes the message, with possible status values:
created: Initial message statestreaming: AI is generating the responsecompleted: Response is complete with full messageWhen completed, the response will contain the actual AI message instead of the processing message.
The conversation state stream provides live updates as the AI generates responses:
status: 'completed'status: 'streaming', update in real-time, end with status: 'completed'const stream = await openai.chat.completions.create({
model: 'gpt-4o-mini',
messages: [...],
stream: true, // Enable streaming
})
for await (const chunk of stream) {
// Update state with each token
await streams.conversation.set(conversationId, messageId, {
message: fullResponse,
status: 'streaming',
// ...
})
}
export const config: StateStreamConfig = {
name: 'conversation',
schema: z.object({
message: z.string(),
from: z.enum(['user', 'assistant']),
status: z.enum(['created', 'streaming', 'completed']),
timestamp: z.string(),
}),
baseConfig: { storageType: 'state' },
}
// API emits event
await emit({
topic: 'chat-message',
data: { message, conversationId, assistantMessageId },
})
// Event handler subscribes and processes
export const config: EventConfig = {
subscribes: ['chat-message'],
// ...
}
This example showcases Motia's power in just 3 files:
Perfect for demonstrating how Motia makes complex real-time applications simple and maintainable.
OPENAI_API_KEY: Your OpenAI API key (required)LLM app with RAG to chat with GitHub Repo in just 30 lines of Python Code. The app uses Retrieval Augmented Generation (RAG) to provide accurate answe…
LLM app with RAG to chat with Gmail in just 30 lines of Python Code. The app uses Retrieval Augmented Generation (RAG) to provide accurate answers to …
LLM app with RAG to chat with PDF in just 30 lines of Python Code. The app uses Retrieval Augmented Generation (RAG) to provide accurate answers to qu…
Need a tailor-made solution?
Not sure where to start with AI in your business? Get a free assessment and a tailored plan - no commitment.
Doutor AI gives you 1,859 ready-to-copy AI prompts, by industry and in plain English - plus a complete technical library for those who want to go further.