File size: 1,275 Bytes
b513fcc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from flask import Flask, request, jsonify
from mistralai.client import MistralClient
from mistralai.models.chat_completion import ChatMessage

app = Flask(__name__)

# Ensure the environment variable for the API key is set
os.environ["MISTRAL_API_KEY"] = "JGKRrtZuxRncvjl32EI0EMFjvBUC10h7"
api_key = os.environ.get("MISTRAL_API_KEY")
if not api_key:
    raise ValueError("MISTRAL_API_KEY environment variable not set")

model = "mistral-tiny"
client = MistralClient(api_key=api_key)

@app.route('/generate-goals', methods=['POST'])
def generate_goals():
    input_var = request.json.get('input_var', '')

    messages = [
        ChatMessage(role="user", content=f"Generate 10 specific, industry relevant goals for {input_var} using Python and Pundos. 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")
    ]

    # Ensure the model name is correct and exists
    response = client.chat(model=model, messages=messages)
    content = response.choices[0].message.content

    return jsonify({'content': content})

if __name__ == '__main__':
    app.run(debug=True)