File size: 792 Bytes
053834c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import gradio as gr
import requests
# Replace with your actual API endpoint (if using a different service)
API_URL = "https://api.deepseek.com/v1/chat/completions" # Example (not me)
API_KEY = "your-api-key" # Replace with your key
def ask_ruby(question):
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
data = {
"messages": [{"role": "user", "content": question}]
}
response = requests.post(API_URL, headers=headers, json=data)
return response.json()["choices"][0]["message"]["content"]
# Gradio UI (optional, but useful for testing)
demo = gr.Interface(
fn=ask_ruby,
inputs=gr.Textbox(lines=2, placeholder="Ask Ruby anything..."),
outputs="text",
title="Ruby AI API"
)
demo.launch() |