Skip to content

JealousyM/ngx-open-web-ui-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

26 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

OpenWebUI TypeScript Embedded SDK

License

Modern Angular 20 library for embedding OpenWebUI chat in your applications with full conversation history, markdown support, and Angular 2025 architecture.

๐ŸŒ Live Demo

Try the live demo โ†’

Interactive demo showcasing all features:

  • Dynamic configuration
  • Model selection
  • Real-time chat with conversation history
  • Markdown rendering
  • Multi-language support

โœจ Features

  • ๐Ÿš€ Angular 2025 Ready - Zoneless, Signals, Modern file structure
  • ๐Ÿ’ฌ Conversation History - AI remembers all previous messages
  • ๐Ÿ“ Markdown Support - Rich text rendering with ngx-markdown
  • โšก Signals & Zoneless - Latest Angular reactive patterns
  • ๐Ÿ“ก Streaming Responses - Real-time chat with typing indicator
  • โน๏ธ Stop Generation - Cancel AI response at any time
  • ๐ŸŽค Voice Input - Record audio messages with automatic transcription
  • ๐ŸŒ Multi-language - 10 languages supported
  • ๐ŸŽจ Customizable - SCSS with modern features
  • ๐Ÿ”ง TypeScript - Full type safety
  • ๐Ÿ“ฑ Responsive - Mobile-friendly design
  • โญ Response Actions - Continue, regenerate, and rate responses
  • ๐Ÿ‘ Rating System - Comprehensive feedback with good/bad ratings
  • ๐Ÿ“ค Chat Export - Download conversations as PDF, TXT, or JSON
  • ๐Ÿ›ก๏ธ Safe Deletion - Prevents accidental deletion of active chats
  • ๐Ÿ’ฌ Ask & Explain - Context menu for selected text with AI explanations
  • ๐Ÿ“‚ Folder Support - Organize chats into folders with drag & drop
  • ๐Ÿ“ Notes Support - Integrated markdown note editor with sidebar
  • ๐Ÿ—ƒ๏ธ Archived Chats - View, search, unarchive, and delete archived conversations
  • ๐Ÿ”Œ Integrations - Toggle Web Search and Code Interpreter capabilities

๐Ÿš€ Quick Start

Installation

npm install ngx-open-web-ui-chat

Setup

1. Configure Bootstrap (main.ts)

import { bootstrapApplication } from '@angular/platform-browser';
import { provideZonelessChangeDetection } from '@angular/core';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { provideMarkdown } from 'ngx-markdown';
import { AppComponent } from './app/app.component';

bootstrapApplication(AppComponent, {
  providers: [
    provideZonelessChangeDetection(),  // Zoneless mode!
    provideHttpClient(withInterceptorsFromDi()),
    provideMarkdown()  // For markdown rendering
  ]
}).catch((err) => console.error(err));

2. Use Component

import { Component } from '@angular/core';
import { OpenwebuiChatComponent } from 'ngx-open-web-ui-chat';

@Component({
  standalone: true,
  imports: [OpenwebuiChatComponent],
  template: `
    <openwebui-chat
      [endpoint]="'https://your-openwebui-instance.com'"
      [modelId]="'llama3'"
      [apiKey]="'sk-your-api-key'">
    </openwebui-chat>
  `
})
export class AppComponent {}

๐Ÿ“– Key Concepts

Conversation History

The component automatically maintains conversation context:

[
  {"role": "user", "content": "Hello"},
  {"role": "assistant", "content": "Hi! How can I help?"},
  {"role": "user", "content": "What did I just say?"},
  {"role": "assistant", "content": "You said 'Hello'"}
]

Features:

  • โœ… Full conversation history sent with each request
  • โœ… AI remembers all previous messages
  • โœ… Context-aware responses

Angular 2025 Architecture

Zoneless Change Detection:

provideZonelessChangeDetection()  // No ZoneJS!

Signals for State:

messages = signal<ChatMessage[]>([]);
isLoading = signal(false);

Modern File Structure:

components/
โ”œโ”€โ”€ openwebui-chat.ts       โ† Logic
โ”œโ”€โ”€ openwebui-chat.html     โ† Template
โ””โ”€โ”€ openwebui-chat.scss     โ† Styles (SCSS!)

๐Ÿ“ Project Structure

openwebui-ts-embedded-sdk/
โ”œโ”€โ”€ projects/
โ”‚   โ””โ”€โ”€ ngx-open-web-ui-chat/    # Library package
โ”‚       โ”œโ”€โ”€ src/lib/
โ”‚       โ”‚   โ”œโ”€โ”€ components/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ openwebui-chat.ts
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ openwebui-chat.html
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ openwebui-chat.scss
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ chat-input/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ chat-message/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ chat-history-sidebar/
โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ sidebar/
โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ list/
โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ item/
โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ header/
โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ context-menu/
โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ folder-list/
โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ folder-item/
โ”‚       โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ folder-context-menu/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ archived-chats-modal/       โ† Archived chats modal
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ note-editor/            โ† Note editor component
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ notes-sidebar/          โ† Notes sidebar component
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ chat-search-modal/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ confirm-dialog/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ error-banner/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ export-format-menu/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ message-actions/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ rating-form/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ regenerate-menu/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ text-selection-menu/
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ ask-explain-modal/
โ”‚       โ”‚   โ”œโ”€โ”€ services/
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ openwebui-api.ts
โ”‚       โ”‚   โ”œโ”€โ”€ models/
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ chat.model.ts
โ”‚       โ”‚   โ”œโ”€โ”€ utils/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ audio-recorder.ts
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ date-formatter.ts
โ”‚       โ”‚   โ””โ”€โ”€ i18n/
โ”‚       โ”‚       โ””โ”€โ”€ translations.ts
โ”‚       โ””โ”€โ”€ dist/                 # Built package
โ”œโ”€โ”€ test-app/                     # Test application
โ”‚   โ”œโ”€โ”€ src/app/
โ”‚   โ”‚   โ”œโ”€โ”€ app.component.ts
โ”‚   โ”‚   โ”œโ”€โ”€ app.component.html
โ”‚   โ”‚   โ””โ”€โ”€ app.component.scss
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ docs/                         # Documentation
โ”‚   โ”œโ”€โ”€ API.md
โ”‚   โ”œโ”€โ”€ I18N.md
โ”‚   โ”œโ”€โ”€ MARKDOWN.md
โ”‚   โ””โ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ README.md                     # This file
โ””โ”€โ”€ package.json

๐ŸŽฏ API Reference

Inputs

Input Type Required Default Description
endpoint string โœ… - OpenWebUI instance URL
modelId string โœ… - AI model identifier
apiKey string โœ… - API key
enableMarkdown boolean โŒ true Enable markdown
debug boolean โŒ false Debug logging
language string โŒ 'en' UI language
history boolean โŒ false Enable chat history sidebar
folders boolean โŒ false Enable folder support
notes boolean โŒ false Enable notes feature
integrations boolean โŒ false Enable integrations support

Outputs

Output Type Description
chatInitialized EventEmitter<void> Chat session ready
messagesChanged EventEmitter<number> Message count changed

Methods

Method Description
sendMessage(message: string) Send a message programmatically
stopGeneration() Stop current AI response generation
clearChat() Clear all messages
createNewChat() Create new chat session
changeModel(modelId: string) Switch to different model

Full API Documentation โ†’

๐Ÿ› ๏ธ Development

Build Library

cd projects/ngx-open-web-ui-chat
npm run build

Output: projects/ngx-open-web-ui-chat/dist/

Test Application

cd test-app
npm start

Visit: http://localhost:4200

Features:

  • Dynamic host & API key configuration
  • Model selection
  • Progressive connection flow
  • Chat controls (clear, disconnect, language)
  • Beautiful UI with step-by-step guide

๐Ÿ“š Documentation

Document Description
API Reference Complete API documentation
Markdown Guide Markdown features & examples
I18N Guide Multi-language support

๐Ÿ”ง Technology Stack

  • Angular 20.x - Latest framework with signals
  • TypeScript 5.8 - Full type safety
  • ng-packagr - Library packaging
  • ngx-markdown - Markdown rendering
  • RxJS - Only for streaming (Angular 2025 pattern)
  • SCSS - Modern styling with nesting

๐Ÿ—๏ธ Angular 2025 Features

โœ… Zoneless Change Detection - No ZoneJS overhead
โœ… Signals - Reactive state management
โœ… Standalone Components - No NgModules
โœ… Modern File Structure - Separated TS/HTML/SCSS
โœ… inject() DI - Modern dependency injection
โœ… Async/Await - Instead of Observable where appropriate
โœ… Computed Properties - Derived state

๐ŸŽจ Examples

Basic Usage

<openwebui-chat
  [endpoint]="'https://ai.example.com'"
  [modelId]="'llama3'"
  [apiKey]="'sk-abc123'">
</openwebui-chat>

With Controls

import { Component, ViewChild } from '@angular/core';
import { OpenwebuiChatComponent } from 'ngx-open-web-ui-chat';

@Component({
  template: `
    <button (click)="clearChat()">Clear</button>
    <button (click)="sendGreeting()">Say Hi</button>
    
    <openwebui-chat
      #chat
      [endpoint]="endpoint"
      [modelId]="modelId"
      [apiKey]="apiKey"
      (messagesChanged)="onMessageCount($event)">
    </openwebui-chat>
    
    <p>Messages: {{ messageCount }}</p>
  `
})
export class AppComponent {
  @ViewChild('chat') chat?: OpenwebuiChatComponent;
  messageCount = 0;
  
  clearChat() {
    this.chat?.clearChat();
  }
  
  sendGreeting() {
    this.chat?.sendMessage('Hello!');
  }
  
  onMessageCount(count: number) {
    this.messageCount = count;
  }
}

Multi-language

<openwebui-chat
  [endpoint]="endpoint"
  [modelId]="modelId"
  [apiKey]="apiKey"
  [language]="'en'">
</openwebui-chat>

Supported languages: en, zh, hi, es, ar, fr, pt, ru, bn, ja

๐Ÿš€ Publishing

# 1. Build
cd projects/ngx-open-web-ui-chat
npm run build

# 2. Publish
cd dist
npm publish --access public

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make changes
  4. Test thoroughly
  5. Submit pull request

๐Ÿ“ License

MIT License - see LICENSE file for details

๐ŸŽ“ Best Practices Implemented

  • โœ… Angular 2025 Architecture - Zoneless, signals, modern patterns
  • โœ… Separation of Concerns - TS/HTML/SCSS files
  • โœ… Type Safety - Full TypeScript strict mode
  • โœ… SCSS Features - Nesting, variables, modern CSS
  • โœ… Conversation Context - Full history maintained
  • โœ… Event-Driven - Reactive communication
  • โœ… Responsive Design - Mobile-friendly
  • โœ… Clean Code - Following Angular style guide

๐Ÿ”ฎ Roadmap

Features

  • Click microphone button to start recording
  • Real-time spectrogram visualization
  • Automatic transcription via OpenWebUI API
  • Editable transcribed text
  • Error handling with retry mechanism

Requirements

  • Modern browser with Web Audio API
  • Microphone permission
  • HTTPS connection (browser security requirement)

Status: Production-ready v1.0.14 Angular Version: 20.x
Node Required: >=20.19.0

Made with โค๏ธ using Angular 2025 architecture

About

Angular component library for embedding OpenWebUI chat in applications

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published