Skip to content

AI Assistant for Pippy and chat integration #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AdityaShome
Copy link

@AdityaShome AdityaShome commented Apr 15, 2025

Chages made:

This PR introduces AI-powered code analysis and chat capabilities to Pippy using Code Llama locally through Ollama integration. The implementation includes a dedicated server for AI interactions and a new UI panel for the chat interface.

Example

Child friendly:
Screenshot from 2025-04-14 23-12-42
Explaination:
Screenshot from 2025-04-14 18-23-02
Chat interface:
Screenshot from 2025-04-14 18-24-33

Technical Details

New Components

  1. Code Llama Server

    • Integration by codellama_server.py with Ollama's API for model inference
    • CodeLlamaHandler class for request handling
    • check_ollama_health() method for service verification
    • make_ollama_request() method with retry logic
    • Support for both code analysis and chat endpoints
  2. Code Llama Helper

    • Manages communication with the Code Llama server
    • CodeLlamaHelper Handles JSON request/response formatting
    • Implements retry logic for failed requests
  3. Code Llama Pane (CodeLlamaPane class)

    • GTK-based UI component for the chat interface
    • Features:
      • Text entry field for user messages
      • Send button for message submission
      • Color-coded message display (user/AI)
      • Automatic scrolling to latest messages
      • Thread-safe message handling

Key Features

  • Code Analysis

    • Automatic code analysis on file changes
    • Structured response format (functionality, improvements, issues)
    • Configurable response length and quality parameters according to requirements
  • Chat Interface

    • Real-time chat with Code Llama
    • Message history display
    • Error handling and user feedback
    • Optimized response parameters for natural conversation

Performance Optimizations

  • Response timeout: 120 seconds
  • Max tokens: 100
  • Context window: 2048
  • CPU threads: 4
  • Temperature: 0.1 (code analysis), 0.7 (chat)
  • Retry mechanism with 3 attempts and 2-second delays

Error Handling

  • Health checks for Ollama service
  • Retry logic for failed requests
  • Detailed error logging
  • User-friendly error messages
  • Timeout handling with informative feedback

Testing

The implementation has been tested with:

  • Chat interactions
  • Error conditions (logs, timeouts, service unavailability)
  • UI responsiveness and thread safety

Dependencies

  • Python 3.x
  • GTK 3
  • Ollama service with Code Llama model
  • llama-cpp-python package

Setup

  • The Code Llama model should be pulled and running in Ollama before using these features
  • The server runs on port 8080 by default
  • Memory usage and response times might vary based on system resources

Kindly suggest the modifications needed and should I also give gemini or openai api support as fallback or configurable mode.

tant with chat interface
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