Create app.py
#1
by
harris1
- opened
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from mistralai.client import MistralClient
|
3 |
+
from mistralai.models.chat_completion import ChatMessage
|
4 |
+
|
5 |
+
# Ensure the environment variable for the API key is set
|
6 |
+
os.environ["MISTRAL_API_KEY"] = "API_KEY"
|
7 |
+
api_key = os.environ.get("MISTRAL_API_KEY")
|
8 |
+
if not api_key:
|
9 |
+
raise ValueError("MISTRAL_API_KEY environment variable not set")
|
10 |
+
|
11 |
+
model = "mistral-tiny"
|
12 |
+
|
13 |
+
client = MistralClient(api_key=api_key)
|
14 |
+
#we can tak input_var from frontend
|
15 |
+
input_var = "Exam data Analysis"
|
16 |
+
|
17 |
+
messages = [
|
18 |
+
ChatMessage(role="user", content=f"Generate 10 specific, industry relevant goals for {input_var} using Python and Pandas. Each goal should include a brief name and a one-sentence description of the task or skill. Focus on practical applications in educational assessment, covering areas such as data processing, statistical analysis, visualization, and advanced techniques")
|
19 |
+
]
|
20 |
+
|
21 |
+
# # Ensure the model name is correct and exists
|
22 |
+
response = client.chat(model=model, messages=messages)
|
23 |
+
content = response.choices[0].message.content
|
24 |
+
|
25 |
+
|
26 |
+
print(content)
|