import gradio as gr from mistralai.client import Mistral import os MISTRAL_API_KEY = os.environ.get("MISTRAL_API_KEY") model = "mistral-small-latest" client = Mistral(api_key=MISTRAL_API_KEY) def ask_mistral(message: str, history: list): history.append({"role": "user", "content": message}) stream = client.chat.stream(messages=history, model=model) chunks = [] for chunk in stream: chunks.append(chunk.data.choices[0].delta.content or "") yield "".join(chunks) app = gr.ChatInterface(fn = ask_mistral, title = "IZIRED chatbot") app.launch(debug=True)