Spaces:
Runtime error
Runtime error
File size: 1,254 Bytes
7af6bd2 8fa2802 7af6bd2 121f2f7 a1f1d6b 7af6bd2 8fa2802 f675048 8fa2802 a2d959f 8fa2802 7af6bd2 8fa2802 7af6bd2 8fa2802 7af6bd2 47ed5af |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import gradio as gr
from mistralai import Mistral, UserMessage
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 = ["Comment fait on pour produire du maïs ?", "Rédige moi une lettre pour faire un stage dans une exploitation agricole", "Comment reprendre une exploitation agricole ?"]
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)
return chat_response.choices[0].message.content
"""
def chat_with_mistral(user_input, history):
messages = [{"role": "user", "content": user_input}]
return "This is a dummy response"
iface = gr.ChatInterface(
fn=chat_with_mistral,
chatbot=gr.Chatbot(height=300),
textbox=gr.Textbox(placeholder=placeholder, container=False, scale=7),
title=title,
description=description,
theme="soft",
examples=examples,
cache_examples=True,
)
iface.launch(share=True) |