python-codex 0.3.3__py3-none-any.whl → 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pycodex/__init__.py +3 -27
- pycodex/bootstrap.py +5 -45
- pycodex/cli.py +1 -14
- pycodex/context.py +1 -1
- pycodex/events.py +1 -1
- pycodex/model.py +2 -2
- pycodex/portable/__init__.py +45 -0
- pycodex/{portable.py → portable/client.py} +4 -7
- pycodex/{portable_server.py → portable/server.py} +3 -3
- pycodex/protocol.py +1 -1
- pycodex/runtime.py +1 -1
- pycodex/tools/base_tool.py +1 -1
- pycodex/tools/close_agent_tool.py +1 -1
- pycodex/tools/code_mode_manager.py +1 -1
- pycodex/tools/request_permissions_tool.py +1 -1
- pycodex/tools/resume_agent_tool.py +1 -1
- pycodex/{runtime_services.py → tools/runtime_services.py} +5 -5
- pycodex/tools/send_input_tool.py +1 -1
- pycodex/tools/spawn_agent_tool.py +1 -1
- pycodex/tools/unified_exec_manager.py +1 -1
- pycodex/tools/update_plan_tool.py +1 -1
- pycodex/tools/view_image_tool.py +5 -0
- pycodex/tools/wait_agent_tool.py +1 -1
- pycodex/utils/__init__.py +0 -4
- pycodex/utils/_aes_gcm/LICENSE +56 -0
- pycodex/utils/_aes_gcm/README.md +61 -0
- pycodex/utils/_aes_gcm/__init__.py +1 -0
- pycodex/utils/_aes_gcm/aes.py +175 -0
- pycodex/utils/_aes_gcm/gcm.py +73 -0
- pycodex/utils/_aes_gcm/source-sha256.json +4 -0
- pycodex/{compat.py → utils/compat.py} +2 -0
- pycodex/utils/crypto.py +35 -0
- pycodex/utils/debug.py +24 -0
- pycodex/{doctor.py → utils/doctor.py} +3 -3
- pycodex/utils/image_utils.py +3 -2
- pycodex/{model_metadata.py → utils/model_metadata.py} +2 -2
- {python_codex-0.3.3.dist-info → python_codex-0.4.0.dist-info}/METADATA +120 -42
- {python_codex-0.3.3.dist-info → python_codex-0.4.0.dist-info}/RECORD +42 -50
- {python_codex-0.3.3.dist-info → python_codex-0.4.0.dist-info}/entry_points.txt +0 -1
- responses_server/app.py +28 -15
- pycodex/feishu_card.py +0 -793
- pycodex/feishu_link.py +0 -440
- pycodex/tools/ipython_tool.py +0 -142
- workspace_server/__init__.py +0 -39
- workspace_server/__main__.py +0 -4
- workspace_server/app.py +0 -1906
- workspace_server/content_views.LICENSE.txt +0 -470
- workspace_server/content_views.css +0 -1
- workspace_server/content_views.mjs +0 -25
- workspace_server/editor.css +0 -1
- workspace_server/editor.mjs +0 -1260
- workspace_server/owned_process.py +0 -27
- workspace_server/workspace.html +0 -2267
- workspace_server/workspace_views.py +0 -533
- workspace_server/workspaces.html +0 -550
- workspace_server/workspaces.py +0 -632
- {python_codex-0.3.3.dist-info → python_codex-0.4.0.dist-info}/WHEEL +0 -0
- {python_codex-0.3.3.dist-info → python_codex-0.4.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
pycodex/__init__.py,sha256=
|
|
1
|
+
pycodex/__init__.py,sha256=fHEyhylULeRo-5xEnl-UxT5ZpBzbFzRW7vLwdy_7oxU,2660
|
|
2
2
|
pycodex/__main__.py,sha256=MHKZ_ae3fSLGTLUUMOx15fWdeOnJSHhq-zslRP5F5Lc,79
|
|
3
3
|
pycodex/agent.py,sha256=zCIG2DV0oQntLXHFj8FVRkgBp5TCC0YJ7sz0lni9J1s,21177
|
|
4
|
-
pycodex/bootstrap.py,sha256=
|
|
5
|
-
pycodex/cli.py,sha256=
|
|
6
|
-
pycodex/
|
|
7
|
-
pycodex/
|
|
8
|
-
pycodex/
|
|
9
|
-
pycodex/
|
|
10
|
-
pycodex/
|
|
11
|
-
pycodex/
|
|
12
|
-
pycodex/
|
|
13
|
-
pycodex/
|
|
14
|
-
pycodex/portable.py,sha256=rfOpVnBZ01RS0Kyjo_w2FNKHY2t-lUcHVtWhPsbp1-k,16158
|
|
15
|
-
pycodex/portable_server.py,sha256=A4IY3xHtBQLRxdHQ4O5zdaVGjqENaLvypsSkLGZvCZ0,7498
|
|
16
|
-
pycodex/protocol.py,sha256=dRcTVKTaE7Eaq_jiSYdCzBMebIo3gnL7wB1x-NJqY5E,12027
|
|
17
|
-
pycodex/runtime.py,sha256=bRlqrmXqK6kPndAG96QoGALKicbWmfuXgo2jDvbQzdE,23806
|
|
18
|
-
pycodex/runtime_services.py,sha256=4jDCMlXHwgbJZPJkWzVEPCRHPxrD0mpCBbDInVToGG8,15033
|
|
4
|
+
pycodex/bootstrap.py,sha256=U1X5kwORpS5JnPk9HhIiOVWPQzDLlk_ro_cY2knwL8I,12421
|
|
5
|
+
pycodex/cli.py,sha256=MLvXpVwrb-HJuVWmPFmNMTR-4cqR3X08ZfAevYlVSQI,12646
|
|
6
|
+
pycodex/context.py,sha256=yfNY2alT3caQQwhay47pSSrGUbgEAcLKhTVaZqtQ4yU,26610
|
|
7
|
+
pycodex/events.py,sha256=wysYXHLiCHzW3k1yaAuoRTw90NRhHPa3jtY0ANGOqH4,29694
|
|
8
|
+
pycodex/model.py,sha256=3mWXTN-oV2Q50SgQYac45WT5Qk2NSmPTxSWyF-w8TRg,44583
|
|
9
|
+
pycodex/protocol.py,sha256=uzUz_06iA4m9vAoqZeCGiJ4SocKZDzOfCJUU4Bpt5dI,12033
|
|
10
|
+
pycodex/runtime.py,sha256=EM8VRfb7Mq2tj39s26lYbAFDzgzzK7qxtPS8RLenoLQ,23812
|
|
11
|
+
pycodex/portable/__init__.py,sha256=FmspRPmblYuZIVXMpXaxE1uosCaz2hZDpkpOzxDJQic,1084
|
|
12
|
+
pycodex/portable/client.py,sha256=DOxzZljVfN1ynmhqrChX7NsT1IFSFVKzEn1J3wvV3XQ,16038
|
|
13
|
+
pycodex/portable/server.py,sha256=w4YD71Sxb7MD5q57GPuIgx7AoicTv0R9xzX2kAaibPA,7503
|
|
19
14
|
pycodex/prompts/default_base_instructions.md,sha256=D65mcj6bo4CDvVom-D9cbJRJVNquo0NghKt164_fRsg,20923
|
|
20
15
|
pycodex/prompts/models.json,sha256=u-bS5xtI7ZHbrG_nbzrt-xmp5RtQT6YL8PHbd_4XZB4,397650
|
|
21
16
|
pycodex/prompts/permissions/approval_policy/never.md,sha256=QceTG6wjkaJARjYr0HYV1aPnPcpGcrkRUW-smWRr6MQ,120
|
|
@@ -29,45 +24,55 @@ pycodex/prompts/permissions/sandbox_mode/workspace_write.md,sha256=lVN-LwrBbHqlv
|
|
|
29
24
|
pycodex/tools/__init__.py,sha256=UYwmsX_Ckw_YaYQ6TYhUU6w5pxi2qzZoTrq6BAgNErM,1857
|
|
30
25
|
pycodex/tools/agent_tool_schemas.py,sha256=8cL9ml4So0H6IIeK0ZzjAo9bk3VeprDOSYPpIamOqEU,2048
|
|
31
26
|
pycodex/tools/apply_patch_tool.py,sha256=t8XFCGZ7q-s9C1Ty6qkReBRk-QD3ONvcKXLAz9djKRY,13956
|
|
32
|
-
pycodex/tools/base_tool.py,sha256=
|
|
27
|
+
pycodex/tools/base_tool.py,sha256=Oqe-0RgH3mz70YckgBFD-tdvNJ9TQXrb0tuMbdy3bfc,6477
|
|
33
28
|
pycodex/tools/clock_tool.py,sha256=2_RYbBEw4V9_f1L-qZl3hhJ6XNPM_gBDmOlCh1cCAjo,6575
|
|
34
|
-
pycodex/tools/close_agent_tool.py,sha256=
|
|
35
|
-
pycodex/tools/code_mode_manager.py,sha256=
|
|
29
|
+
pycodex/tools/close_agent_tool.py,sha256=uIbCjsQx9MLkjVYheS8ZVf5VVPbC6Iviwox4pneJpmI,2030
|
|
30
|
+
pycodex/tools/code_mode_manager.py,sha256=HUgtXxj3hGj2i4_tsToHLr8mGTV8uIob9vtYAZeLnQc,19166
|
|
36
31
|
pycodex/tools/exec_command_tool.py,sha256=iqRiKaaX-AjG6LjATAMOakHIP0gpCWCj2o8af_8eAiQ,4464
|
|
37
32
|
pycodex/tools/exec_runtime.js,sha256=DR1uocKailTqNWAcJNFJuQgFFMSUzTpT_uQsRaneg2s,3643
|
|
38
33
|
pycodex/tools/exec_tool.py,sha256=tuC21rlhP8CPSYml4XnSDSRV0UPGkQ6aHj0DLIoOOvM,2274
|
|
39
34
|
pycodex/tools/grep_files_tool.py,sha256=Ysw68VKI9OEvUH5haYx8FWuthkHykc1wskbuzjj8gTk,5293
|
|
40
|
-
pycodex/tools/ipython_tool.py,sha256=SKVYpJEwlYjOQZQWbpqvrA-3K9aJTlIG9KM50p5JYUM,4496
|
|
41
35
|
pycodex/tools/list_dir_tool.py,sha256=_U6ouRcVbGHT5mChVyUsiMgDGrFK7EFMFaspPLAHtH8,5337
|
|
42
36
|
pycodex/tools/read_file_tool.py,sha256=YK__uhIVldBjAQega5S_ZuZU5jgP_kLOwr-YhjAmRo4,9735
|
|
43
|
-
pycodex/tools/request_permissions_tool.py,sha256=
|
|
37
|
+
pycodex/tools/request_permissions_tool.py,sha256=nEt3_uw3lmFXyydqcN3PxuKwrEvaRPtfjA_U8nikCtU,3978
|
|
44
38
|
pycodex/tools/request_user_input_tool.py,sha256=_7siHF2p3KiNDFwsTqKKIUw2kPCXMzLaR12PkZ1wdIQ,4050
|
|
45
|
-
pycodex/tools/resume_agent_tool.py,sha256=
|
|
46
|
-
pycodex/tools/
|
|
39
|
+
pycodex/tools/resume_agent_tool.py,sha256=bZvXEUNdc1RVD2N5Msjv63Rni62FQk4gj9LAXK1Vsy8,1613
|
|
40
|
+
pycodex/tools/runtime_services.py,sha256=vZHIHGAeTA-DoEoHulAKvjcfHLXkuK1t3T0Mob9VJ8A,15044
|
|
41
|
+
pycodex/tools/send_input_tool.py,sha256=w63SKM05_e3oXvdaBtL-hk941TvkWKuTUDEqTSyWEMQ,3761
|
|
47
42
|
pycodex/tools/shell_command_tool.py,sha256=US63I5xiV5zfO1Oox2yHUg7F6XoKzmyxtohfaQIsmrw,4216
|
|
48
43
|
pycodex/tools/shell_tool.py,sha256=lqFH2XosfBg7yQKhpB7i4vLGz9sNQtEZihD0rjsmBCQ,4068
|
|
49
|
-
pycodex/tools/spawn_agent_tool.py,sha256=
|
|
50
|
-
pycodex/tools/unified_exec_manager.py,sha256=
|
|
51
|
-
pycodex/tools/update_plan_tool.py,sha256=
|
|
52
|
-
pycodex/tools/view_image_tool.py,sha256=
|
|
53
|
-
pycodex/tools/wait_agent_tool.py,sha256=
|
|
44
|
+
pycodex/tools/spawn_agent_tool.py,sha256=Jx5jYpxsH_CQ3BLkXYPZuIINW5deO_zY8tyw8kZpreY,6208
|
|
45
|
+
pycodex/tools/unified_exec_manager.py,sha256=XPN6PgBnjZ5WFZATNIqpWKUAuw8HMMD7mlfHJQjJQZM,14544
|
|
46
|
+
pycodex/tools/update_plan_tool.py,sha256=xwrSrerw5qfkbFc9Ltx1OZEmD__CWtryOy3UhL0-Jp4,3198
|
|
47
|
+
pycodex/tools/view_image_tool.py,sha256=SCoiIHaQ51oYjYX69MRxjAK9b1P6_wOCIuZqzsC2rj8,4082
|
|
48
|
+
pycodex/tools/wait_agent_tool.py,sha256=9Os6RzzCxIU5KJI5l6MzdwO6QKLNxLFwFXGeDMfYlP4,3828
|
|
54
49
|
pycodex/tools/wait_tool.py,sha256=0_OO_DvMsBhG3oDKZePTOjZTBq1lmWntXAzqIqvebdA,3206
|
|
55
50
|
pycodex/tools/web_search_tool.py,sha256=3ao1IvJw7MwcP35UKLbqrM-nlm5Z-UUFVdEzkJYOV1o,988
|
|
56
51
|
pycodex/tools/write_stdin_tool.py,sha256=jvBDchLLmoDITd7g-ZVeEVXHRhWKkmnjM5laL-53FOM,3609
|
|
57
|
-
pycodex/utils/__init__.py,sha256=
|
|
52
|
+
pycodex/utils/__init__.py,sha256=ih_KyZ2_bajR5YlZ1QMTWOHnuEBda-S3gQ7PwnBtLZQ,453
|
|
58
53
|
pycodex/utils/async_bridge.py,sha256=d21Pjim-nsQbSG5pJddd0WaQ03CzA3w3TINWDmmjWbg,1815
|
|
59
54
|
pycodex/utils/compactor.py,sha256=0tlszw1n54aMEGH6sL1U1dEgFSU5ioYL2NI5uSvHSiM,6119
|
|
60
|
-
pycodex/utils/
|
|
55
|
+
pycodex/utils/compat.py,sha256=QxcI4AQuUD-gE2494qPGezgm0OIX98qSHdAiof1JrlU,3550
|
|
56
|
+
pycodex/utils/crypto.py,sha256=HRCXF26Ft3S8CG2X0YpZwa8GMU9YJ0Loo8Q9PMPMcNw,1249
|
|
57
|
+
pycodex/utils/debug.py,sha256=5XMpWpwFSm6woyx6RGXvN2qL0afRtTQbwlOAv-LotTw,913
|
|
58
|
+
pycodex/utils/doctor.py,sha256=fI66oQqB5zNL7aEpFbiHnzhELyp9XydwMyAGznw5YSE,10616
|
|
61
59
|
pycodex/utils/dotenv.py,sha256=h7ZgvqpEswetqjhtwfiaHyokAHwNKPakizTAHPHz5Ds,1865
|
|
62
60
|
pycodex/utils/event_helpers.py,sha256=pnxL0-nBC7cnOheHPCIfkHqJjMbkJg3C348_EzAVhFA,6342
|
|
63
61
|
pycodex/utils/get_env.py,sha256=L4S8h84tkgxZKvrxY7ezTgePbXepG-yIigUTKeY6uuE,6094
|
|
64
|
-
pycodex/utils/image_utils.py,sha256=
|
|
62
|
+
pycodex/utils/image_utils.py,sha256=OUzUs0Cow4L8Z2np0EBeEUotAqqsCmRmhrV8AxZUXRw,2460
|
|
63
|
+
pycodex/utils/model_metadata.py,sha256=uK3iI4yC7Ge7yN4I1_gQYalQ4MYKddz2qMwsmQb-P80,1337
|
|
65
64
|
pycodex/utils/random_ids.py,sha256=jLTxZZ0MBbRdQOFDFWGVRjWzIo6FKSQ5ADXbQSLPp1s,379
|
|
66
65
|
pycodex/utils/session_persist.py,sha256=v9KhmjUB2yCg55c85i8ZU1BWfc-WEMDPmpT0Rv4K8a8,22489
|
|
67
66
|
pycodex/utils/truncation.py,sha256=5D6vAorT8EgXgjd7ASwtraAyIZdlCR-w5jKZqJxDzho,5446
|
|
67
|
+
pycodex/utils/_aes_gcm/LICENSE,sha256=KvdHagY3sYIK34GldJaRi34sNnGwMVJIIoDhbC9MRu8,2805
|
|
68
|
+
pycodex/utils/_aes_gcm/README.md,sha256=D9XGeewCgU2PVqJCO6WusUs0Mw2FbMnABCqaVktqCnE,3045
|
|
69
|
+
pycodex/utils/_aes_gcm/__init__.py,sha256=p0U1CVy6dQBDAfGvSYG0opn6iP2VGF5rqUUM-mNLJxU,70
|
|
70
|
+
pycodex/utils/_aes_gcm/aes.py,sha256=12p_5O7gX-e-LQ08nNe2CBdP_H4eX3J84LlXaVr9i8A,9269
|
|
71
|
+
pycodex/utils/_aes_gcm/gcm.py,sha256=Z8fYHpnLpqJyTPmjDOZtryqe0xmT_93vscNuJe5ZY-w,2762
|
|
72
|
+
pycodex/utils/_aes_gcm/source-sha256.json,sha256=g9uPWXuA0D9Wq9EGnduyiVanTgi8QWRFW-9T69FG-fc,215
|
|
68
73
|
responses_server/__init__.py,sha256=sx9C88YWqmehASZy24FUMqT14A36doM_rj0MIZtQ9iQ,377
|
|
69
74
|
responses_server/__main__.py,sha256=876xZTqhPeDBD2GKKr8pKX33Af8PhFTosAI8bYQsFgQ,61
|
|
70
|
-
responses_server/app.py,sha256=
|
|
75
|
+
responses_server/app.py,sha256=PE-jWn_hmL5os1xsVL81KwU0kDZHOkZoVdSOK-7x3xQ,8400
|
|
71
76
|
responses_server/config.py,sha256=sCJYGisPHW9Uup26-R9Zv0o9W_kRVt-ETc2MFCVjG90,2795
|
|
72
77
|
responses_server/messages_api.py,sha256=ialAYTMmN0y-uxQB3Y51ukq-kvkSVO84WVLXaqLsKw0,18775
|
|
73
78
|
responses_server/payload_processors.py,sha256=dqPwqHD-FhyiIwjzFEMf2wCtQDxkRyerZzbdqnH1aDE,3561
|
|
@@ -78,21 +83,8 @@ responses_server/trajectory_dump.py,sha256=5_Wy6tslszrqx3j1JeP_boyTbzIicKy8No84P
|
|
|
78
83
|
responses_server/tools/__init__.py,sha256=ivsBSEy0SBUhY-Uea5v1XMLXShkwHdCVl0id-1FwdZg,150
|
|
79
84
|
responses_server/tools/custom_adapter.py,sha256=SnIiNUdomff3APtTriURAC9YCeEdhCDjzGMEYusfUdk,8340
|
|
80
85
|
responses_server/tools/web_search.py,sha256=pnKH9JyTScRehWpZS3HpXRvjWsQvC0QZqxjEOCT4ndg,8936
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
workspace_server/content_views.mjs,sha256=8sbYqAgwYrAE9SMd3bO6jv6DlHwWru1gboID8h2oTLE,16241
|
|
87
|
-
workspace_server/editor.css,sha256=4qBe2ZLqloAFQ2YNyJYvsJelvTHIIQCxpfg4EVTubk8,346450
|
|
88
|
-
workspace_server/editor.mjs,sha256=oZpBsmnA56VIogpbg_NDg8cs4bIQZkuUCtXPJnVLook,4110455
|
|
89
|
-
workspace_server/owned_process.py,sha256=j1cJ89Nm7gS91Zj62kYKabFbb9qhbU7-q1YDsWcVcn8,895
|
|
90
|
-
workspace_server/workspace.html,sha256=r1cBihjnyt8cxjI9xGqTVBs3zboMcoYHemgvwNMpN2A,74728
|
|
91
|
-
workspace_server/workspace_views.py,sha256=acV-SS3Uw-Qy5AI_KV16AowB1R3cbJN4Okk6CDbpPzw,22172
|
|
92
|
-
workspace_server/workspaces.html,sha256=72WEextEEUZeAYCmZ5UcWbg1m7voFezxgL6j48koRuU,15794
|
|
93
|
-
workspace_server/workspaces.py,sha256=hMvGyZtuFshGV3l56AMhGJN0vDOvvVj8iv9-VAJJHhw,22524
|
|
94
|
-
python_codex-0.3.3.dist-info/METADATA,sha256=ucgUraJ7rlCeUstF-FlAE8qiURNuqF-qOw6xKMbYF7M,42715
|
|
95
|
-
python_codex-0.3.3.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
|
|
96
|
-
python_codex-0.3.3.dist-info/entry_points.txt,sha256=vkV2UWCtEKvQNMJuPNjt8HyBKiwp83JyqBatrBNGDp8,80
|
|
97
|
-
python_codex-0.3.3.dist-info/licenses/LICENSE,sha256=0X8ifk312hYAORM4hlzg8wVSEXYKNmiPgWlB1YIy2Nw,10926
|
|
98
|
-
python_codex-0.3.3.dist-info/RECORD,,
|
|
86
|
+
python_codex-0.4.0.dist-info/METADATA,sha256=nb46V9WoOekFjc7X3Ep9U0NNoV7bf7DK8Io12_Uch8s,47415
|
|
87
|
+
python_codex-0.4.0.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
|
|
88
|
+
python_codex-0.4.0.dist-info/entry_points.txt,sha256=sNUVakoVuTrzJH505ZgRTQxmtRRPUHV_EH0i6EbYTyM,45
|
|
89
|
+
python_codex-0.4.0.dist-info/licenses/LICENSE,sha256=0X8ifk312hYAORM4hlzg8wVSEXYKNmiPgWlB1YIy2Nw,10926
|
|
90
|
+
python_codex-0.4.0.dist-info/RECORD,,
|
responses_server/app.py
CHANGED
|
@@ -9,8 +9,11 @@ from dataclasses import replace
|
|
|
9
9
|
from typing import Iterator
|
|
10
10
|
|
|
11
11
|
import uvicorn
|
|
12
|
-
from
|
|
13
|
-
from
|
|
12
|
+
from starlette.applications import Starlette
|
|
13
|
+
from starlette.exceptions import HTTPException
|
|
14
|
+
from starlette.requests import Request
|
|
15
|
+
from starlette.responses import JSONResponse, StreamingResponse
|
|
16
|
+
from starlette.routing import Route
|
|
14
17
|
|
|
15
18
|
from .config import CompatServerConfig
|
|
16
19
|
from .server import ResponseServer
|
|
@@ -22,6 +25,12 @@ def _run_uvicorn_server(server) -> "None":
|
|
|
22
25
|
server.run()
|
|
23
26
|
|
|
24
27
|
|
|
28
|
+
async def _http_exception_response(request: "Request", exc: "HTTPException"):
|
|
29
|
+
return JSONResponse(
|
|
30
|
+
{"detail": exc.detail}, status_code=exc.status_code, headers=exc.headers
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
25
34
|
def _format_sse_event(
|
|
26
35
|
event_name: "str", payload: "typing.Dict[str, object]"
|
|
27
36
|
) -> "bytes":
|
|
@@ -113,33 +122,25 @@ class ManagedResponseServer:
|
|
|
113
122
|
config: "CompatServerConfig",
|
|
114
123
|
session_store=None,
|
|
115
124
|
stream_router=None,
|
|
116
|
-
) -> "
|
|
125
|
+
) -> "Starlette":
|
|
117
126
|
response_server = ResponseServer(
|
|
118
127
|
config,
|
|
119
128
|
session_store=session_store,
|
|
120
129
|
stream_router=stream_router,
|
|
121
130
|
)
|
|
122
|
-
app = FastAPI(title="ResponsesCompat", version="0.1.0")
|
|
123
|
-
app.state.response_server = response_server
|
|
124
131
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
async def health() -> "typing.Dict[str, bool]":
|
|
128
|
-
return {"ok": True}
|
|
132
|
+
async def health(request: "Request"):
|
|
133
|
+
return JSONResponse({"ok": True})
|
|
129
134
|
|
|
130
|
-
|
|
131
|
-
@app.get("/v1/models")
|
|
132
|
-
async def list_models():
|
|
135
|
+
async def list_models(request: "Request"):
|
|
133
136
|
try:
|
|
134
|
-
return response_server.list_models()
|
|
137
|
+
return JSONResponse(response_server.list_models())
|
|
135
138
|
except OutcommingChatError as exc:
|
|
136
139
|
return JSONResponse(
|
|
137
140
|
{"error": {"message": str(exc)}},
|
|
138
141
|
status_code=502,
|
|
139
142
|
)
|
|
140
143
|
|
|
141
|
-
@app.post("/responses")
|
|
142
|
-
@app.post("/v1/responses")
|
|
143
144
|
async def responses(request: "Request"):
|
|
144
145
|
try:
|
|
145
146
|
request_body = await request.json()
|
|
@@ -174,6 +175,18 @@ class ManagedResponseServer:
|
|
|
174
175
|
},
|
|
175
176
|
)
|
|
176
177
|
|
|
178
|
+
app = Starlette(
|
|
179
|
+
routes=[
|
|
180
|
+
Route("/health", health, methods=["GET"]),
|
|
181
|
+
Route("/healthz", health, methods=["GET"]),
|
|
182
|
+
Route("/models", list_models, methods=["GET"]),
|
|
183
|
+
Route("/v1/models", list_models, methods=["GET"]),
|
|
184
|
+
Route("/responses", responses, methods=["POST"]),
|
|
185
|
+
Route("/v1/responses", responses, methods=["POST"]),
|
|
186
|
+
],
|
|
187
|
+
exception_handlers={HTTPException: _http_exception_response},
|
|
188
|
+
)
|
|
189
|
+
app.state.response_server = response_server
|
|
177
190
|
return app
|
|
178
191
|
|
|
179
192
|
def __init__(self, config: "CompatServerConfig") -> "None":
|