dev / app.py
Dzsysop's picture
debug app.py about available models
8a6ff9d
Raw
History Blame
612 Bytes
# 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()