-
Notifications
You must be signed in to change notification settings - Fork 485
Expand file tree
/
Copy pathchat.py
More file actions
30 lines (23 loc) · 725 Bytes
/
chat.py
File metadata and controls
30 lines (23 loc) · 725 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
30
import openai
MODEL_NAME = "phi3:mini"
client = openai.OpenAI(
base_url="http://localhost:11434/v1",
api_key="nokeyneeded",
)
messages = [
{"role": "system", "content": "You are a chat assistant that helps people with their questions."},
]
while True:
question = input("\nYour question: ")
print("Sending question...")
messages.append({"role": "user", "content": question})
response = client.chat.completions.create(
model=MODEL_NAME,
messages=messages,
temperature=1,
max_tokens=400
)
bot_response = response.choices[0].message.content
messages.append({"role": "assistant", "content": bot_response})
print("Answer: ")
print(bot_response)