initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from mistralai import Mistral
|
||||
import inbox
|
||||
import os
|
||||
|
||||
api_key = os.environ["MISTRAL_API_KEY"]
|
||||
if api_key is None:
|
||||
raise "Please provide a valid MISTRAL_API_KEY"
|
||||
|
||||
|
||||
client = Mistral(api_key=api_key)
|
||||
|
||||
def process(instructions: str) -> str:
|
||||
messages = [{
|
||||
"role": "system",
|
||||
"content": instructions,
|
||||
},{
|
||||
"role": "system",
|
||||
"content": "Here is the list of emails",
|
||||
}]
|
||||
|
||||
for mail in inbox.fetch_emails():
|
||||
content = f"""
|
||||
Date: {mail["date"]}
|
||||
From: {mail["from"]}
|
||||
To: {mail["to"]}
|
||||
|
||||
Subject: {mail["subject"]}
|
||||
Body: {mail["text"]}
|
||||
"""
|
||||
messages.append({
|
||||
"role": "user",
|
||||
"content": content,
|
||||
})
|
||||
|
||||
chat_response = client.chat.complete(
|
||||
model = "mistral-tiny",
|
||||
messages = messages)
|
||||
|
||||
return chat_response.choices[0].message.content
|
||||
Reference in New Issue
Block a user