Skip to content

ultralytics/llm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

49 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Ultralytics logo

๐Ÿš€ Ultralytics LLM

Ultralytics LLM provides a lightweight, production-ready JavaScript chat client for integrating AI-powered conversations into web applications. Built for jsDelivr CDN delivery with zero dependencies.

CI Ultralytics Actions codecov Vercel Deploy jsDelivr hits

Ultralytics Discord Ultralytics Forums Ultralytics Reddit

Ultralytics Chat Window

๐ŸŽฏ Current Status

โš ๏ธ Experimental Development: The chat widget ships as a CDN-ready chat.min.js bundle and as part of the ultralytics-llm Python package published on PyPI. Track tagged releases for production deployments and reserve @main for testing nightly changes.

Ecosystem: This repo hosts both the in-browser chat widget and the Python scaffolding we use for backend workflows. The widget is production ready, while the Python client remains a lightweight placeholder until the managed API is released.

๐Ÿ“ฆ Installation

JavaScript (Browser)

Load the chat widget via jsDelivr CDN:

<!-- Latest stable release (recommended for production) -->
<script src="https://cdn.jsdelivr.net/gh/ultralytics/llm@latest/js/chat.min.js"></script>

<!-- Specific version (guaranteed stability) -->
<script src="https://cdn.jsdelivr.net/gh/ultralytics/[email protected]/js/chat.min.js"></script>

<!-- Main branch (experimental, for testing) -->
<script src="https://cdn.jsdelivr.net/gh/ultralytics/llm@main/js/chat.min.js"></script>

CDN Links:

  • ๐Ÿ” Browse files: jsdelivr.com/package/gh/ultralytics/llm
  • ๐Ÿ“Š View stats: Check download counts and version usage
  • ๐Ÿท๏ธ Latest release: https://cdn.jsdelivr.net/gh/ultralytics/llm@latest/js/chat.min.js
  • ๐Ÿ”ฌ Main branch: https://cdn.jsdelivr.net/gh/ultralytics/llm@main/js/chat.min.js

Versioning Strategy:

  • @latest - Always points to the newest tagged release (cache purged on new releases)
  • @v0.0.1 - Specific version tags (permanent cache, high reliability)
  • @main - Latest development code (12-hour cache, auto-purged on push)

Note: For production, use @latest or pin to a specific version tag. The @main branch is for testing and may contain breaking changes.

๐ŸŽฏ Quick Start

Ultralytics Chat Pill

JavaScript Chat Widget

<!DOCTYPE html>
<html>
  <head>
    <title>Ultralytics Chat</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
  </head>
  <body>
    <script src="https://cdn.jsdelivr.net/gh/ultralytics/llm@latest/js/chat.min.js"></script>
    <script>
      const chat = new UltralyticsChat({
        apiUrl: "https://your-api-endpoint.com/api/chat",
        branding: {
          name: "My AI Assistant",
          tagline: "Ask me anything!",
          pillText: "Chat with AI",
        },
        theme: {
          primary: "#042AFF",
          yellow: "#E1FF25",
        },
      });
    </script>
  </body>
</html>

๐ŸŽจ JavaScript Chat Features

  • ๐ŸŽฏ Zero Dependencies: Standalone vanilla JavaScript (~1000 lines), no frameworks required
  • ๐Ÿ“ฑ Mobile Optimized: Full iOS & Android support with orientation handling, safe area insets, and back button integration
  • ๐ŸŒ— Dark Mode: Automatic theme switching based on system preferences
  • ๐Ÿ’ป Responsive: Desktop modal and mobile full-screen layouts (WebKit, Blink, Gecko)
  • โšก Streaming: Real-time SSE response streaming with abort support
  • ๐Ÿ” Search Mode: Built-in documentation search capability
  • ๐Ÿ’พ Session Management: Persistent conversation history via localStorage
  • โ™ฟ Accessible: WCAG compliant with ARIA labels and keyboard navigation
  • ๐ŸŽจ Customizable: Full theme and branding control
  • ๐Ÿ”’ Security: XSS protection with HTML escaping, input length limits

โš™๏ธ Configuration Options

JavaScript Widget

const chat = new UltralyticsChat({
  // API Configuration
  apiUrl: "/api/chat", // Chat endpoint that streams SSE
  maxMessageLength: 10000, // Character limit enforced per user message

  // Branding
  branding: {
    name: "AI Assistant", // Assistant name
    tagline: "How can I help?", // Tagline text
    logo: "https://...", // Header logo URL
    logomark: "https://...", // Pill button logo URL
    logoUrl: "https://example.com", // Link when header logo is clicked
    pillText: "Ask AI", // Pill button text
  },

  // Theme Colors
  theme: {
    primary: "#042AFF", // Primary brand color
    dark: "#111F68", // Dark theme accent
    accent: "#E1FF25", // Highlight color (falls back to theme.yellow)
    text: "#0b0b0f", // Text color
  },

  // Welcome Message
  welcome: {
    title: "Hi!",
    message: "How can I help you today?",
    chatExamples: ["What is YOLO11?", "How do I train a model?"],
    searchExamples: ["YOLO quickstart", "model training parameters"],
  },

  // UI Text
  ui: {
    placeholder: "Ask anythingโ€ฆ",
    copyText: "Copy thread",
    downloadText: "Download thread",
    clearText: "New chat",
  },
});

UltralyticsChat automatically injects document context (title, URL, description, path) into each request so your backend can provide page-aware responses without extra work on the integrator side.

API Requirements

Your backend should implement:

POST /api/chat
Content-Type: application/json

{
  "messages": [{"role": "user", "content": "Hello"}],
  "session_id": "optional-session-id",
  "context": {
    "url": "https://example.com/docs/widget",
    "title": "Docs page title",
    "description": "Meta description text",
    "path": "/docs/widget"
  },
  "edit_index": 3 // optional when user edits a previous turn
}

Response: Server-Sent Events (SSE)
data: {"content": "Hello! "}
data: {"content": "How can "}
data: {"content": "I help?"}
data: [DONE]

Headers:
X-Session-ID: session-uuid (for persistence)
Content-Type: text/event-stream

When the widget is switched to Search mode it will call the same base URL with /search replacing /chat via POST /api/search and expects a JSON body { "results": [{ title, url, text, score }] }.

๐Ÿ“ฑ Mobile Support

iOS (Safari, Chrome, Firefox)

  • โœ… Safe area insets for notched devices
  • โœ… Keyboard handling with auto-resize
  • โœ… Home indicator padding
  • โœ… Smooth scrolling optimization

Android (Chrome, Samsung Internet, Firefox)

  • โœ… Back button integration (History API)
  • โœ… Dynamic viewport height (address bar handling)
  • โœ… Touch action optimization
  • โœ… Gesture navigation support
  • โœ… Split-screen and multi-window modes

Cross-Platform

  • โœ… Portrait/landscape orientation changes
  • โœ… Full-screen mobile modal (no horizontal scroll)
  • โœ… Background scroll lock when open
  • โœ… Keyboard shortcuts (desktop: Cmd/Ctrl+K, ESC)

๐Ÿ”ง Development

Build Minified Version

npm install -g terser
terser js/chat.js -o js/chat.min.js -c -m

Local Testing

# Serve examples locally
python -m http.server 8000
# Open http://localhost:8000/examples/js/chat.html

Browser Compatibility

Tested and working on:

  • โœ… Chrome/Edge 90+ (Blink)
  • โœ… Safari 14+ (WebKit)
  • โœ… Firefox 88+ (Gecko)
  • โœ… Mobile Safari (iOS 12+)
  • โœ… Chrome Mobile (Android 8+)
  • โœ… Samsung Internet (Android 8+)

๐ŸŒŸ Roadmap

JavaScript Client (Current Focus)

  • Chat widget with streaming
  • Dark mode support
  • Search mode
  • Session persistence
  • Production-ready security & performance
  • Full mobile support (iOS & Android)
  • File upload support
  • Voice input
  • Multi-language support
  • Official v1.0.0 release

Python Backend (Coming Soon)

We plan to open-source our Python components once mature:

  • LLMClient class for Claude/OpenAI/etc.
  • FastAPI server implementation
  • Async streaming support
  • Tool/function calling
  • RAG integration with vector databases
  • Session management utilities
  • Rate limiting & caching

๐Ÿ“– Documentation

  • API reference for the widget and backend contracts: docs/API.md
  • Product announcements and tutorials: docs.ultralytics.com (LLM section rolling out alongside SDK updates)

๐Ÿ’ก Contribute

Ultralytics thrives on community collaboration! While this repo is currently experimental, we welcome:

A heartfelt thank you ๐Ÿ™ to all our contributors!

Ultralytics open-source contributors

๐Ÿ“„ License

Ultralytics offers two licensing options:

  • AGPL-3.0 License: Ideal for students, researchers, and enthusiasts passionate about open collaboration. This OSI-approved open-source license promotes transparency and community involvement. See the LICENSE file for details.
  • Enterprise License: For commercial applications, this license permits seamless integration of Ultralytics software into commercial products, bypassing AGPL-3.0 copyleft requirements. Inquire about an Ultralytics Enterprise License.

๐Ÿ“ฎ Contact

For bug reports or feature suggestions related to this repo or other Ultralytics projects, please use GitHub Issues. For general questions, discussions, and community support, join our Discord server!


Ultralytics GitHub space Ultralytics LinkedIn space Ultralytics Twitter space Ultralytics YouTube space Ultralytics TikTok space Ultralytics BiliBili space Ultralytics Discord