forked from r2d4/openlm
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
as_openai.py
44 lines (40 loc) · 1.04 KB
/
as_openai.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
import sys
from pathlib import Path
sys.path.append(str(Path(__file__).resolve().parent.parent))
import openlm as openai
import json
completion = openai.Completion.create(
model="ada",
prompt="Hello world"
)
print(json.dumps(completion, indent=4))
'''
{
"id": "3890d5c3-e6c4-4222-b77d-40a65f1d032b",
"object": "text_completion",
"created": 1683583320,
"choices": [
{
"id": "660d576d-8c04-420f-b410-146729c8fc8a",
"model_idx": 0,
"model_name": "openai.com/ada",
"index": 0,
"created": 1683583320,
"text": ". Details?), website modding, something that makes no sense, and just design",
"usage": {
"prompt_tokens": 2,
"completion_tokens": 16,
"total_tokens": 18
},
"extra": {
"id": "cmpl-7E3DcN1o6Axv1JIXxHNt11Q0wA1Is"
}
}
],
"usage": {
"prompt_tokens": 2,
"completion_tokens": 16,
"total_tokens": 18
}
}
'''