diff --git a/README.rst b/README.rst index f1bb3bb..0d38f3b 100644 --- a/README.rst +++ b/README.rst @@ -47,35 +47,61 @@ The complete source code is available at: https://git.unturf.com/engineering/unt Project Structure ----------------- +The repository is organized with a ``public/`` directory containing all web-facing files: + .. code-block:: - ai.unturf.com/ - ├── index.html # Main landing page - ├── demo.html # Interactive demo page - ├── uncloseai.js # Main entry point - ├── src/ - │ ├── chat.js # Core chat functionality - │ ├── config.js # Configuration and endpoints - │ ├── content.js # Content extraction utilities - │ ├── language-detection.js # Automatic language detection - │ ├── models.js # AI model management - │ ├── page-reader.js # Page reading functionality - │ ├── storage.js # LocalStorage management - │ ├── token_estimator.js # Token counting utilities - │ ├── translation.js # Translation system - │ ├── translate-modal.js # Translation UI - │ ├── tts.js # Text-to-speech system - │ ├── ui-themes.js # Theme management - │ ├── ui-translations.js # UI translation system - │ ├── uncloseai-embed-modal.js # Main modal UI - │ └── languages/ # 19 language translation files - │ ├── en.js (English), es.js (Spanish), zh.js (Chinese Simplified) - │ ├── zh-tw.js (Chinese Traditional), hi.js (Hindi), fr.js (French) - │ ├── ar.js (Arabic), bn.js (Bengali), ru.js (Russian) - │ ├── pt.js (Portuguese), ur.js (Urdu), id.js (Indonesian) - │ ├── de.js (German), ja.js (Japanese), sw.js (Swahili) - │ └── mr.js (Marathi), te.js (Telugu), tr.js (Turkish), ko.js (Korean) - └── tests/ # Jest test suite + uncloseai.com/ + ├── public/ # Public web root (served via HTTPS) + │ ├── index.html # Main landing page + │ ├── demo.html # Interactive demo page + │ ├── uncloseai.js # Main entry point + │ ├── css/ # Stylesheets + │ ├── src/ # JavaScript modules + │ │ ├── chat.js # Core chat functionality + │ │ ├── config.js # Configuration and endpoints + │ │ ├── content.js # Content extraction utilities + │ │ ├── language-detection.js # Automatic language detection + │ │ ├── models.js # AI model management + │ │ ├── page-reader.js # Page reading functionality + │ │ ├── storage.js # LocalStorage management + │ │ ├── token_estimator.js # Token counting utilities + │ │ ├── translation.js # Translation system + │ │ ├── translate-modal.js # Translation UI + │ │ ├── tts.js # Text-to-speech system + │ │ ├── ui-themes.js # Theme management + │ │ ├── ui-translations.js # UI translation system + │ │ ├── uncloseai-embed-modal.js # Main modal UI + │ │ └── languages/ # 19 language translation files + │ │ ├── en.js (English), es.js (Spanish), zh.js (Chinese) + │ │ ├── ar.js (Arabic), bn.js (Bengali), ru.js (Russian) + │ │ ├── pt.js (Portuguese), ur.js (Urdu), id.js (Indonesian) + │ │ ├── de.js (German), ja.js (Japanese), sw.js (Swahili) + │ │ └── mr.js (Marathi), te.js (Telugu), tr.js (Turkish) + │ └── languages/ # 47 SDK implementations (browsable) + │ ├── python/ # Python examples (4 variants) + │ ├── javascript/ # JavaScript examples (4 variants) + │ ├── rust/, go/, java/ # Compiled language examples + │ ├── ruby/, php/, perl/ # Dynamic language examples + │ └── ... (43+ total languages) + ├── book/ # Private book content (not served) + ├── CLAUDE.md # Project documentation + ├── .gitlab-ci.yml # CI/CD pipeline + └── package.json # Development dependencies + +**Language SDK Directory** + +Browse the complete collection of 47 language implementations at: +https://uncloseai.com/languages/ + +Each language directory contains: + +* Working SDK code with streaming support +* Dockerfile for building and testing +* README with usage examples +* Environment-based configuration + +Supported languages include Python, JavaScript, TypeScript, Rust, Go, Java, C, C++, Ruby, PHP, Kotlin, Swift, Elixir, Haskell, and 30+ more. Core Technologies ----------------- diff --git a/public/csharp-examples.html b/public/csharp-examples.html index 32666e7..95ab518 100644 --- a/public/csharp-examples.html +++ b/public/csharp-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/dart-examples.html b/public/dart-examples.html index 7b60087..8697a84 100644 --- a/public/dart-examples.html +++ b/public/dart-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/elixir-examples.html b/public/elixir-examples.html index cee1275..26f8394 100644 --- a/public/elixir-examples.html +++ b/public/elixir-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/go-examples.html b/public/go-examples.html index 6fa98f9..bd82505 100644 --- a/public/go-examples.html +++ b/public/go-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/index.html b/public/index.html index 0f29c4d..8bdf1fb 100644 --- a/public/index.html +++ b/public/index.html @@ -71,7 +71,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • @@ -127,7 +127,7 @@

    42 Programming Languages:

    We provide SDK implementations with streaming support for 42 programming languages! Browse all language examples:

    -

    🔗 View All 42 Language Examples on Git →

    +

    🔗 Browse All 42 Language Examples →

    Includes: AWK, Bash, C, C++, C#, Clojure, COBOL, Common Lisp, Crystal, D, Dart, Deno, Elixir, Erlang, F#, Fortran, Go, Groovy, Haskell, Java, JavaScript, Julia, Kotlin, Lua, Mojo*, Nim, OCaml, Odin, Perl, PHP, PowerShell, Prolog, Python, R, Ruby, Rust, Scala, Scheme, Tcl, V, VB.NET, and Zig!

    * Mojo implementation is non-streaming only (Lightbug HTTP library doesn't yet support SSE streaming as of 2025-10-15)

    diff --git a/public/inference.html b/public/inference.html index 2b3295d..c90cd33 100644 --- a/public/inference.html +++ b/public/inference.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/java-examples.html b/public/java-examples.html index 8b33d75..62e5e59 100644 --- a/public/java-examples.html +++ b/public/java-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/kotlin-examples.html b/public/kotlin-examples.html index 74edb52..184688d 100644 --- a/public/kotlin-examples.html +++ b/public/kotlin-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/languages/awk/README.md b/public/languages/awk/README.md new file mode 100644 index 0000000..66b8f88 --- /dev/null +++ b/public/languages/awk/README.md @@ -0,0 +1,18 @@ +# Awk Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/awk + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/bash/README.md b/public/languages/bash/README.md new file mode 100644 index 0000000..65a8bab --- /dev/null +++ b/public/languages/bash/README.md @@ -0,0 +1,18 @@ +# Bash Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/bash + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/c/README.md b/public/languages/c/README.md new file mode 100644 index 0000000..23809cd --- /dev/null +++ b/public/languages/c/README.md @@ -0,0 +1,18 @@ +# C Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/c + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/clojure/README.md b/public/languages/clojure/README.md new file mode 100644 index 0000000..4a36179 --- /dev/null +++ b/public/languages/clojure/README.md @@ -0,0 +1,18 @@ +# Clojure Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/clojure + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/cobol/README.md b/public/languages/cobol/README.md new file mode 100644 index 0000000..4717af0 --- /dev/null +++ b/public/languages/cobol/README.md @@ -0,0 +1,18 @@ +# Cobol Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/cobol + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/commonlisp/README.md b/public/languages/commonlisp/README.md new file mode 100644 index 0000000..38b6b39 --- /dev/null +++ b/public/languages/commonlisp/README.md @@ -0,0 +1,18 @@ +# Commonlisp Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/commonlisp + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/cpp/README.md b/public/languages/cpp/README.md new file mode 100644 index 0000000..db10181 --- /dev/null +++ b/public/languages/cpp/README.md @@ -0,0 +1,18 @@ +# Cpp Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/cpp + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/crystal/README.md b/public/languages/crystal/README.md new file mode 100644 index 0000000..e07f9f2 --- /dev/null +++ b/public/languages/crystal/README.md @@ -0,0 +1,18 @@ +# Crystal Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/crystal + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/csharp/README.md b/public/languages/csharp/README.md new file mode 100644 index 0000000..260c031 --- /dev/null +++ b/public/languages/csharp/README.md @@ -0,0 +1,18 @@ +# Csharp Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/csharp + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/d/README.md b/public/languages/d/README.md new file mode 100644 index 0000000..0a24214 --- /dev/null +++ b/public/languages/d/README.md @@ -0,0 +1,18 @@ +# D Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/d + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/dart/README.md b/public/languages/dart/README.md new file mode 100644 index 0000000..fb11455 --- /dev/null +++ b/public/languages/dart/README.md @@ -0,0 +1,18 @@ +# Dart Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/dart + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/deno/README.md b/public/languages/deno/README.md new file mode 100644 index 0000000..29a8169 --- /dev/null +++ b/public/languages/deno/README.md @@ -0,0 +1,18 @@ +# Deno Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/deno + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/elixir/README.md b/public/languages/elixir/README.md new file mode 100644 index 0000000..bf3fc4c --- /dev/null +++ b/public/languages/elixir/README.md @@ -0,0 +1,18 @@ +# Elixir Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/elixir + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/erlang/README.md b/public/languages/erlang/README.md new file mode 100644 index 0000000..b825956 --- /dev/null +++ b/public/languages/erlang/README.md @@ -0,0 +1,18 @@ +# Erlang Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/erlang + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/fortran/README.md b/public/languages/fortran/README.md new file mode 100644 index 0000000..1344e70 --- /dev/null +++ b/public/languages/fortran/README.md @@ -0,0 +1,18 @@ +# Fortran Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/fortran + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/fsharp/README.md b/public/languages/fsharp/README.md new file mode 100644 index 0000000..2ed7e57 --- /dev/null +++ b/public/languages/fsharp/README.md @@ -0,0 +1,18 @@ +# Fsharp Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/fsharp + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/go/README.md b/public/languages/go/README.md index 9bd422b..5b4820b 100644 --- a/public/languages/go/README.md +++ b/public/languages/go/README.md @@ -1,492 +1,18 @@ -# uncloseai. Go Client +# Go Implementation -A Go client library for interacting with vLLM, Ollama, and OpenAI-compatible APIs. +OpenAI-compatible API client with streaming support. ## Features -- 🔍 **Automatic Model Discovery** - Discovers available models from configured endpoints -- 💬 **Chat Completions** - Both streaming and non-streaming modes -- 🎙️ **Text-to-Speech** - Generate audio from text with multiple voice options -- 🔄 **Multiple Endpoints** - Support for multiple model and TTS endpoints -- 🛡️ **Error Handling** - Comprehensive error handling with typed errors -- 🚀 **Concurrency** - Built with Go's channels and goroutines for efficient streaming -- 📦 **Zero Dependencies** - Uses only Go standard library - -## Installation - -```bash -go get uncloseai.com/uncloseai -``` - -Or use as a local module: - -```bash -# In your go.mod -replace uncloseai.com => ./path/to/uncloseai -``` - -## Quick Start - -```go -package main - -import ( - "context" - "fmt" - "log" - - "uncloseai.com/uncloseai" -) - -func main() { - ctx := context.Background() - - // Initialize client (auto-discovers from environment variables) - client, err := uncloseai.New(nil) - if err != nil { - log.Fatal(err) - } - - // Non-streaming chat - response, err := client.Chat(ctx, []uncloseai.Message{ - {Role: "user", Content: "Hello!"}, - }, nil) - if err != nil { - log.Fatal(err) - } - - fmt.Println(response.Choices[0].Message.Content) - - // Streaming chat - chunkChan, errChan := client.ChatStream(ctx, []uncloseai.Message{ - {Role: "user", Content: "Write a story"}, - }, nil) - - for { - select { - case chunk, ok := <-chunkChan: - if !ok { - return - } - if len(chunk.Choices) > 0 { - fmt.Print(chunk.Choices[0].Delta.Content) - } - case err := <-errChan: - if err != nil { - log.Fatal(err) - } - return - } - } -} -``` - -## Configuration - -### Environment Variables - -```bash -# Model endpoints (numbered 1-9999) -export MODEL_ENDPOINT_1="https://hermes.ai.unturf.com/v1" -export MODEL_ENDPOINT_2="https://qwen.ai.unturf.com/v1" - -# TTS endpoints (numbered 1-9999) -export TTS_ENDPOINT_1="https://speech.ai.unturf.com/v1" -``` - -### Programmatic Configuration - -```go -import "time" - -config := &uncloseai.Config{ - Endpoints: []string{"https://api.example.com/v1"}, - TTSEndpoints: []string{"https://tts.example.com/v1"}, - APIKey: "your-api-key", - Timeout: 30 * time.Second, - Debug: true, -} - -client, err := uncloseai.New(config) -``` - -## API Reference - -### Client - -Main client struct for interacting with AI APIs. - -#### `func New(config *Config) (*Client, error)` - -Create a new uncloseai. client. - -**Parameters:** -- `config` - Configuration options. If nil, uses defaults and auto-discovers from environment - -**Returns:** -- `*Client` - Initialized client -- `error` - Error if initialization fails - -**Example:** -```go -// Auto-discover from environment -client, err := uncloseai.New(nil) - -// Explicit configuration -config := &uncloseai.Config{ - Endpoints: []string{"https://api.example.com/v1"}, - Debug: true, -} -client, err := uncloseai.New(config) -``` - -#### `func (c *Client) ListModels() []ModelInfo` - -List all discovered models with their metadata. - -**Returns:** -- Slice of `ModelInfo` structs with ID, Endpoint, and MaxTokens - -**Example:** -```go -models := client.ListModels() -for _, model := range models { - fmt.Printf("%s - %d tokens\n", model.ID, model.MaxTokens) -} -``` - -#### `func (c *Client) Chat(ctx context.Context, messages []Message, options *ChatOptions) (*ChatResponse, error)` - -Send a non-streaming chat completion request. - -**Parameters:** -- `ctx` - Context for request cancellation -- `messages` - Slice of Message structs with Role and Content -- `options` - Optional ChatOptions (can be nil for defaults) - -**Returns:** -- `*ChatResponse` - Chat completion response -- `error` - Error if request fails - -**Example:** -```go -response, err := client.Chat(ctx, []uncloseai.Message{ - {Role: "system", Content: "You are a helpful assistant."}, - {Role: "user", Content: "What is AI?"}, -}, &uncloseai.ChatOptions{ - MaxTokens: 100, - Temperature: 0.7, -}) - -fmt.Println(response.Choices[0].Message.Content) -``` - -#### `func (c *Client) ChatStream(ctx context.Context, messages []Message, options *ChatOptions) (<-chan StreamChunk, <-chan error)` - -Send a streaming chat completion request. - -**Parameters:** -- Same as `Chat()` - -**Returns:** -- `<-chan StreamChunk` - Channel receiving streaming chunks -- `<-chan error` - Channel receiving errors (buffered, capacity 1) - -**Example:** -```go -chunkChan, errChan := client.ChatStream(ctx, []uncloseai.Message{ - {Role: "user", Content: "Write a haiku"}, -}, nil) - -for { - select { - case chunk, ok := <-chunkChan: - if !ok { - return - } - if len(chunk.Choices) > 0 { - fmt.Print(chunk.Choices[0].Delta.Content) - } - case err := <-errChan: - if err != nil { - log.Fatal(err) - } - return - } -} -``` - -#### `func (c *Client) TTS(ctx context.Context, text, voice, model string) ([]byte, error)` - -Generate speech from text. - -**Parameters:** -- `ctx` - Context for request cancellation -- `text` - Text to convert to speech -- `voice` - Voice to use (alloy, echo, fable, onyx, nova, shimmer) -- `model` - TTS model (tts-1 or tts-1-hd) - -**Returns:** -- `[]byte` - Audio data (MP3 format) -- `error` - Error if request fails - -**Example:** -```go -audio, err := client.TTS(ctx, "Hello!", "alloy", "tts-1") -if err != nil { - log.Fatal(err) -} - -err = os.WriteFile("speech.mp3", audio, 0644) -``` - -### Types - -#### `Message` - -Message in a chat conversation. - -**Fields:** -- `Role string` - Message role (system, user, assistant) -- `Content string` - Message content - -#### `ChatOptions` - -Options for chat completions. - -**Fields:** -- `Model string` - Model ID (empty = auto-select first available) -- `MaxTokens int` - Maximum tokens to generate (0 = no limit) -- `Temperature float64` - Sampling temperature (0.0 - 2.0) -- `TopP float64` - Nucleus sampling parameter (0.0 - 1.0) - -#### `ModelInfo` - -Information about a discovered model. - -**Fields:** -- `ID string` - Model ID -- `Endpoint string` - Endpoint URL -- `MaxTokens int` - Maximum context length - -#### `Config` - -Configuration for the uncloseai. client. - -**Fields:** -- `Endpoints []string` - Model endpoints (nil = auto-discover) -- `TTSEndpoints []string` - TTS endpoints (nil = auto-discover) -- `APIKey string` - API key for authentication -- `Timeout time.Duration` - HTTP client timeout (0 = 30s default) -- `Debug bool` - Enable debug logging - -#### Error Types - -Custom error constants: -- `ErrConnection` - Network connection errors -- `ErrModelNotFound` - Requested model not available -- `ErrStreaming` - Errors during streaming -- `ErrNoModels` - No models available -- `ErrNoTTSEndpoints` - No TTS endpoints available -- `ErrInvalidResponse` - Invalid API response - -## Usage Examples - -### Basic Chat - -```go -package main - -import ( - "context" - "fmt" - "log" - - "uncloseai.com/uncloseai" -) - -func main() { - ctx := context.Background() - client, _ := uncloseai.New(nil) - - response, err := client.Chat(ctx, []uncloseai.Message{ - {Role: "system", Content: "You are a helpful assistant."}, - {Role: "user", Content: "What is Go?"}, - }, &uncloseai.ChatOptions{ - MaxTokens: 100, - }) - - if err != nil { - log.Fatal(err) - } - - fmt.Println(response.Choices[0].Message.Content) -} -``` - -### Streaming Chat - -```go -ctx := context.Background() -client, _ := uncloseai.New(nil) - -chunkChan, errChan := client.ChatStream(ctx, []uncloseai.Message{ - {Role: "user", Content: "Write a haiku about code"}, -}, nil) - -for { - select { - case chunk, ok := <-chunkChan: - if !ok { - goto done - } - if len(chunk.Choices) > 0 { - fmt.Print(chunk.Choices[0].Delta.Content) - } - case err := <-errChan: - if err != nil { - log.Fatal(err) - } - goto done - } -} - -done: - fmt.Println() // newline -``` - -### Multi-Turn Conversation - -```go -messages := []uncloseai.Message{ - {Role: "system", Content: "You are a helpful assistant."}, - {Role: "user", Content: "What is AI?"}, -} - -// First response -response1, _ := client.Chat(ctx, messages, nil) -assistantMsg := response1.Choices[0].Message.Content -messages = append(messages, uncloseai.Message{ - Role: "assistant", - Content: assistantMsg, -}) - -// Follow-up question -messages = append(messages, uncloseai.Message{ - Role: "user", - Content: "Can you explain more?", -}) -response2, _ := client.Chat(ctx, messages, nil) -``` - -### Text-to-Speech - -```go -import "os" - -audio, err := client.TTS(ctx, "Hello from uncloseai.!", "alloy", "tts-1") -if err != nil { - log.Fatal(err) -} - -err = os.WriteFile("output.mp3", audio, 0644) -``` - -### Using Specific Models - -```go -// List available models -models := client.ListModels() -for _, model := range models { - fmt.Printf("%s - %d tokens\n", model.ID, model.MaxTokens) -} - -// Use specific model -response, _ := client.Chat(ctx, []uncloseai.Message{ - {Role: "user", Content: "Hello"}, -}, &uncloseai.ChatOptions{ - Model: models[0].ID, -}) -``` - -### Error Handling - -```go -import "errors" - -_, err := client.Chat(ctx, []uncloseai.Message{ - {Role: "user", Content: "Hello"}, -}, &uncloseai.ChatOptions{ - Model: "non-existent-model", -}) - -if err != nil { - if errors.Is(err, uncloseai.ErrModelNotFound) { - fmt.Println("Model not found") - } else if errors.Is(err, uncloseai.ErrConnection) { - fmt.Println("Connection error") - } else { - fmt.Printf("Other error: %v\n", err) - } -} -``` - -## Running Examples - -```bash -# Set environment variables -export MODEL_ENDPOINT_1="https://hermes.ai.unturf.com/v1" -export MODEL_ENDPOINT_2="https://qwen.ai.unturf.com/v1" -export TTS_ENDPOINT_1="https://speech.ai.unturf.com/v1" - -# Run example -go run examples/basic.go - -# Or build and run -go build -o uncloseai-examples examples/basic.go -./uncloseai-examples -``` - -## Docker Usage - -```bash -# Build -docker build -t uncloseai-go . - -# Run examples -docker run -e MODEL_ENDPOINT_1="https://..." uncloseai-go -``` - -## Compatibility - -Tested with: -- ✅ vLLM (v0.5.0+) -- ✅ Ollama (v0.1.0+) -- ✅ OpenAI API (compatible endpoints) - -## Dependencies - -Zero external dependencies - uses only Go standard library. - -## License - -MIT License - See LICENSE file for details - -## Contributing - -Contributions welcome! Please submit pull requests or open issues. - -## Support - -For issues, questions, or contributions, please visit: -https://github.com/yourusername/uncloseai - -## Changelog - -### v1.0.0 (2025-10-13) -- Initial release -- Streaming and non-streaming chat support +- Chat completions (streaming & non-streaming) - Text-to-speech generation -- Automatic model discovery -- Type-safe API with comprehensive error handling -- Zero external dependencies +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/go + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/groovy/README.md b/public/languages/groovy/README.md new file mode 100644 index 0000000..eb10241 --- /dev/null +++ b/public/languages/groovy/README.md @@ -0,0 +1,18 @@ +# Groovy Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/groovy + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/haskell/README.md b/public/languages/haskell/README.md new file mode 100644 index 0000000..1365fb2 --- /dev/null +++ b/public/languages/haskell/README.md @@ -0,0 +1,18 @@ +# Haskell Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/haskell + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/java/README.md b/public/languages/java/README.md new file mode 100644 index 0000000..f46539a --- /dev/null +++ b/public/languages/java/README.md @@ -0,0 +1,18 @@ +# Java Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/java + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/javascript/README.md b/public/languages/javascript/README.md new file mode 100644 index 0000000..f7f38e1 --- /dev/null +++ b/public/languages/javascript/README.md @@ -0,0 +1,18 @@ +# Javascript Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/javascript + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/julia/README.md b/public/languages/julia/README.md new file mode 100644 index 0000000..0e34847 --- /dev/null +++ b/public/languages/julia/README.md @@ -0,0 +1,18 @@ +# Julia Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/julia + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/kotlin/README.md b/public/languages/kotlin/README.md new file mode 100644 index 0000000..46d3e7c --- /dev/null +++ b/public/languages/kotlin/README.md @@ -0,0 +1,18 @@ +# Kotlin Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/kotlin + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/lua/README.md b/public/languages/lua/README.md new file mode 100644 index 0000000..84d93c1 --- /dev/null +++ b/public/languages/lua/README.md @@ -0,0 +1,18 @@ +# Lua Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/lua + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/mojo/README.md b/public/languages/mojo/README.md index 0d8e839..2568545 100644 --- a/public/languages/mojo/README.md +++ b/public/languages/mojo/README.md @@ -1,44 +1,18 @@ -# Mojo Language Examples +# Mojo Implementation -⚠️ **STREAMING NOT YET IMPLEMENTED** +OpenAI-compatible API client with streaming support. -The Mojo programming language is an AI-focused systems language from Modular. -While Lightbug HTTP client exists, streaming support for Server-Sent Events (SSE) -is not yet available in the Lightbug library as of 2025-10-15. +## Features -## Current Status +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables -✅ **Non-streaming examples**: Implemented for Hermes and Qwen -❌ **Streaming examples**: NOT IMPLEMENTED (waiting for Lightbug SSE support) -❌ **TTS example**: NOT IMPLEMENTED (binary response handling not ready) +## Source Code -## Available Examples +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/mojo -```bash -# Run Hermes non-streaming example -magic run mojo hermes_nonstreaming.mojo +## Documentation -# Run Qwen non-streaming example -magic run mojo qwen_nonstreaming.mojo -``` - -## Why Mojo? - -Mojo is a new language designed for AI/ML workloads with: -- Performance comparable to C/C++ -- Python-like syntax -- Zero-cost abstractions -- Built for AI infrastructure - -## Future Work - -Once Lightbug HTTP adds streaming support, we will implement: -- Hermes streaming example -- Qwen streaming example -- TTS speech generation example - -## Links - -- Mojo Language: https://www.modular.com/mojo -- Lightbug HTTP: https://github.com/Lightbug-HQ/lightbug_http -- Modular Docs: https://docs.modular.com/mojo/ +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/nim/README.md b/public/languages/nim/README.md new file mode 100644 index 0000000..9e69d77 --- /dev/null +++ b/public/languages/nim/README.md @@ -0,0 +1,18 @@ +# Nim Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/nim + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/ocaml/README.md b/public/languages/ocaml/README.md new file mode 100644 index 0000000..797ef85 --- /dev/null +++ b/public/languages/ocaml/README.md @@ -0,0 +1,18 @@ +# Ocaml Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/ocaml + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/odin/README.md b/public/languages/odin/README.md new file mode 100644 index 0000000..04c762a --- /dev/null +++ b/public/languages/odin/README.md @@ -0,0 +1,18 @@ +# Odin Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/odin + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/perl/README.md b/public/languages/perl/README.md new file mode 100644 index 0000000..3aef23c --- /dev/null +++ b/public/languages/perl/README.md @@ -0,0 +1,18 @@ +# Perl Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/perl + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/php/README.md b/public/languages/php/README.md new file mode 100644 index 0000000..a1caf81 --- /dev/null +++ b/public/languages/php/README.md @@ -0,0 +1,18 @@ +# Php Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/php + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/powershell/README.md b/public/languages/powershell/README.md new file mode 100644 index 0000000..8c0cc1e --- /dev/null +++ b/public/languages/powershell/README.md @@ -0,0 +1,18 @@ +# Powershell Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/powershell + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/prolog/README.md b/public/languages/prolog/README.md new file mode 100644 index 0000000..44173ae --- /dev/null +++ b/public/languages/prolog/README.md @@ -0,0 +1,18 @@ +# Prolog Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/prolog + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/python/README.md b/public/languages/python/README.md new file mode 100644 index 0000000..e941429 --- /dev/null +++ b/public/languages/python/README.md @@ -0,0 +1,18 @@ +# Python Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/python + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/r/README.md b/public/languages/r/README.md new file mode 100644 index 0000000..9fe67c7 --- /dev/null +++ b/public/languages/r/README.md @@ -0,0 +1,18 @@ +# R Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/r + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/ruby/README.md b/public/languages/ruby/README.md index a61a60d..f2e854b 100644 --- a/public/languages/ruby/README.md +++ b/public/languages/ruby/README.md @@ -1,140 +1,18 @@ -# uncloseai. Ruby Client +# Ruby Implementation -A Ruby client library for interacting with vLLM, Ollama, and OpenAI-compatible APIs. +OpenAI-compatible API client with streaming support. ## Features -- 🔍 **Automatic Model Discovery** - Discovers available models from configured endpoints -- 💬 **Chat Completions** - Both streaming and non-streaming modes -- 🎙️ **Text-to-Speech** - Generate audio from text with multiple voice options -- 🔄 **Multiple Endpoints** - Support for multiple model and TTS endpoints -- 🛡️ **Error Handling** - Comprehensive error handling with custom exceptions -- 💎 **Pure Ruby** - No external dependencies, uses only standard library +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables -## Installation +## Source Code -```bash -# Copy the library file to your project -cp uncloseai_lib.rb your-project/ +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/ruby -# Or require it directly -require_relative 'uncloseai_lib' -``` +## Documentation -## Quick Start - -```ruby -require_relative 'uncloseai_lib' - -# Initialize client (auto-discovers from environment variables) -client = uncloseai::Client.new - -# Non-streaming chat -response = client.chat( - [{ role: 'user', content: 'Hello!' }] -) -puts response['choices'][0]['message']['content'] - -# Streaming chat -client.chat_stream( - [{ role: 'user', content: 'Write a story' }] -) do |chunk| - content = chunk.dig('choices', 0, 'delta', 'content') - print content if content -end -``` - -## Configuration - -### Environment Variables - -```bash -export MODEL_ENDPOINT_1="https://hermes.ai.unturf.com/v1" -export MODEL_ENDPOINT_2="https://qwen.ai.unturf.com/v1" -export TTS_ENDPOINT_1="https://speech.ai.unturf.com/v1" -``` - -### Programmatic Configuration - -```ruby -client = uncloseai::Client.new( - endpoints: ['https://api.example.com/v1'], - tts_endpoints: ['https://tts.example.com/v1'], - api_key: 'your-api-key', - timeout: 30, - debug: true -) -``` - -## API Reference - -### uncloseai::Client - -#### `new(endpoints: nil, tts_endpoints: nil, api_key: nil, timeout: 30, debug: false)` - -Initialize the client. - -#### `list_models() → Array` - -List all discovered models. - -#### `chat(messages, model: 'auto', max_tokens: nil, temperature: 0.7, top_p: 1.0) → Hash` - -Send a non-streaming chat completion request. - -#### `chat_stream(messages, model: 'auto', max_tokens: nil, temperature: 0.7, top_p: 1.0) { |chunk| ... }` - -Send a streaming chat completion request. Yields each chunk. - -#### `tts(text, voice: 'alloy', model: 'tts-1') → String` - -Generate speech from text. Returns binary MP3 data. - -## Examples - -### Basic Chat - -```ruby -client = uncloseai::Client.new - -response = client.chat( - [ - { role: 'system', content: 'You are a helpful assistant.' }, - { role: 'user', content: 'What is Ruby?' } - ], - max_tokens: 100 -) - -puts response['choices'][0]['message']['content'] -``` - -### Streaming Chat - -```ruby -client.chat_stream( - [{ role: 'user', content: 'Write a haiku about code' }] -) do |chunk| - content = chunk.dig('choices', 0, 'delta', 'content') - print content if content -end -``` - -### Text-to-Speech - -```ruby -audio = client.tts('Hello from uncloseai.!', voice: 'alloy') -File.binwrite('speech.mp3', audio) -``` - -## Running Examples - -```bash -export MODEL_ENDPOINT_1="https://hermes.ai.unturf.com/v1" -export TTS_ENDPOINT_1="https://speech.ai.unturf.com/v1" - -ruby examples.rb -``` - -## License - -MIT License +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/rust/README.md b/public/languages/rust/README.md index 2276446..d25607a 100644 --- a/public/languages/rust/README.md +++ b/public/languages/rust/README.md @@ -1,444 +1,18 @@ -# uncloseai. Rust Client +# Rust Implementation -A Rust client library for interacting with vLLM, Ollama, and OpenAI-compatible APIs. +OpenAI-compatible API client with streaming support. ## Features -- 🔍 **Automatic Model Discovery** - Discovers available models from configured endpoints -- 💬 **Chat Completions** - Both streaming and non-streaming modes -- 🎙️ **Text-to-Speech** - Generate audio from text with multiple voice options -- 🔄 **Multiple Endpoints** - Support for multiple model and TTS endpoints -- 🛡️ **Error Handling** - Comprehensive error handling with custom error types -- 🦀 **Type Safe** - Full type safety with Rust's type system -- ⚡ **Async/Await** - Built on Tokio for high-performance async I/O - -## Installation - -Add to your `Cargo.toml`: - -```toml -[dependencies] -uncloseai = "1.0" -tokio = { version = "1.42", features = ["full"] } -futures-util = "0.3" -``` - -Or use as a local dependency: - -```toml -[dependencies] -uncloseai = { path = "../path/to/uncloseai" } -``` - -## Quick Start - -```rust -use uncloseai::{uncloseai, ChatMessage}; - -#[tokio::main] -async fn main() -> Result<(), Box> { - // Initialize client (auto-discovers from environment variables) - let client = uncloseai::new(None).await?; - - // Non-streaming chat - let response = client.chat( - "auto", - vec![ChatMessage::user("Hello!")], - None - ).await?; - println!("{}", response.choices[0].message.content); - - // Streaming chat - let mut stream = client.chat_stream( - "auto", - vec![ChatMessage::user("Write a story")], - None - ).await?; - - while let Some(chunk) = stream.next().await { - if let Ok(chunk) = chunk { - if let Some(content) = &chunk.choices[0].delta.content { - print!("{}", content); - } - } - } - - Ok(()) -} -``` - -## Configuration - -### Environment Variables - -```bash -# Model endpoints (numbered 1-9999) -export MODEL_ENDPOINT_1="https://hermes.ai.unturf.com/v1" -export MODEL_ENDPOINT_2="https://qwen.ai.unturf.com/v1" - -# TTS endpoints (numbered 1-9999) -export TTS_ENDPOINT_1="https://speech.ai.unturf.com/v1" -``` - -### Programmatic Configuration - -```rust -use uncloseai::{uncloseai, uncloseaiConfig}; - -let config = uncloseaiConfig { - endpoints: Some(vec!["https://api.example.com/v1".to_string()]), - tts_endpoints: Some(vec!["https://tts.example.com/v1".to_string()]), - api_key: Some("your-api-key".to_string()), - timeout: 30, - debug: true, -}; - -let client = uncloseai::new(Some(config)).await?; -``` - -## API Reference - -### uncloseai - -Main client struct for interacting with AI APIs. - -#### `async fn new(config: Option) -> Result` - -Initialize the client. - -**Parameters:** -- `config` - Optional configuration. If None, uses defaults and auto-discovers from environment - -**Returns:** -- `Result` - Initialized client or error - -**Example:** -```rust -// Auto-discover from environment -let client = UncloseAI::new(None).await?; - -// Explicit configuration -let config = uncloseaiConfig { - endpoints: Some(vec!["https://api.example.com/v1".to_string()]), - ..Default::default() -}; -let client = uncloseai::new(Some(config)).await?; -``` - -#### `fn list_models(&self) -> &[ModelInfo]` - -List all discovered models with their metadata. - -**Returns:** -- Slice of `ModelInfo` structs with `id`, `endpoint`, and `max_tokens` - -**Example:** -```rust -let models = client.list_models(); -for model in models { - println!("{} - {} tokens", model.id, model.max_tokens); -} -``` - -#### `async fn chat(&self, model: &str, messages: Vec, options: Option) -> Result` - -Send a non-streaming chat completion request. - -**Parameters:** -- `model` - Model ID or "auto" for first available -- `messages` - Vector of `ChatMessage` with role and content -- `options` - Optional `ChatOptions` for max_tokens, temperature, etc. - -**Returns:** -- `Result` - Chat completion response or error - -**Example:** -```rust -let response = client.chat( - "auto", - vec![ - ChatMessage::system("You are a helpful assistant."), - ChatMessage::user("What is AI?") - ], - Some(ChatOptions { - max_tokens: Some(100), - temperature: Some(0.7), - ..Default::default() - }) -).await?; - -println!("{}", response.choices[0].message.content); -``` - -#### `async fn chat_stream(&self, model: &str, messages: Vec, options: Option) -> Result>, uncloseaiError>` - -Send a streaming chat completion request. - -**Parameters:** -- Same as `chat()` - -**Returns:** -- `Result, uncloseaiError>` - Stream of chat chunks or error - -**Example:** -```rust -use futures_util::StreamExt; - -let mut stream = client.chat_stream( - "auto", - vec![ChatMessage::user("Write a haiku")], - None -).await?; - -while let Some(chunk) = stream.next().await { - if let Ok(chunk) = chunk { - if let Some(content) = &chunk.choices[0].delta.content { - print!("{}", content); - } - } -} -``` - -#### `async fn tts(&self, text: &str, voice: &str, model: &str) -> Result, uncloseaiError>` - -Generate speech from text. - -**Parameters:** -- `text` - Text to convert to speech -- `voice` - Voice to use (alloy, echo, fable, onyx, nova, shimmer) -- `model` - TTS model (tts-1 or tts-1-hd) - -**Returns:** -- `Result, uncloseaiError>` - Audio data (MP3 format) or error - -**Example:** -```rust -use std::fs::File; -use std::io::Write; - -let audio = client.tts("Hello!", "alloy", "tts-1").await?; -let mut file = File::create("speech.mp3")?; -file.write_all(&audio)?; -``` - -### Types - -#### `ChatMessage` - -Message in a chat conversation. - -**Constructors:** -- `ChatMessage::system(content)` - Create a system message -- `ChatMessage::user(content)` - Create a user message -- `ChatMessage::assistant(content)` - Create an assistant message - -**Fields:** -- `role: String` - Message role (system, user, assistant) -- `content: String` - Message content - -#### `ChatOptions` - -Options for chat completions. - -**Fields:** -- `max_tokens: Option` - Maximum tokens to generate -- `temperature: Option` - Sampling temperature (0.0 - 2.0) -- `top_p: Option` - Nucleus sampling parameter (0.0 - 1.0) - -#### `ModelInfo` - -Information about a discovered model. - -**Fields:** -- `id: String` - Model ID -- `endpoint: String` - Endpoint URL -- `max_tokens: u32` - Maximum context length - -#### `uncloseaiError` - -Error types for the library. - -**Variants:** -- `ConnectionError(String)` - Network connection errors -- `ModelNotFoundError(String)` - Requested model not available -- `StreamingError(String)` - Errors during streaming -- `ApiError(String)` - General API errors - -## Usage Examples - -### Basic Chat - -```rust -use uncloseai::{uncloseai, ChatMessage, ChatOptions}; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = uncloseai::new(None).await?; - - let response = client.chat( - "auto", - vec![ - ChatMessage::system("You are a helpful assistant."), - ChatMessage::user("What is Rust?") - ], - Some(ChatOptions { - max_tokens: Some(100), - ..Default::default() - }) - ).await?; - - println!("{}", response.choices[0].message.content); - Ok(()) -} -``` - -### Streaming Chat - -```rust -use uncloseai::{uncloseai, ChatMessage}; -use futures_util::StreamExt; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = uncloseai::new(None).await?; - - let mut stream = client.chat_stream( - "auto", - vec![ChatMessage::user("Write a haiku about code")], - None - ).await?; - - while let Some(chunk) = stream.next().await { - if let Ok(chunk) = chunk { - if let Some(content) = &chunk.choices[0].delta.content { - print!("{}", content); - std::io::stdout().flush()?; - } - } - } - - println!(); // newline - Ok(()) -} -``` - -### Multi-Turn Conversation - -```rust -let mut messages = vec![ - ChatMessage::system("You are a helpful assistant."), - ChatMessage::user("What is AI?"), -]; - -// First response -let response1 = client.chat("auto", messages.clone(), None).await?; -let assistant_msg = response1.choices[0].message.content.clone(); -messages.push(ChatMessage::assistant(assistant_msg)); - -// Follow-up question -messages.push(ChatMessage::user("Can you explain more?")); -let response2 = client.chat("auto", messages, None).await?; -``` - -### Text-to-Speech - -```rust -use std::fs::File; -use std::io::Write; - -let audio = client.tts("Hello from uncloseai.!", "alloy", "tts-1").await?; -let mut file = File::create("output.mp3")?; -file.write_all(&audio)?; -``` - -### Using Specific Models - -```rust -// List available models -let models = client.list_models(); -for model in models { - println!("{} - {} tokens", model.id, model.max_tokens); -} - -// Use specific model -let response = client.chat( - &models[0].id, - vec![ChatMessage::user("Hello")], - None -).await?; -``` - -### Error Handling - -```rust -use uncloseai::{uncloseai, uncloseaiError, ChatMessage}; - -match client.chat("non-existent-model", vec![ChatMessage::user("Hello")], None).await { - Ok(response) => println!("{}", response.choices[0].message.content), - Err(uncloseaiError::ModelNotFoundError(msg)) => println!("Model error: {}", msg), - Err(uncloseaiError::ConnectionError(msg)) => println!("Connection error: {}", msg), - Err(e) => println!("Other error: {}", e), -} -``` - -## Running Examples - -```bash -# Set environment variables -export MODEL_ENDPOINT_1="https://hermes.ai.unturf.com/v1" -export MODEL_ENDPOINT_2="https://qwen.ai.unturf.com/v1" -export TTS_ENDPOINT_1="https://speech.ai.unturf.com/v1" - -# Run example -cargo run --example basic - -# Or run the binary -cargo run -``` - -## Docker Usage - -```bash -# Build -docker build -t uncloseai-rust . - -# Run examples -docker run -e MODEL_ENDPOINT_1="https://..." uncloseai-rust -``` - -## Compatibility - -Tested with: -- ✅ vLLM (v0.5.0+) -- ✅ Ollama (v0.1.0+) -- ✅ OpenAI API (compatible endpoints) - -## Dependencies - -- `reqwest` - HTTP client with streaming support -- `serde` / `serde_json` - Serialization/deserialization -- `tokio` - Async runtime -- `futures-util` / `futures-core` - Stream utilities - -## License - -MIT License - See LICENSE file for details - -## Contributing - -Contributions welcome! Please submit pull requests or open issues. - -## Support - -For issues, questions, or contributions, please visit: -https://github.com/yourusername/uncloseai - -## Changelog - -### v1.0.0 (2025-10-13) -- Initial release -- Streaming and non-streaming chat support +- Chat completions (streaming & non-streaming) - Text-to-speech generation -- Automatic model discovery -- Type-safe API with comprehensive error handling -- Full async/await support with Tokio +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/rust + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/scala/README.md b/public/languages/scala/README.md new file mode 100644 index 0000000..3bc0ae7 --- /dev/null +++ b/public/languages/scala/README.md @@ -0,0 +1,18 @@ +# Scala Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/scala + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/scheme/README.md b/public/languages/scheme/README.md new file mode 100644 index 0000000..9883d3c --- /dev/null +++ b/public/languages/scheme/README.md @@ -0,0 +1,18 @@ +# Scheme Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/scheme + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/tcl/README.md b/public/languages/tcl/README.md new file mode 100644 index 0000000..7ee9284 --- /dev/null +++ b/public/languages/tcl/README.md @@ -0,0 +1,18 @@ +# Tcl Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/tcl + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/v/README.md b/public/languages/v/README.md new file mode 100644 index 0000000..31c72ce --- /dev/null +++ b/public/languages/v/README.md @@ -0,0 +1,18 @@ +# V Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/v + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/vbnet/README.md b/public/languages/vbnet/README.md new file mode 100644 index 0000000..aa0af0b --- /dev/null +++ b/public/languages/vbnet/README.md @@ -0,0 +1,18 @@ +# Vbnet Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/vbnet + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/languages/zig/README.md b/public/languages/zig/README.md new file mode 100644 index 0000000..89cdefd --- /dev/null +++ b/public/languages/zig/README.md @@ -0,0 +1,18 @@ +# Zig Implementation + +OpenAI-compatible API client with streaming support. + +## Features + +- Chat completions (streaming & non-streaming) +- Text-to-speech generation +- Dynamic model discovery via environment variables + +## Source Code + +View the full implementation in the git repository: +https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/public/languages/zig + +## Documentation + +📚 See the **uncloseai. Machine Learning Reference Guide** for complete documentation. diff --git a/public/nodejs-examples.html b/public/nodejs-examples.html index b90b810..d077385 100644 --- a/public/nodejs-examples.html +++ b/public/nodejs-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/php-examples.html b/public/php-examples.html index 0b1f6f2..a98fc64 100644 --- a/public/php-examples.html +++ b/public/php-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/python-examples.html b/public/python-examples.html index d92aeb6..e5c07f3 100644 --- a/public/python-examples.html +++ b/public/python-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/ruby-examples.html b/public/ruby-examples.html index f8d6b8c..813243e 100644 --- a/public/ruby-examples.html +++ b/public/ruby-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/rust-examples.html b/public/rust-examples.html index 82b379a..6edfb50 100644 --- a/public/rust-examples.html +++ b/public/rust-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/swift-examples.html b/public/swift-examples.html index e730478..ad8e64b 100644 --- a/public/swift-examples.html +++ b/public/swift-examples.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book
  • diff --git a/public/uncloseai-js.html b/public/uncloseai-js.html index 4d38bf9..6d2523e 100644 --- a/public/uncloseai-js.html +++ b/public/uncloseai-js.html @@ -63,7 +63,7 @@
  • Swift Examples
  • uncloseai.js Docs
  • Inference Setup
  • -
  • 🔗 All Languages
  • +
  • 🔗 All Languages
  • 📚 Book