Skip to content

feat(chat): scaffold chatbotAPI with local Ollama integration#30

Open
Yatharth-coding wants to merge 2 commits into
FOSSEE:developfrom
Yatharth-coding:intern/chatbot
Open

feat(chat): scaffold chatbotAPI with local Ollama integration#30
Yatharth-coding wants to merge 2 commits into
FOSSEE:developfrom
Yatharth-coding:intern/chatbot

Conversation

@Yatharth-coding

Copy link
Copy Markdown

Executive Summary

This PR introduces the foundational backend architecture for the AI Circuit Assistant (Minor Project). It scaffolds the new chatbotAPI Django app and integrates a secure, fully local LLM client using Ollama. This ensures the AI assistant can run entirely locally without relying on paid external APIs, API keys, or internet connectivity.

Key Features & Implementations

  • chatbotAPI Scaffold: Created the core Django app structure following the project's existing API conventions, including URL routing and app registration.
  • Local Ollama Integration:
    • Built services/llm_client.py to handle HTTP communication with a local Ollama instance.
    • Implemented robust error handling for timeouts, connection drops, and missing models.
  • Core Endpoints:
    • GET /api/chat/health/: Added an open health check endpoint.
    • POST /api/chat/message/: Implemented the main chat interface featuring strict payload validation (enforcing an 8KB limit on context JSON to prevent oversized requests).
  • Automated Testing: Developed comprehensive unit tests utilizing unittest.mock to ensure that CI/CD pipelines will pass without requiring a live Ollama server to be running.

Local Testing Instructions for Reviewers

  1. Install Ollama on your host machine.
  2. Pull the required model by running: ollama pull llama3.2 (or the model specified in your .env).
  3. Ensure Ollama is running locally on port 11434.
  4. Start the eSim-Cloud Docker stack and test the /api/chat/message/ endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant