Spaces:
Runtime error
Runtime error
import gradio as gr | |
#from mistralai import Mistral, UserMessage | |
from chatbot_gaia.src.main_flow import kickoff | |
import pandas as pd | |
import os | |
title = "Gaia Mistral Chat Demo" | |
description = "Example of simple chatbot with Gradio and Mistral AI via its API" | |
placeholder = "Posez moi une question sur l'agriculture" | |
examples = ["Je suis un agriculture basé pas loin de bordeaux et je cultive du mais et je cherche des recommandations d'autres cultures mieux adapté aux changements climatique ?", | |
"Je suis un agriculteur basé au sud de la France vers Nice, je cherche des recommandations de cultures mieux adapté aux changements climatiques ?",] | |
#api_key = os.environ.get("MISTRAL_API_KEY") | |
#client = MistralClient(api_key=api_key) | |
#client = Mistral(api_key=api_key) | |
#model = 'open-mixtral-8x7b' | |
""" | |
def chat_with_mistral(user_input, history): | |
messages = [{"role": "user", "content": user_input}] | |
chat_response = client.chat.complete(model=model, messages=messages)P | |
return chat_response.choices[0].message.content | |
""" | |
def chat_with_agrienergy(user_input, history): | |
messages = [{"role": "user", "content": user_input}] | |
result = kickoff(user_input=user_input) | |
return f"{result}" | |
iface = gr.ChatInterface( | |
fn=chat_with_agrienergy, | |
chatbot=gr.Chatbot(height=300), | |
textbox=gr.Textbox(placeholder=placeholder, container=False, scale=7), | |
title=title, | |
description=description, | |
theme="soft", | |
examples=examples, | |
cache_examples=False, | |
) | |
iface.launch(share=True) | |