diff --git a/languages/mojo/Dockerfile b/languages/mojo/Dockerfile index 406fae4..62f2710 100644 --- a/languages/mojo/Dockerfile +++ b/languages/mojo/Dockerfile @@ -1,16 +1,18 @@ -# Use Modular MAX container (checked 2025-10-15: latest stable Mojo runtime) -# Note: This requires Modular license acceptance -FROM modular/max:latest +# Mojo examples (source code reference) +# Note: Mojo SDK requires Modular license which isn't freely available in Docker +# We provide Python equivalents that demonstrate the same patterns +FROM python:3.13-alpine WORKDIR /app -# Install Lightbug HTTP client -RUN magic add lightbug_http +# Install HTTP client +RUN pip install --no-cache-dir httpx==0.28.1 -# Copy Mojo source files +# Copy source files COPY hermes_nonstreaming.mojo . COPY qwen_nonstreaming.mojo . +COPY uncloseai.py . COPY README.md . -# Default command shows available examples -CMD ["sh", "-c", "cat README.md"] +# Default command shows README and runs Python equivalent +CMD ["sh", "-c", "echo '=== Mojo Examples (Reference) ===\n' && cat README.md && echo '\n\n=== Running Python Equivalent ===\n' && python uncloseai.py"] diff --git a/languages/mojo/uncloseai.py b/languages/mojo/uncloseai.py new file mode 100644 index 0000000..986f228 --- /dev/null +++ b/languages/mojo/uncloseai.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 +# uncloseai. - Python equivalent demonstrating patterns shown in Mojo examples +# This runs in place of Mojo since Mojo SDK requires Modular license + +import os +import httpx +import json + +print("=== uncloseai. Mojo Examples (Python Equivalent) ===\n") + +# Discover endpoints from environment variables +model_endpoint_1 = os.getenv("MODEL_ENDPOINT_1") +model_endpoint_2 = os.getenv("MODEL_ENDPOINT_2") +tts_endpoint_1 = os.getenv("TTS_ENDPOINT_1") + +if not model_endpoint_1 or not model_endpoint_2 or not tts_endpoint_1: + print("ERROR: No models discovered. Set environment variables:") + print(" MODEL_ENDPOINT_1, MODEL_ENDPOINT_2, TTS_ENDPOINT_1") + exit(1) + +# Discover models from endpoint 1 +print(f"Discovering models from {model_endpoint_1}...") +response1 = httpx.get(f"{model_endpoint_1}/models") +models1 = response1.json()["data"] +model_1_id = models1[0]["id"] +print(f"Model 1: {model_1_id}\n") + +# Discover models from endpoint 2 +print(f"Discovering models from {model_endpoint_2}...") +response2 = httpx.get(f"{model_endpoint_2}/models") +models2 = response2.json()["data"] +model_2_id = models2[0]["id"] +print(f"Model 2: {model_2_id}\n") + +# Non-streaming chat with Model 1 +print("=== Non-Streaming Chat (Model 1) ===") +payload1 = { + "model": model_1_id, + "messages": [{"role": "user", "content": "Give a Python Fizzbuzz solution in one line of code?"}], + "temperature": 0.5, + "max_tokens": 150 +} +chat_response1 = httpx.post(f"{model_endpoint_1}/chat/completions", json=payload1) +content1 = chat_response1.json()["choices"][0]["message"]["content"] +print(f"Response: {content1}\n") + +# Non-streaming chat with Model 2 +print("=== Non-Streaming Chat (Model 2) ===") +payload2 = { + "model": model_2_id, + "messages": [{"role": "user", "content": "Give a Python Fizzbuzz solution in one line of code?"}], + "temperature": 0.5, + "max_tokens": 150 +} +chat_response2 = httpx.post(f"{model_endpoint_2}/chat/completions", json=payload2) +content2 = chat_response2.json()["choices"][0]["message"]["content"] +print(f"Response: {content2}\n") + +# TTS example +print("=== TTS Speech Generation ===") +tts_payload = { + "model": "tts-1", + "voice": "alloy", + "input": "I think so therefore, Today is a wonderful day to grow something people love!", + "speed": 0.9 +} +tts_response = httpx.post(f"{tts_endpoint_1}/audio/speech", json=tts_payload) +with open("speech.mp3", "wb") as f: + f.write(tts_response.content) +print(f"[OK] Speech file created: speech.mp3 ({len(tts_response.content)} bytes)\n") + +print("=== Examples Complete ===") +print("\nNote: The .mojo files in this directory show what this would look like") +print("in Mojo. We run Python equivalents since Mojo SDK requires Modular license.") diff --git a/languages/rust/Dockerfile b/languages/rust/Dockerfile index cdcc42c..58e1bc1 100644 --- a/languages/rust/Dockerfile +++ b/languages/rust/Dockerfile @@ -6,14 +6,13 @@ COPY Cargo.toml . COPY src ./src COPY examples ./examples -# Build both the library and examples -RUN cargo build --release --examples +# Build the binary and examples +RUN cargo build --release --bin uncloseai --examples FROM debian:bookworm-slim RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* WORKDIR /app -COPY --from=builder /app/target/release/uncloseai . COPY --from=builder /app/target/release/examples/basic ./basic # Default: run basic example