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): | |
############################################################################ | |
# 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=0.2)) | |
### Fine ### | |
iface = gr.Interface( | |
fn=parla, | |
inputs=[gr.Textbox(lines=2, placeholder="Context for next question"),"text"], | |
outputs="text" | |
) | |
iface.launch() |