sofia / app.py
Curaf's picture
Update app.py
cd0bfa3
raw
history blame
839 Bytes
import gradio as gr
from hugchat import hugchat
chatbot = hugchat.ChatBot(cookie_path="./cookies.json")
# Nuova a conversazione
id = chatbot.new_conversation()
chatbot.change_conversation(id)
def parla(context, question,creativity):
############################################################################
# Qua puoi eventualmente aggiungere alla domanda un contesto specifico
############################################################################
prompt="Rispondi alla domanda in base al seguente contesto:\n\nContesto:"+context+"\n\nDomanda: "+question
return(chatbot.chat(prompt,temperature=float(creativity)))
### Fine ###
iface = gr.Interface(
fn=parla,
inputs=[gr.Textbox(lines=2, placeholder="Context for next question"),"text",gr.Slider(0,1,value=0.2,step=0.1)],
outputs="text"
)
iface.launch()