Skip to content

Integrate AI Agent Platform with OpenWebUI at http://72.61.178.135:3000/#38

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/add-tool-to-link
Draft

Integrate AI Agent Platform with OpenWebUI at http://72.61.178.135:3000/#38
Copilot wants to merge 6 commits intomainfrom
copilot/add-tool-to-link

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 20, 2025

Overview

This PR integrates the AI Agent Platform's web interface with an OpenWebUI instance running at http://72.61.178.135:3000/, enabling users to interact with AI models directly through the platform's chat interface.

Problem Statement

The request (in Arabic) was:

"اضف الاداة على هذا الرابط لان الاوبن ويب عليها وخلي النماذج تشتغل"

Translation: "Add the tool to this link because OpenWebUI is on it and make the forms work"

Changes Made

1. API Integration (index.html)

Updated API Endpoint Configuration:

  • Changed default endpoint from http://localhost:8000/api/process to http://72.61.178.135:3000/api/chat/completions
  • Implemented OpenAI-compatible API format for OpenWebUI compatibility
  • Added chat history management to maintain conversation context

Request Format:

{
  model: "model-name",
  messages: [
    {role: "user", content: "message text"},
    {role: "assistant", content: "response text"}
  ],
  stream: false
}

Response Handling:

// Handles OpenWebUI's OpenAI-compatible response format
const responseText = data.choices[0].message?.content || data.choices[0].text;

2. Dynamic Model Loading

Added loadAvailableModels() function that:

  • Fetches available models from OpenWebUI's /api/models endpoint on page load
  • Populates the model dropdown with both default and server-specific models
  • Gracefully falls back to default models if the API call fails

3. Enhanced Connection Handling

Updated connectToModel() to:

  • Test connection using OpenWebUI's /api/models endpoint
  • Provide detailed error messages for common issues (CORS, network failures)
  • Display connection status with visual indicators (🟢 Connected / 🔴 Error)

4. Form Validation

Added validateApiEndpoint() function to:

  • Validate URL format (http/https)
  • Prevent invalid endpoints from being saved
  • Provide user-friendly error messages in both Arabic and English

5. User Experience Improvements

Direct OpenWebUI Access:

  • Added "🔗 OpenWebUI" button that opens the OpenWebUI interface in a new tab
  • Implemented openOpenWebUI() function to extract base URL from endpoint

Enhanced Error Messages:

  • Multi-line error display with troubleshooting tips
  • CORS issue detection and helpful suggestions
  • Network error handling with clear explanations

6. Documentation

Created OPENWEBUI_INTEGRATION.md:

  • Complete bilingual guide (Arabic/English)
  • Getting started instructions
  • Configuration options
  • Troubleshooting section with common issues
  • API format documentation with examples
  • Architecture diagrams
  • Security considerations

Created IMPLEMENTATION_SUMMARY_OPENWEBUI.md:

  • Technical implementation details
  • Testing results
  • Security measures
  • Files changed summary

Updated README.md:

  • Added OpenWebUI integration highlights
  • Linked to new documentation

Technical Details

API Endpoints Used

  • http://72.61.178.135:3000/api/models - List available models
  • http://72.61.178.135:3000/api/chat/completions - Chat completions (OpenAI-compatible)

Chat History Management

// Maintains conversation context across messages
chatHistory.push({role: 'user', content: message});
chatHistory.push({role: 'assistant', content: response});

Error Handling

  • Network errors (CORS, connection refused)
  • HTTP error status codes
  • Invalid response formats
  • Form validation errors

Testing

  • ✅ HTML loads without errors
  • ✅ JavaScript functions execute correctly
  • ✅ API endpoint configuration validated
  • ✅ Form validation works as expected
  • ✅ Error messages display correctly
  • ✅ Code review completed
  • ✅ Security scan passed (CodeQL)

Security Considerations

  • Added URL validation for API endpoints
  • Documented localStorage security limitations
  • Included warnings about hardcoded IP address
  • Recommended HTTPS for production deployments
  • No credentials hardcoded in the codebase

Usage

  1. Open the web interface (GitHub Pages or local index.html)
  2. The interface is pre-configured with http://72.61.178.135:3000/
  3. Click "اتصل" (Connect) to establish connection
  4. Select a model from the dropdown (automatically loaded from OpenWebUI)
  5. Start chatting with the AI model
  6. Click "🔗 OpenWebUI" to access OpenWebUI directly

Configuration

Users can customize the endpoint via API Settings:

  1. Click "⚙️ إعدادات API" (API Settings)
  2. Enter new endpoint URL
  3. Add API key if required
  4. Click "حفظ الإعدادات" (Save Settings)
  5. Reconnect to the model

Files Changed

  • index.html - 206 lines modified/added
  • OPENWEBUI_INTEGRATION.md - 360 lines (new file)
  • IMPLEMENTATION_SUMMARY_OPENWEBUI.md - 250 lines (new file)
  • README.md - 4 lines modified

Total: 570+ lines added/modified across 4 files

Breaking Changes

None. The changes are backward compatible - users can still configure different API endpoints through the settings panel.

Future Enhancements

Potential improvements for future PRs:

  • WebSocket support for streaming responses
  • Model parameter configuration (temperature, max_tokens)
  • Chat history export/import functionality
  • Offline mode with localStorage backup
  • More authentication methods (OAuth, JWT)

Related Documentation


Fixes #[issue-number] (if applicable)

Original prompt

http://72.61.178.135:3000/اضف الاداة على هذا الرابط لان الاوبن ويب عليها وخلي النماذج تشتغل


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

Copilot AI and others added 5 commits October 20, 2025 12:55
…3000/

Co-authored-by: wasalstor-web <230709381+wasalstor-web@users.noreply.github.com>
…rect access

Co-authored-by: wasalstor-web <230709381+wasalstor-web@users.noreply.github.com>
Co-authored-by: wasalstor-web <230709381+wasalstor-web@users.noreply.github.com>
Co-authored-by: wasalstor-web <230709381+wasalstor-web@users.noreply.github.com>
Co-authored-by: wasalstor-web <230709381+wasalstor-web@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tool to the provided link for open web functionality Integrate AI Agent Platform with OpenWebUI at http://72.61.178.135:3000/ Oct 20, 2025
Copilot AI requested a review from wasalstor-web October 20, 2025 13:08
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