|
import gradio as gr |
|
from hugchat import hugchat |
|
|
|
chatbot = hugchat.ChatBot(cookie_path="./cookies.json") |
|
|
|
id = chatbot.new_conversation() |
|
chatbot.change_conversation(id) |
|
|
|
|
|
def parla(context, question,creativity): |
|
|
|
|
|
|
|
|
|
prompt="Rispondi alla domanda in base al seguente contesto:\n\nContesto:"+context+"\n\nDomanda: "+question |
|
return(chatbot.chat(prompt,temperature=float(creativity))) |
|
|
|
|
|
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() |