-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
62 lines (59 loc) · 1.61 KB
/
demo.py
File metadata and controls
62 lines (59 loc) · 1.61 KB
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
57
58
59
60
61
62
import erniebot
functions = functions = [
{
'name': 'get_current_temperature',
'description': "获取指定城市的气温",
'parameters': {
'type': 'object',
'properties': {
'location': {
'type': 'string',
'description': "城市名称",
},
'unit': {
'type': 'string',
'enum': [
'摄氏度',
'华氏度',
],
},
},
'required': [
'location',
'unit',
],
},
'responses': {
'type': 'object',
'properties': {
'temperature': {
'type': 'integer',
'description': "城市气温",
},
'unit': {
'type': 'string',
'enum': [
'摄氏度',
'华氏度',
],
},
},
},
},
]
erniebot.api_type = 'aistudio'
erniebot.access_token = '3c410ce131fe8d246c47e26fdf932cfd44e95aa8'
messages = [
{
'role': 'user',
'content': "深圳市今天气温如何?",
}
]
response = erniebot.ChatCompletion.create(
model='ernie-bot',
messages=messages,
functions=functions,
)
assert hasattr(response, 'function_call')
function_call = response.function_call
print(function_call)