Introducing Odoo Expert Streaming API & Integration
Discover how Odoo Expert's new streaming API revolutionizes documentation search with instant, AI-powered responses. It can be integrated and deliver real-time answers while browsing Odoo docs, enhancing user experience with version-specific results and seamless integration.
Imagine getting instant, AI-powered answers while browsing Odoo documentation—no more waiting for complete responses to load. That's exactly what I've achieved with the latest streaming API update to my Odoo Expert chatbot project.
I’m excited to share this major update to my Odoo Expert chatbot project: streaming API support. This feature lets me serve up real-time, AI-powered responses directly in my local Odoo documentation site—right at the top of the page, above the usual search results.
What is Odoo Expert?
Odoo Expert is a documentation assistant that leverages Retrieval-Augmented Generation (RAG) to provide intelligent search capabilities across Odoo's technical documentation. It supports multiple Odoo versions and features an interactive chat interface powered by Large Language Models (LLMs).
The Challenge: Response Time and User Experience
The original version of Odoo Expert provided accurate answers but had a significant limitation: users had to wait for the entire response to be generated before seeing any output. The /api/chat
endpoint's loading time was notably slow due to the comprehensive processing required for each query. This delay disrupted the natural flow of documentation search and hindered user experience.
The Solution: Streaming API Implementation
To address this challenge, I developed a streaming solution that delivers response chunks in real-time, creating a more dynamic and responsive experience. Here's how it works:
Backend Implementation
I extended my chatbot’s backend with an endpoint (/api/stream
) that streams text chunks in text/event-stream format. This addition means I can now continuously deliver chunks of the AI’s response as they become available. Under the hood, it retrieves relevant documentation chunks, prepares them for context, and then streams the answer—complete with markdown and real-time updates—right in the browser.
Now, if you are using Odoo Expert, you can simply make a POST request to the /api/stream
endpoint, to query the documentation and get AI-powered responses in streaming format.
curl -X POST "http://localhost:8000/api/stream" \
-H "Authorization: Bearer your-api-token" \
-H "Content-Type: application/json" \
-d '{
"query": "How do I install Odoo?",
"version": 180,
"conversation_history": []
}'
For the detailed guide and change log, you are welcome to follow the guide in the GitHub repo.
Integrate it into the Odoo Documentation Website
Thankfully, Odoo's documentation website with its content is open sourced:
Because the open source, I can easily build the static HTML website by myself, and by changing the source code, I can test the integration with Odoo Expert. To dive deeply into the technical details, here is what I have done:
- New AI Response Section
- I introduced a dedicated section (
#ai-response-section
) insearch.html
to display AI-powered insights. This section is placed above the default search results, ensuring it grabs the user’s attention. - A new CSS file (
ai-response.css
) styles the response box and keeps the code neatly organized.
- I introduced a dedicated section (
- JavaScript for Real-Time Updates
- I added a script to fetch the search query from the URL and detect the Odoo version.
- The script calls the new
/api/stream
endpoint, listening to the server-sent events. - As text chunks arrive, the script renders them in real time with Marked.js, enabling markdown formatting on the fly.
- Version-Aware Replies
- I used a straightforward approach to capture the correct Odoo version (e.g., 16.0, 17.0, 18.0) from the documentation page.
- With this version passed along in the request, my chatbot only pulls content relevant to that specific Odoo release.
Results and Impact
The streaming implementation has transformed and revolutionized the documentation search experience as the video shown above:
- Immediate response initiation instead of waiting for complete generation
- Smooth, chat-like interaction with the documentation
- Maintained accuracy while improving responsiveness
- Version-specific results that match the user's context
Here's how the search process now works:
- User enters a search query
- AI response begins streaming immediately above search results
- Traditional search results remain available below
- All responses include citations and references to official documentation
Technical Highlights
- StreamingResponse in FastAPI: I used this class to handle the server-sent events so the front end can receive data piece by piece.
- Efficient Document Retrieval: My chatbot filters and retrieves the most relevant chunks from local Odoo docs, ensuring the conversation is grounded in actual Odoo documentation.
- Simple to Integrate: By modifying
search.html
and adding minimal CSS/JS, I was able to incorporate the streaming feature smoothly into the existing docs interface.
Wrapping Up
The project is open source and welcomes contributions. Whether you're interested in improving the streaming implementation, enhancing the RAG system, or adding new features, visit my GitHub repository to get started.
By implementing streaming responses, Odoo Expert now provides a more natural and efficient documentation search experience. The combination of real-time responses and version-aware context makes it a powerful tool for Odoo developers and users alike.
Have questions or suggestions? Feel free to reach out through the GitHub repository or join the discussion in the issues section. Let's continue making Odoo documentation more accessible and user-friendly!
Discussion