Spaces:
Paused
Paused
comment app
Browse files
app.py
CHANGED
@@ -1,36 +1,36 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from mistralai.client import MistralClient, ChatMessage
|
3 |
-
import os
|
4 |
-
from dotenv import load_dotenv
|
5 |
|
6 |
-
# Load environment variables
|
7 |
-
load_dotenv()
|
8 |
-
api_key = os.getenv('API_KEY')
|
9 |
|
10 |
-
# Initialize Mistral client with the API key
|
11 |
-
client = MistralClient(api_key=api_key)
|
12 |
|
13 |
-
def answer_question(question):
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
|
23 |
-
def run_mistral(user_message, model="mistral-medium"):
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
app = gr.Interface(fn=answer_question,
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
-
if __name__ == "__main__":
|
36 |
-
|
|
|
1 |
+
# import gradio as gr
|
2 |
+
# from mistralai.client import MistralClient, ChatMessage
|
3 |
+
# import os
|
4 |
+
# from dotenv import load_dotenv
|
5 |
|
6 |
+
# # Load environment variables
|
7 |
+
# load_dotenv()
|
8 |
+
# api_key = os.getenv('API_KEY')
|
9 |
|
10 |
+
# # Initialize Mistral client with the API key
|
11 |
+
# client = MistralClient(api_key=api_key)
|
12 |
|
13 |
+
# def answer_question(question):
|
14 |
+
# """Directly ask Mistral the question and return the answer."""
|
15 |
+
# # Format the user's question for Mistral
|
16 |
+
# user_message = question
|
17 |
|
18 |
+
# # Use the run_mistral function to get an answer
|
19 |
+
# answer = run_mistral(user_message)
|
20 |
|
21 |
+
# return answer
|
22 |
|
23 |
+
# def run_mistral(user_message, model="mistral-medium"):
|
24 |
+
# """Interact with Mistral using chat."""
|
25 |
+
# messages = [ChatMessage(role="user", content=user_message)]
|
26 |
+
# chat_response = client.chat(model=model, messages=messages)
|
27 |
+
# return chat_response.choices[0].message.content
|
28 |
|
29 |
+
# app = gr.Interface(fn=answer_question,
|
30 |
+
# inputs=gr.inputs.Textbox(lines=2, placeholder="Ask a question..."),
|
31 |
+
# outputs="text",
|
32 |
+
# title="Your Assistant",
|
33 |
+
# description="Ask any question, and I'll try to provide an informative answer.")
|
34 |
|
35 |
+
# if __name__ == "__main__":
|
36 |
+
# app.launch(share=True) # Set `share=True` to create a public link
|