add Python example with openai==2.3.0 (latest) and dependency pinning standards to CLAUDE.md

This commit is contained in:
Russell Ballestrini 2025-10-12 15:10:07 -04:00
parent 973c045af6
commit 39502bcac3
7 changed files with 320 additions and 0 deletions

View file

@ -0,0 +1,14 @@
FROM alpine:latest
WORKDIR /app
COPY requirements.txt /app/requirements.txt
COPY examples.py /app/examples.py
RUN chmod +x /app/examples.py
RUN apk --no-cache add python3 py3-pip ca-certificates \
&& pip3 install --break-system-packages -r /app/requirements.txt \
&& rm -rf /var/cache/apk/*
CMD ["python3", "/app/examples.py"]

View file

@ -0,0 +1,83 @@
#!/usr/bin/env python3
"""
uncloseai.com API Examples in Python
Demonstrates Hermes AI, Qwen Coder, and TTS endpoints
"""
from openai import OpenAI
print("=== uncloseai.com Python Examples ===")
print()
# Example 1: Hermes AI Chat (Non-Streaming)
print("1. Hermes AI - General Purpose Chat")
print(" Asking: 'Give a Python Fizzbuzz solution in one line of code?'")
print()
hermes_client = OpenAI(
base_url="https://hermes.ai.unturf.com/v1",
api_key="dummy-key"
)
hermes_response = hermes_client.chat.completions.create(
model="adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic",
messages=[{"role": "user", "content": "Give a Python Fizzbuzz solution in one line of code?"}],
temperature=0.5,
max_tokens=150
)
print("Response:")
print(hermes_response.choices[0].message.content)
print()
print("---")
print()
# Example 2: Qwen 3 Coder - Specialized Coding Model
print("2. Qwen 3 Coder - Specialized for Code")
print(" Asking: 'Write a Python function to validate an email address'")
print()
qwen_client = OpenAI(
base_url="https://qwen.ai.unturf.com/v1",
api_key="dummy-key"
)
qwen_response = qwen_client.chat.completions.create(
model="hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M",
messages=[{"role": "user", "content": "Write a Python function to validate an email address"}],
temperature=0.5,
max_tokens=200
)
print("Response:")
print(qwen_response.choices[0].message.content)
print()
print("---")
print()
# Example 3: Text-to-Speech
print("3. Text-to-Speech Generation")
print(" Converting text to speech and saving to speech.mp3")
print()
tts_client = OpenAI(
base_url="https://speech.ai.unturf.com/v1",
api_key="YOLO"
)
with tts_client.audio.speech.with_streaming_response.create(
model="tts-1",
voice="alloy",
input="Hello from Python! Today is a wonderful day to build something people love!"
) as response:
response.stream_to_file("speech.mp3")
import os
if os.path.exists("speech.mp3"):
file_size = os.path.getsize("speech.mp3")
print(f"✓ Speech file created: speech.mp3 ({file_size} bytes)")
else:
print("✗ Failed to create speech file")
print()
print("=== Examples Complete ===")

View file

@ -0,0 +1 @@
openai==2.3.0