ghost717 commited on
Commit
2bf5def
1 Parent(s): d7382dd

chatOpenAI & groq_API_KEY ;d

Browse files
Files changed (1) hide show
  1. chat.py +23 -0
chat.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from openai import OpenAI
2
+ import os
3
+ from dotenv import load_dotenv
4
+ load_dotenv()
5
+
6
+ OPENAI_API_KEY = os.environ['OPENAI_API_KEY']
7
+
8
+ client = OpenAI()
9
+
10
+ response = client.chat.completions.create(
11
+ # model="gpt-4-turbo",
12
+ model="gpt-4o",
13
+ messages=[
14
+ {"role": "system", "content": "You are a helpful assistant."},
15
+ {"role": "user", "content": "Who won the world series in 2020?"},
16
+ {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
17
+ {"role": "user", "content": "Where was it played?"}
18
+ ]
19
+ )
20
+ print('')
21
+ print(response)
22
+ print('')
23
+ print(response.choices[0].message.content)