-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathagent.py
More file actions
29 lines (21 loc) · 808 Bytes
/
agent.py
File metadata and controls
29 lines (21 loc) · 808 Bytes
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
import os
from mistralai import Mistral
import discord
MISTRAL_MODEL = "mistral-large-latest"
SYSTEM_PROMPT = "You are a helpful assistant."
class MistralAgent:
def __init__(self):
MISTRAL_API_KEY = os.getenv("MISTRAL_API_KEY")
self.client = Mistral(api_key=MISTRAL_API_KEY)
async def run(self, message: discord.Message):
# The simplest form of an agent
# Send the message's content to Mistral's API and return Mistral's response
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": message.content},
]
response = await self.client.chat.complete_async(
model=MISTRAL_MODEL,
messages=messages,
)
return response.choices[0].message.content