-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path1_secure_chat.py
More file actions
44 lines (34 loc) · 1.81 KB
/
1_secure_chat.py
File metadata and controls
44 lines (34 loc) · 1.81 KB
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
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
"""Step 1: Example conversation content for the premium session."""
from memor import Prompt, Response, Session, Role, RenderFormat
from mistralai import Mistral
sample_messages = [
"Hey, I need help planning my 3-month Europe trip. I'll be visiting France, Italy, and Germany. What else information should I give to you?",
"My budget is around $7,200. I'm trying to keep track of flight costs, hotels, and food. Do you need any contact information?",
"Here is my email just in case: personal.email@example.com. What are the options I have for the flight?",
"I'm thinking of booking a multi-city flight. Found one for $1240 on Lufthansa. Do you need more information?",
"OK! Here's a chunk of my notes: " + "lorem ipsum " * 400 + "\n\nCan you book it for me if I give you my information?", # intentionally long
"My passport number is X12345678. Please remind me to renew it, it's a bit old. Should we start the daily plan of the trip?",
"Can you help me create a daily itinerary for France first?",
]
system_instruction = "You are a helpful assistant. Provide concise and accurate answers."
system_prompt = Prompt(message=system_instruction, role=Role.SYSTEM)
MISTRAL_API_KEY = "YOUR_MISTRAL_API_KEY"
MISTRAL_MODEL = "mistral-large-latest"
mistral_client = Mistral(api_key=MISTRAL_API_KEY)
session = Session(title="Private Chat")
session.add_message(system_prompt)
for msg in sample_messages:
p = Prompt(message=msg, role=Role.USER)
session.add_message(p)
response = mistral_client.chat.complete(
model=MISTRAL_MODEL,
messages=session.render(RenderFormat.OPENAI)
).choices[0].message.content
r = Response(
message=response,
role=Role.ASSISTANT,
)
session.add_message(r)
df = session.to_dataframe()
df.to_csv('2_session_df.csv')