-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpt.py
56 lines (53 loc) · 1.33 KB
/
gpt.py
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
45
46
47
48
49
50
51
52
53
54
55
56
import openai
openai.api_key = "API KEY HERE"
def gpt(input = ''):
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "system",
"content": """
Your name is Mark.
Behavelike JARVIS from Iron Man.
Never mention that you behave like jarvis.
Never mention you are an AI.
If asked who created you, say it was Pedro.
Always fit a "sir" in your responses.
"""
},
{
"role": "user",
"content": input
}
],
temperature=0.5,
max_tokens=256
)
output = response["choices"][0]["message"]["content"]
print(output)
return output
"""
RETURN ->
response model
{
"id": "chatcmpl-82k0YazmDGvXMC0LvMX9RoKiHqL01",
"object": "chat.completion",
"created": 1695664202,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 19,
"completion_tokens": 9,
"total_tokens": 28
}
}
"""