Skip to content

Implement real AI API integration for AI Assistant#152

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/update-unknown-feature
Draft

Implement real AI API integration for AI Assistant#152
Copilot wants to merge 2 commits into
mainfrom
copilot/update-unknown-feature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 4, 2025

Replace mock AI responses with actual LLM API integration. The AI Assistant now connects to real models via Ollama, OpenAI, Anthropic, or custom endpoints.

Changes

  • src/lib/ai-service.ts - AI service class with streaming support for multiple providers

    • Ollama/local model API format
    • OpenAI-compatible chat completions
    • Anthropic messages API
    • Custom endpoint passthrough
    • Request cancellation via AbortController
  • src/hooks/useAIChat.ts - React hook for chat state management

    • Streaming response handling with token callbacks
    • Model settings persistence to localStorage
    • Active model selection and connection status
  • src/components/ai-assistant/AIAssistant.tsx - Updated UI

    • Real-time streaming response display
    • Stop/abort button during generation
    • Clear conversation action
    • Error state handling with user feedback

Usage

const { sendMessage, isStreaming, currentResponse } = useAIChat();
await sendMessage("查看钱包余额");

Screenshots

Chat Interface

AI Chat Interface

Model Configuration

Model Configuration

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/runtime/0d8a8192229dfe2338a7/loaded
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/AICHI3LM11.29/AICHI3LM11.29/node_modules/.bin/vite --host (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

老子要真的


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Create AIService class to handle real API calls to LLM providers (Ollama, OpenAI, Anthropic, custom endpoints)
- Add streaming response support for real-time token display
- Create useAIChat React hook for managing AI chat state and settings
- Update AIAssistant component to use real AI API instead of mock responses
- Add error handling, loading states, and abort functionality
- Persist model settings to localStorage

Co-authored-by: hhongli1979-coder <244808107+hhongli1979-coder@users.noreply.github.com>
Copilot AI changed the title [WIP] Update unspecified feature implementation Implement real AI API integration for AI Assistant Dec 4, 2025
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.

2 participants