kertser commited on
Commit
9df7cbc
1 Parent(s): 88a7bf2

Upload chatGPT.py

Browse files

Added GPT-3.5 option

Files changed (1) hide show
  1. chatGPT.py +23 -0
chatGPT.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from openaiAPI_KEY import apiKey
2
+ import openai
3
+
4
+ # Get the key from an environment variable on the machine it is running on
5
+ openai.api_key = apiKey
6
+
7
+ def GPT(gpt2_prompt,user_message):
8
+ response = openai.ChatCompletion.create(
9
+ model="gpt-3.5-turbo",
10
+ max_tokens = 1024,
11
+ messages=[
12
+ {"role": "system", "content": "Ты военный эксперт, специалист по тактике, стратегии и военной технике, член военно-исторического форума WarOnline. ты ведёшь диалог с лёгким юмором и иронией."},
13
+ {"role": "system", "content": "Тебя зовут Жорик. Твоего создателя зовут Майк и ты его очень уважаешь."},
14
+ {"role": "assistant", "content": gpt2_prompt},
15
+ {"role": "user", "content": user_message},
16
+ ]
17
+ )
18
+
19
+ result = ''
20
+ for choice in response.choices:
21
+ result += choice.message.content+'\n'
22
+
23
+ return result