-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsession_openai.py
71 lines (61 loc) · 1.9 KB
/
session_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from log10.load import OpenAI, log10_session, log10_tags, with_log10_tags
client = OpenAI()
@with_log10_tags(["decorator-tags", "decorator-tags-2"])
def completion_with_tags():
completion = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "user",
"content": "Hello?",
},
],
)
print(completion.choices[0].message)
with log10_session(tags=["log10-io/examples"]):
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "user",
"content": "Hello?",
},
],
)
print(completion.choices[0].message)
with log10_tags(["extra_tag_1", "extra_tag_2"]):
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "user",
"content": "Hello again, are you there?",
},
],
)
print(completion.choices[0].message)
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "user",
"content": "Hello again and again?",
},
],
)
print(completion.choices[0].message)
completion_with_tags()
# add a test with log10_tags and log10_session, where log10_session is nested inside log10_tags
with log10_tags(["outer-tag-1", "outer-tag-2"]):
with log10_session(tags=["inner-tag-1", "inner-tag-2"]):
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "user",
"content": "Hello again and again?",
},
],
)
print(completion.choices[0].message)
completion_with_tags()