import gradio as gr from hugchat import hugchat from hugchat.login import Login import os #hugsec=os.environ.get('hugsec') #sign = Login('rcudazzo@outlook.it', None) #cookies = sign.loadCookies() chatbot = hugchat.ChatBot(cookie_path="usercookies/rcudazzo@outlook.it.json") # or cookie_path="usercookies/.json" print(chatbot.chat("HI")) # 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()