Spaces:
Paused
Paused
import os | |
from mistralai.client import MistralClient | |
from mistralai.models.chat_completion import ChatMessage | |
api_key = os.environ["MISTRAL_API_KEY"] | |
model = "mistral-large-latest" | |
client = MistralClient(api_key=api_key) | |
# Return the name in a short JSON object with a single key called name. Only return the json object. What item from this list is most similar to: 'Pepper - Habanero Pepper'. List: Stuffed pepper, with rice and meat; Stuffed pepper, with rice, meatless; Pepper, hot chili, raw; Pepper, raw, NFS; Pepper, sweet, green, raw; Pepper, sweet, red, raw; Pepper, banana | |
messages = [ | |
ChatMessage(role="user", content=""" | |
Return the name in a short JSON object. What item from this list is most similar to: 'Pepper - Habanero Pepper'. List: | |
- Stuffed pepper, with rice and meat | |
- Stuffed pepper, with rice, meatless | |
- Pepper, hot chili, raw | |
- Pepper, raw, NFS | |
- Pepper, sweet, green, raw | |
- Pepper, sweet, red, raw | |
- Pepper, banana, raw | |
""") | |
] | |
chat_response = client.chat( | |
model=model, | |
response_format={"type": "json_object"}, | |
messages=messages, | |
) | |
print(chat_response.choices[0].message.content) | |