Update links to /languages and add brief READMEs to all language directories

This commit is contained in:
Russell Ballestrini 2025-10-24 13:36:27 -04:00
parent 38545721a0
commit 845e747d1c
58 changed files with 800 additions and 1138 deletions

View file

@ -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
-----------------

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -71,7 +71,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>
@ -127,7 +127,7 @@
<h3>42 Programming Languages:</h3>
<p>We provide SDK implementations with streaming support for 42 programming languages! Browse all language examples:</p>
<p>🔗 <a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank"><strong>View All 42 Language Examples on Git</strong></a></p>
<p>🔗 <a href="/languages" target="_blank"><strong>Browse All 42 Language Examples</strong></a></p>
<p>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!</p>
<p><small>* Mojo implementation is non-streaming only (Lightbug HTTP library doesn't yet support SSE streaming as of 2025-10-15)</small></p>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html" class="active">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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<ModelInfo>`
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.

View file

@ -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<dyn std::error::Error>> {
// 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<uncloseaiConfig>) -> Result<uncloseai, uncloseaiError>`
Initialize the client.
**Parameters:**
- `config` - Optional configuration. If None, uses defaults and auto-discovers from environment
**Returns:**
- `Result<uncloseai, uncloseaiError>` - 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<ChatMessage>, options: Option<ChatOptions>) -> Result<ChatResponse, uncloseaiError>`
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<ChatResponse, uncloseaiError>` - 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<ChatMessage>, options: Option<ChatOptions>) -> Result<impl Stream<Item = Result<ChatChunk, uncloseaiError>>, uncloseaiError>`
Send a streaming chat completion request.
**Parameters:**
- Same as `chat()`
**Returns:**
- `Result<Stream<...>, 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<Vec<u8>, 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<Vec<u8>, 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<u32>` - Maximum tokens to generate
- `temperature: Option<f32>` - Sampling temperature (0.0 - 2.0)
- `top_p: Option<f32>` - 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<dyn std::error::Error>> {
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<dyn std::error::Error>> {
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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html" class="active">Swift Examples</a></li>
<li><a href="/uncloseai-js.html">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>

View file

@ -63,7 +63,7 @@
<li><a href="/swift-examples.html">Swift Examples</a></li>
<li><a href="/uncloseai-js.html" class="active">uncloseai.js Docs</a></li>
<li><a href="/inference.html">Inference Setup</a></li>
<li><a href="https://git.unturf.com/engineering/unturf/uncloseai.com/-/tree/master/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="/languages" target="_blank">🔗 All Languages</a></li>
<li><a href="https://shop.unturf.com/p/8486f492-a93e-11f0-b477-02dfe05770ee/uncloseai-machine-learning-reference-guide-to-inference-clients" target="_blank">📚 Book</a></li>
</ul>
</nav>