Spaces:
Paused
Paused
File size: 1,188 Bytes
9189e38 |
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 |
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)
|