File size: 697 Bytes
9041e41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
import os
import gradio as gr
from openai import OpenAI

# Cliente para Hugging Face Inference API
client = OpenAI(
    base_url="https://router.huggingface.co/v1",
    api_key=os.environ["HF_TOKEN"],  # Definido nas Secrets do Space
)

def ask_model(question):
    completion = client.chat.completions.create(
        model="Qwen/Qwen3-4B-Thinking-2507:nscale",
        messages=[
            {"role": "user", "content": question}
        ],
    )
    return completion.choices[0].message.content

demo = gr.Interface(
    fn=ask_model,
    inputs=gr.Textbox(label="Pergunta"),
    outputs=gr.Textbox(label="Resposta"),
    title="Minha API de IA"
)

if __name__ == "__main__":
    demo.launch()