File size: 612 Bytes
837726c
d397212
837726c
 
d397212
837726c
d397212
837726c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# app.py
import gradio as gr
from huggingface_hub import InferenceClient
import os

client = InferenceClient(token=os.environ.get("HF_TOKEN"))

def predict(prompt):
    try:
        response = client.text_generation(
            prompt=prompt,
            model="microsoft/phi-2",
            max_new_tokens=100
        )
        return response
    except:
        return "Извините, сервис временно недоступен"

gr.Interface(
    fn=predict,
    inputs=gr.Textbox(label="Вопрос к NPC"),
    outputs=gr.Textbox(label="Ответ"),
    title="AI для игры"
).launch()