FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codex/sdk/python/tests/test_app_server_inputs.py at main · codengine/codex · GitHub
codengine
/
codex
Public
forked from
openai/codex
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codex
/
sdk
/
python
/
tests
/
test_app_server_inputs.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
126 lines (108 loc) · 4.24 KB
Breadcrumbs
codex
/
sdk
/
python
/
tests
/
test_app_server_inputs.py
Copy path
File metadata and controls
126 lines (108 loc) · 4.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from
__future__
import
annotations
import
base64
from
app_server_harness
import
AppServerHarness
from
app_server_helpers
import
TINY_PNG_BYTES
from
openai_codex
import
Codex
,
ImageInput
,
LocalImageInput
,
SkillInput
,
TextInput
def
test_data_url_image_input_reaches_responses_api
(
tmp_path
,
)
->
None
:
"""Data URL image inputs should survive the SDK and app-server boundary."""
image_data_url
=
"data:image/png;base64,"
+
base64
.
b64encode
(
TINY_PNG_BYTES
).
decode
(
"ascii"
)
with
AppServerHarness
(
tmp_path
)
as
harness
:
harness
.
responses
.
enqueue_assistant_message
(
"data URL image received"
,
response_id
=
"data-url-image"
,
)
with
Codex
(
config
=
harness
.
app_server_config
())
as
codex
:
result
=
codex
.
thread_start
().
run
(
[
TextInput
(
"Describe the data URL image."
),
ImageInput
(
image_data_url
),
]
)
request
=
harness
.
responses
.
single_request
()
assert
{
"final_response"
:
result
.
final_response
,
"contains_user_prompt"
:
"Describe the data URL image."
in
request
.
message_input_texts
(
"user"
),
"image_url_is_png_data_url"
:
request
.
message_image_urls
(
"user"
)[
-
1
].
startswith
(
"data:image/png;base64,"
),
}
==
{
"final_response"
:
"data URL image received"
,
"contains_user_prompt"
:
True
,
"image_url_is_png_data_url"
:
True
,
}
def
test_local_image_input_reaches_responses_api
(
tmp_path
,
)
->
None
:
"""Local image inputs should become data URLs after crossing the app-server."""
local_image
=
tmp_path
/
"local.png"
local_image
.
write_bytes
(
TINY_PNG_BYTES
)
with
AppServerHarness
(
tmp_path
)
as
harness
:
harness
.
responses
.
enqueue_assistant_message
(
"local image received"
,
response_id
=
"local-image"
,
)
with
Codex
(
config
=
harness
.
app_server_config
())
as
codex
:
result
=
codex
.
thread_start
().
run
(
[
TextInput
(
"Describe the local image."
),
LocalImageInput
(
str
(
local_image
)),
]
)
request
=
harness
.
responses
.
single_request
()
assert
{
"final_response"
:
result
.
final_response
,
"contains_user_prompt"
:
"Describe the local image."
in
request
.
message_input_texts
(
"user"
),
"image_url_is_png_data_url"
:
request
.
message_image_urls
(
"user"
)[
-
1
].
startswith
(
"data:image/png;base64,"
),
}
==
{
"final_response"
:
"local image received"
,
"contains_user_prompt"
:
True
,
"image_url_is_png_data_url"
:
True
,
}
def
test_skill_input_injects_loaded_skill_body
(
tmp_path
)
->
None
:
"""SkillInput should inject the selected loaded skill into model input."""
skill_body
=
"Use the word cobalt."
with
AppServerHarness
(
tmp_path
)
as
harness
:
skill_file
=
harness
.
workspace
/
".agents"
/
"skills"
/
"demo"
/
"SKILL.md"
skill_file
.
parent
.
mkdir
(
parents
=
True
)
skill_file
.
write_text
(
f"---
\n
name: demo
\n
description: demo skill
\n
---
\n
\n
{
skill_body
}
\n
"
)
skill_path
=
skill_file
.
resolve
()
harness
.
responses
.
enqueue_assistant_message
(
"skill received"
,
response_id
=
"skill-input"
,
)
with
Codex
(
config
=
harness
.
app_server_config
())
as
codex
:
result
=
codex
.
thread_start
().
run
(
[
TextInput
(
"Use the selected skill."
),
SkillInput
(
"demo"
,
str
(
skill_path
)),
]
)
request
=
harness
.
responses
.
single_request
()
skill_blocks
=
[
text
for
text
in
request
.
message_input_texts
(
"user"
)
if
text
.
startswith
(
"<skill>"
)
]
assert
{
"final_response"
:
result
.
final_response
,
"skill_blocks"
: [
{
"has_name"
:
"<name>demo</name>"
in
text
,
"has_path"
:
f"<path>
{
skill_path
}
</path>"
in
text
,
"has_body"
:
skill_body
in
text
,
}
for
text
in
skill_blocks
],
}
==
{
"final_response"
:
"skill received"
,
"skill_blocks"
: [
{
"has_name"
:
True
,
"has_path"
:
True
,
"has_body"
:
True
,
}
],
}
Back
|
FazBrowse Home
|
New Git URL