forked from unconv/gpt-ai-agent
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgpt_functions.py
48 lines (45 loc) · 1.53 KB
/
gpt_functions.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
import json
def write_file(filename, content):
sure = input("Do you want to write to " + filename + "? (YES/NO) ")
if sure == "YES":
with open(filename, "w") as f:
f.write(content)
return "Successfully written file " + filename
else:
return "ERROR: You are not allowed to write to this file"
def get_jokes(number_of_jokes):
return json.dumps(["Why don't scientists trust atoms? Because they make up all the things!", 'How did the computer get wasted? It took screenshots!', "Why don't skeletons fight other skeletons? They don't have the guts!"])
definitions = [
{
"name": "get_jokes",
"description": "Gets jokes from the joke database",
"parameters": {
"type": "object",
"properties": {
"number_of_jokes": {
"type": "number",
"description": "Gets the specified number of jokes"
}
}
},
"required": ["number_of_jokes"]
},
{
"name": "write_file",
"description": "Writes content to a file",
"parameters": {
"type": "object",
"properties": {
"filename": {
"type": "string",
"description": "Filename to write to"
},
"content": {
"type": "string",
"description": "Content to write to file"
}
}
},
"required": ["filename", "content"]
}
]