diff --git a/packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/base_agent_instrumentor.py b/packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/base_agent_instrumentor.py index 372786b32c..bcf8b03067 100644 --- a/packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/base_agent_instrumentor.py +++ b/packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/base_agent_instrumentor.py @@ -9,11 +9,20 @@ from opentelemetry.semconv.ai import SpanAttributes, TraceloopSpanKindValues -V9_MODULE_NAME = "llama_index.agent.types" -V10_MODULE_NAME = "llama_index.core.agent.types" -V10_LEGACY_MODULE_NAME = "llama_index.legacy.agent.types" - -CLASS_NAME = "BaseAgent" +TO_INSTRUMENT = [ + { + "class": "AgentRunner", + "v9_module": "llama_index.agent.runner.base", + "v10_module": "llama_index.core.agent.runner.base", + "v10_legacy_module": "llama_index.legacy.agent.runner.base", + }, + { + "class": "OpenAIAssistantAgent", + "v9_module": "llama_index.agent.openai_assistant_agent", + "v10_module": "llama_index.agent.openai.openai_assistant_agent", + "v10_legacy_module": "llama_index.legacy.agent.openai_assistant_agent", + }, +] class BaseAgentInstrumentor: @@ -21,20 +30,21 @@ def __init__(self, tracer): self._tracer = tracer def instrument(self): - try: - package_version("llama-index-core") - self._instrument_module(V10_MODULE_NAME) - self._instrument_module(V10_LEGACY_MODULE_NAME) + for module in TO_INSTRUMENT: + try: + package_version("llama-index-core") + self._instrument_module(module["v10_module"], module["class"]) + self._instrument_module(module["v10_legacy_module"], module["class"]) - except PackageNotFoundError: - self._instrument_module(V9_MODULE_NAME) + except PackageNotFoundError: + self._instrument_module(module["v9_module"], module["class"]) - def _instrument_module(self, module_name): + def _instrument_module(self, module_name, class_name): wrap_function_wrapper( - module_name, f"{CLASS_NAME}._query", query_wrapper(self._tracer) + module_name, f"{class_name}.chat", query_wrapper(self._tracer) ) wrap_function_wrapper( - module_name, f"{CLASS_NAME}._aquery", aquery_wrapper(self._tracer) + module_name, f"{class_name}.achat", aquery_wrapper(self._tracer) ) diff --git a/packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/base_tool_instrumentor.py b/packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/base_tool_instrumentor.py index 266f622ffd..142d5196cb 100644 --- a/packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/base_tool_instrumentor.py +++ b/packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/base_tool_instrumentor.py @@ -9,11 +9,20 @@ from opentelemetry.semconv.ai import SpanAttributes, TraceloopSpanKindValues -V9_MODULE_NAME = "llama_index.tools.types" -V10_MODULE_NAME = "llama_index.core.tools.types" -V10_LEGACY_MODULE_NAME = "llama_index.legacy.tools.types" - -CLASS_NAME = "AsyncBaseTool" +TO_INSTRUMENT = [ + { + "class": "FunctionTool", + "v9_module": "llama_index.tools.function_tool", + "v10_module": "llama_index.core.tools.function_tool", + "v10_legacy_module": "llama_index.legacy.tools.function_tool", + }, + { + "class": "QueryEngineTool", + "v9_module": "llama_index.tools.query_engine", + "v10_module": "llama_index.core.tools.query_engine", + "v10_legacy_module": "llama_index.legacy.tools.query_engine", + }, +] class BaseToolInstrumentor: @@ -21,20 +30,21 @@ def __init__(self, tracer): self._tracer = tracer def instrument(self): - try: - package_version("llama-index-core") - self._instrument_module(V10_MODULE_NAME) - self._instrument_module(V10_LEGACY_MODULE_NAME) + for module in TO_INSTRUMENT: + try: + package_version("llama-index-core") + self._instrument_module(module["v10_module"], module["class"]) + self._instrument_module(module["v10_legacy_module"], module["class"]) - except PackageNotFoundError: - self._instrument_module(V9_MODULE_NAME) + except PackageNotFoundError: + self._instrument_module(module["v9_module"], module["class"]) - def _instrument_module(self, module_name): + def _instrument_module(self, module_name, class_name): wrap_function_wrapper( - module_name, f"{CLASS_NAME}.call", query_wrapper(self._tracer) + module_name, f"{class_name}.call", query_wrapper(self._tracer) ) wrap_function_wrapper( - module_name, f"{CLASS_NAME}.acall", aquery_wrapper(self._tracer) + module_name, f"{class_name}.acall", aquery_wrapper(self._tracer) ) diff --git a/packages/opentelemetry-instrumentation-llamaindex/poetry.lock b/packages/opentelemetry-instrumentation-llamaindex/poetry.lock index 9dc3387d9b..41e52c088a 100644 --- a/packages/opentelemetry-instrumentation-llamaindex/poetry.lock +++ b/packages/opentelemetry-instrumentation-llamaindex/poetry.lock @@ -935,23 +935,62 @@ optional = false python-versions = ">=3.7" files = [ {file = "greenlet-3.0.3-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:9da2bd29ed9e4f15955dd1595ad7bc9320308a3b766ef7f837e23ad4b4aac31a"}, + {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d353cadd6083fdb056bb46ed07e4340b0869c305c8ca54ef9da3421acbdf6881"}, + {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dca1e2f3ca00b84a396bc1bce13dd21f680f035314d2379c4160c98153b2059b"}, + {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3ed7fb269f15dc662787f4119ec300ad0702fa1b19d2135a37c2c4de6fadfd4a"}, {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd4f49ae60e10adbc94b45c0b5e6a179acc1736cf7a90160b404076ee283cf83"}, {file = "greenlet-3.0.3-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:73a411ef564e0e097dbe7e866bb2dda0f027e072b04da387282b02c308807405"}, + {file = "greenlet-3.0.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:7f362975f2d179f9e26928c5b517524e89dd48530a0202570d55ad6ca5d8a56f"}, + {file = "greenlet-3.0.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:649dde7de1a5eceb258f9cb00bdf50e978c9db1b996964cd80703614c86495eb"}, + {file = "greenlet-3.0.3-cp310-cp310-win_amd64.whl", hash = "sha256:68834da854554926fbedd38c76e60c4a2e3198c6fbed520b106a8986445caaf9"}, {file = "greenlet-3.0.3-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:b1b5667cced97081bf57b8fa1d6bfca67814b0afd38208d52538316e9422fc61"}, + {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:52f59dd9c96ad2fc0d5724107444f76eb20aaccb675bf825df6435acb7703559"}, + {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:afaff6cf5200befd5cec055b07d1c0a5a06c040fe5ad148abcd11ba6ab9b114e"}, + {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fe754d231288e1e64323cfad462fcee8f0288654c10bdf4f603a39ed923bef33"}, {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2797aa5aedac23af156bbb5a6aa2cd3427ada2972c828244eb7d1b9255846379"}, {file = "greenlet-3.0.3-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b7f009caad047246ed379e1c4dbcb8b020f0a390667ea74d2387be2998f58a22"}, + {file = "greenlet-3.0.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:c5e1536de2aad7bf62e27baf79225d0d64360d4168cf2e6becb91baf1ed074f3"}, + {file = "greenlet-3.0.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:894393ce10ceac937e56ec00bb71c4c2f8209ad516e96033e4b3b1de270e200d"}, + {file = "greenlet-3.0.3-cp311-cp311-win_amd64.whl", hash = "sha256:1ea188d4f49089fc6fb283845ab18a2518d279c7cd9da1065d7a84e991748728"}, {file = "greenlet-3.0.3-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:70fb482fdf2c707765ab5f0b6655e9cfcf3780d8d87355a063547b41177599be"}, + {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d4d1ac74f5c0c0524e4a24335350edad7e5f03b9532da7ea4d3c54d527784f2e"}, + {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:149e94a2dd82d19838fe4b2259f1b6b9957d5ba1b25640d2380bea9c5df37676"}, + {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:15d79dd26056573940fcb8c7413d84118086f2ec1a8acdfa854631084393efcc"}, {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:881b7db1ebff4ba09aaaeae6aa491daeb226c8150fc20e836ad00041bcb11230"}, {file = "greenlet-3.0.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fcd2469d6a2cf298f198f0487e0a5b1a47a42ca0fa4dfd1b6862c999f018ebbf"}, + {file = "greenlet-3.0.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:1f672519db1796ca0d8753f9e78ec02355e862d0998193038c7073045899f305"}, + {file = "greenlet-3.0.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:2516a9957eed41dd8f1ec0c604f1cdc86758b587d964668b5b196a9db5bfcde6"}, + {file = "greenlet-3.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:bba5387a6975598857d86de9eac14210a49d554a77eb8261cc68b7d082f78ce2"}, {file = "greenlet-3.0.3-cp37-cp37m-macosx_11_0_universal2.whl", hash = "sha256:5b51e85cb5ceda94e79d019ed36b35386e8c37d22f07d6a751cb659b180d5274"}, + {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:daf3cb43b7cf2ba96d614252ce1684c1bccee6b2183a01328c98d36fcd7d5cb0"}, + {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:99bf650dc5d69546e076f413a87481ee1d2d09aaaaaca058c9251b6d8c14783f"}, + {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2dd6e660effd852586b6a8478a1d244b8dc90ab5b1321751d2ea15deb49ed414"}, {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e3391d1e16e2a5a1507d83e4a8b100f4ee626e8eca43cf2cadb543de69827c4c"}, {file = "greenlet-3.0.3-cp37-cp37m-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e1f145462f1fa6e4a4ae3c0f782e580ce44d57c8f2c7aae1b6fa88c0b2efdb41"}, + {file = "greenlet-3.0.3-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:1a7191e42732df52cb5f39d3527217e7ab73cae2cb3694d241e18f53d84ea9a7"}, + {file = "greenlet-3.0.3-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:0448abc479fab28b00cb472d278828b3ccca164531daab4e970a0458786055d6"}, + {file = "greenlet-3.0.3-cp37-cp37m-win32.whl", hash = "sha256:b542be2440edc2d48547b5923c408cbe0fc94afb9f18741faa6ae970dbcb9b6d"}, + {file = "greenlet-3.0.3-cp37-cp37m-win_amd64.whl", hash = "sha256:01bc7ea167cf943b4c802068e178bbf70ae2e8c080467070d01bfa02f337ee67"}, {file = "greenlet-3.0.3-cp38-cp38-macosx_11_0_universal2.whl", hash = "sha256:1996cb9306c8595335bb157d133daf5cf9f693ef413e7673cb07e3e5871379ca"}, + {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3ddc0f794e6ad661e321caa8d2f0a55ce01213c74722587256fb6566049a8b04"}, + {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c9db1c18f0eaad2f804728c67d6c610778456e3e1cc4ab4bbd5eeb8e6053c6fc"}, + {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7170375bcc99f1a2fbd9c306f5be8764eaf3ac6b5cb968862cad4c7057756506"}, {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6b66c9c1e7ccabad3a7d037b2bcb740122a7b17a53734b7d72a344ce39882a1b"}, {file = "greenlet-3.0.3-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:098d86f528c855ead3479afe84b49242e174ed262456c342d70fc7f972bc13c4"}, + {file = "greenlet-3.0.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:81bb9c6d52e8321f09c3d165b2a78c680506d9af285bfccbad9fb7ad5a5da3e5"}, + {file = "greenlet-3.0.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:fd096eb7ffef17c456cfa587523c5f92321ae02427ff955bebe9e3c63bc9f0da"}, + {file = "greenlet-3.0.3-cp38-cp38-win32.whl", hash = "sha256:d46677c85c5ba00a9cb6f7a00b2bfa6f812192d2c9f7d9c4f6a55b60216712f3"}, + {file = "greenlet-3.0.3-cp38-cp38-win_amd64.whl", hash = "sha256:419b386f84949bf0e7c73e6032e3457b82a787c1ab4a0e43732898a761cc9dbf"}, {file = "greenlet-3.0.3-cp39-cp39-macosx_11_0_universal2.whl", hash = "sha256:da70d4d51c8b306bb7a031d5cff6cc25ad253affe89b70352af5f1cb68e74b53"}, + {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:086152f8fbc5955df88382e8a75984e2bb1c892ad2e3c80a2508954e52295257"}, + {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d73a9fe764d77f87f8ec26a0c85144d6a951a6c438dfe50487df5595c6373eac"}, + {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b7dcbe92cc99f08c8dd11f930de4d99ef756c3591a5377d1d9cd7dd5e896da71"}, {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1551a8195c0d4a68fac7a4325efac0d541b48def35feb49d803674ac32582f61"}, {file = "greenlet-3.0.3-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:64d7675ad83578e3fc149b617a444fab8efdafc9385471f868eb5ff83e446b8b"}, + {file = "greenlet-3.0.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b37eef18ea55f2ffd8f00ff8fe7c8d3818abd3e25fb73fae2ca3b672e333a7a6"}, + {file = "greenlet-3.0.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:77457465d89b8263bca14759d7c1684df840b6811b2499838cc5b040a8b5b113"}, + {file = "greenlet-3.0.3-cp39-cp39-win32.whl", hash = "sha256:57e8974f23e47dac22b83436bdcf23080ade568ce77df33159e019d161ce1d1e"}, + {file = "greenlet-3.0.3-cp39-cp39-win_amd64.whl", hash = "sha256:c5ee858cfe08f34712f548c3c363e807e7186f03ad7a5039ebadb29e8c6be067"}, {file = "greenlet-3.0.3.tar.gz", hash = "sha256:43374442353259554ce33599da8b692d5aa96f8976d567d4badf263371fbe491"}, ] @@ -3000,6 +3039,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -4145,4 +4185,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<3.12" -content-hash = "e5bf604b557b79774472ad1ccdb2d43a0577e1d03b48c4b286fa9af94e8c97ff" +content-hash = "79bbdfc331db709c88474fa68a7233143f58d17a24cdd17e70802ea8723f5069" diff --git a/packages/opentelemetry-instrumentation-llamaindex/pyproject.toml b/packages/opentelemetry-instrumentation-llamaindex/pyproject.toml index 7a93dce359..9c0b97ab4c 100644 --- a/packages/opentelemetry-instrumentation-llamaindex/pyproject.toml +++ b/packages/opentelemetry-instrumentation-llamaindex/pyproject.toml @@ -44,6 +44,8 @@ llama-index-postprocessor-cohere-rerank = "^0.1.2" opentelemetry-instrumentation-openai = {path="../opentelemetry-instrumentation-openai", develop=true} opentelemetry-instrumentation-cohere = {path="../opentelemetry-instrumentation-cohere", develop=true} opentelemetry-instrumentation-chromadb = {path="../opentelemetry-instrumentation-chromadb", develop=true} +sqlalchemy = "^2.0.27" +llama-index-agent-openai = "^0.1.5" [build-system] diff --git a/packages/opentelemetry-instrumentation-llamaindex/tests/cassettes/test_agents/test_agent_with_query_tool.yaml b/packages/opentelemetry-instrumentation-llamaindex/tests/cassettes/test_agents/test_agent_with_query_tool.yaml new file mode 100644 index 0000000000..ebce0f026b --- /dev/null +++ b/packages/opentelemetry-instrumentation-llamaindex/tests/cassettes/test_agents/test_agent_with_query_tool.yaml @@ -0,0 +1,1441 @@ +interactions: +- request: + body: '{"model": "gpt-4-1106-preview", "file_ids": [], "instructions": "You are + a bot designed to answer questions about cities (both unstructured and structured + data)", "name": "City bot", "tools": [{"type": "function", "function": {"name": + "sql_tool", "description": "Useful for translating a natural language query + into a SQL query over a table containing: city_stats, containing the population/country + of each city", "parameters": {"type": "object", "properties": {"input": {"title": + "Input", "type": "string"}}, "required": ["input"]}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '536' + content-type: + - application/json + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: POST + uri: https://api.openai.com/v1/assistants + response: + body: + string: !!binary | + H4sIAAAAAAAAA2RSTWsbMRC9+1cMe0rBpnZaYuJbmksCgVJCD3UJZnY1u1Yjj2RpFGOC/3sZeTFr + +yKh9968+dB8jgAqa6oFVJiSrPLztx/ty+vTw8/wvnOpxuV78/SwXFZjFfr6HzXSi20SZDkSTSQU + MitUcjaf3k9v5/O728IxbkhDHq3sofZ9hKHURBvEeq4WwNm5Am+8IafqLsjk+2Q2m95NQqQPS7tj + nOUkMTcal1T3x2fASIBqDYaS7ZgMiAfktKMI20ypqAFrnwUaK5YS3NRe1pB7txzJALKBwdOg4Jdj + UvHeaba/IwCAz3IqvA+lszZzKaiIC3NCFif1YBJp61ZqedJfzaP6najNDlofQSJyciiWO0BglBzR + gUPuMnak/cU9WNaO4fXXSw/4D4qAIFg7gsazoGXL3UL736+SoKTxAAdZEwQfsiby/LXxmUVtWiBs + 1iVqWG7AiBsSiumsxcFQ+l0ZD7kQfaCo87+IKh8bslzBamjFFcfnohhf8X3CJNFyV53Rh8HrcFZK + pG22kczpVy8KGWBvo0u7463nW9mP1jpaWVNW5IhsSFAXSBs6jA7/AQAA//8DAIqn3+xnAwAA + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e38c9a60e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:02 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + path=/; expires=Tue, 27-Feb-24 10:26:02 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '177' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_dd526896e76e0e18ef7705ac0ec72a82 + status: + code: 200 + message: OK +- request: + body: '{}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '2' + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: POST + uri: https://api.openai.com/v1/threads + response: + body: + string: !!binary | + H4sIAAAAAAAAA6rmUlBQykxRslJQKskoSk1Mic+scA5JtkjLy82wSHJzdk4yy85y8S8vDVPSASnN + T8pKTS5BKIeIJhelJpakpsQngmQMzQ0sDYzMzc2MwHK5qSWJKYkliUpWCtW1XLUAAAAA//8DAAIf + 5q1xAAAA + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e3b0d350e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:02 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '82' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_b4ec69ecb484151164ee39e56967ddaa + status: + code: 200 + message: OK +- request: + body: '{"content": "Which city has the highest population?", "role": "user", "file_ids": + []}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '85' + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: POST + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/messages + response: + body: + string: !!binary | + H4sIAAAAAAAAA1yPzU7DMBCE73mKVc4ItT0kpRcOQYifSkUIygFVkRNvYhfHDvG6pKr67sh2yYHL + SjvzeWd8SgBSydMVpJ1ty23zuB7nvNHvz0+HvHlpH9zmdf2dpVeeM9Uea/IsiQEZv+7QWtZidOsB + GSEvmSfm+exmtsjzbBE8Zq20xDSVIUs7pYIe70RxWsbirV42uhPL6r4oquxrf7f5cduYMjj978Zg + FPrnzuJwaWI0ofY1PhMAgFOYPu7YB5RwpIBG1W+riQJID0y5AH4IWQuoJR1BMAskEIRsBVqC3vRO + MZJG306n/E+1NhRk6/N3F+ec/M1dqNhIhaXkkQlKh8Q4I+abnJPzLwAAAP//AwA6Hok1mQEAAA== + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e3ca84d0e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:02 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '105' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_c70f0567d796d7d427105ad0a07efdd6 + status: + code: 200 + message: OK +- request: + body: '{"assistant_id": "asst_uI3BfLSHAOpkwlsbaZkcHAZZ", "instructions": null}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '71' + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: POST + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/runs + response: + body: + string: !!binary | + H4sIAAAAAAAAA2RTXU/cMBB8v1+xylMrHS30EFx5AyoE1SFUQSv1KhRtnE3O4LN96zXHh/jvlZ1w + CtxLIs/Ozs7Em5cRQKHr4ggKjrZ8buPP49l0fzK5jCezc30zn15erFZnxTjxXHVHShJXFkxYf+Fo + u4piQqG6xFTdO9z9vvvt8PBgkmsYgg6CVspuDoYgZbyYnDSz6/PjK3+/NqHC+b06P57PO7lOvue/ + HR5Pb9S0scvFtDo7Pa0O7u9+XK3jn64jCEoMib6KFKneoLyxZaMxGaVHr5nC0Ox00ptVaBUZs9XT + oN4GlVt6Q9sDmFZRc4KVaGeHJYNBSmJ2PESXriaTzLdedvZ39vZ2D3Y804OmdRdE2yAcs1oO+ddF + QCZAqJxATUG3lmoQB2jDmhhWkUJmA1YuCigtmgJ8qpwsIPZqkakGtDUMjjUKfu5vwTmTpv0bAQC8 + 5GeCnzwlD020XbzxW2WDHG3YAIXFZeaHlSmT5IYPUNQUFGvfNxW/AzXRQOMYhNEGg6JtCwgWJTIa + MGjbiC2lfPwE2qbEcP1r1gPugRgQBCtDoJwV1Fbb9ijlfyrTkoTxAAdZEHjnYxrk7FflopUk0wCh + WuSuoV2PjEsS4vAu4uCj9L/IeFjz7Dxx+v4fuvLF+ihbcBLUYrLiRWaMt+r9wCCsbVu8K78OTq/v + rLxt5uZWPxgZYLejj3LdOz1vu39CGyp1nVekQ5YkmBYoBcqDixiwpX7VR6//AQAA//8DAAb6ZP9u + BAAA + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e3e7c1d0e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:03 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '249' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_0afec7be8fe43fe902b133dbdf69c54a + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: GET + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/runs/run_zguJAL8433MuBLHiTZ8MIqqF + response: + body: + string: !!binary | + H4sIAAAAAAAAA3RT0U7bQBB8z1es/NRKoYUGQcpboEJQBaEKWqmpkLW2187B5e6yt0dIEf9e3dmJ + TKK+2LqZ2dkd3/p1AJCpKjuDjIPJ/zbh+2Q6Ph6NbsL59Erdz8Y318vlZTaMOls8UilRK3MmrD5x + MC1TMqFQlWNkj04Pvx5+OT09GSUOvVde0Eje9kHvJQ/Xo/N6enc1uXVPK+0LnD2VV5PZrLVr7Tv9 + 5vBycV+Oa7OYj4vLi4vi5Onx2+0q/GorvKAEH+XK5I5tw+T9luL/zUYvTjH5PjcedVyJpiStN5Um + aJ3wGtU+WNqF0yR7ONMyKI5wKcqaPqXRS07MlvvowlakY47GycHxwdHR4cmBY3pWtGrjKOOFQ3JL + eX/bAMgECIUVqMirxlAFYgGNXxHDMpBPasDCBoFSiSIPHworcwidW2CqAE0FvWOFgh+7C7FWx25/ + BgAAr+kZ4bWjOEMdTBtvuGG2yNlWDZAZXCS9X+o8Wm71AFlFvmTluqLsp6c6aKgtgzAar1GUaQDB + oARGDRpNE7ChmI/XoExMDHc/ph1gn4kBQbDQBKU1gsoo05zF/Os87osf9nCQOYGzLsRG1nwubTAS + bWogLOepqj+uQ8YFCbF/F7H3Ubq/ZdjnHFtHHL//TlW6WBdkD46GSnRyvE6K4R7fNfTCyjTZO/qt + d3p7N8pmM7e3ujNID3sY7Nq17/h8aP8JpSlXVVqRFlmQYFygGCg1zoLHhrpVH7z9AwAA//8DAMLD + W7V5BAAA + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e41595d0e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:03 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '92' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_b7959fe87128dac0cb86b1b97152ce0f + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: GET + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/runs/run_zguJAL8433MuBLHiTZ8MIqqF + response: + body: + string: !!binary | + H4sIAAAAAAAAA3RT0U7bQBB8z1es/NRKoYUGQcpboEJQBaEKWqmpkLW2187B5e6yt0dIEf9e3dmJ + TKK+2LqZ2dkd3/p1AJCpKjuDjIPJ/zbh+2Q6Ph6NbsL59Erdz8Y318vlZTaMOls8UilRK3MmrD5x + MC1TMqFQlWNkj04Pvx5+OT09GSUOvVde0Eje9kHvJQ/Xo/N6enc1uXVPK+0LnD2VV5PZrLVr7Tv9 + 5vBycV+Oa7OYj4vLi4vi5Onx2+0q/GorvKAEH+XK5I5tw+T9luL/zUYvTjH5PjcedVyJpiStN5Um + aJ3wGtU+WNqF0yR7ONMyKI5wKcqaPqXRS07MlvvowlakY47GycHxwdHR4cmBY3pWtGrjKOOFQ3JL + eX/bAMgECIUVqMirxlAFYgGNXxHDMpBPasDCBoFSiSIPHworcwidW2CqAE0FvWOFgh+7C7FWx25/ + BgAAr+kZ4bWjOEMdTBtvuGG2yNlWDZAZXCS9X+o8Wm71AFlFvmTluqLsp6c6aKgtgzAar1GUaQDB + oARGDRpNE7ChmI/XoExMDHc/ph1gn4kBQbDQBKU1gsoo05zF/Os87osf9nCQOYGzLsRG1nwubTAS + bWogLOepqj+uQ8YFCbF/F7H3Ubq/ZdjnHFtHHL//TlW6WBdkD46GSnRyvE6K4R7fNfTCyjTZO/qt + d3p7N8pmM7e3ujNID3sY7Nq17/h8aP8JpSlXVVqRFlmQYFygGCg1zoLHhrpVH7z9AwAA//8DAMLD + W7V5BAAA + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e43ee2b0e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:04 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '38' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_c54b2e64db9374bb1b8c0f12dcd632dc + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: GET + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/runs/run_zguJAL8433MuBLHiTZ8MIqqF + response: + body: + string: !!binary | + H4sIAAAAAAAAA3RT0U7bQBB8z1es/NRKoYUGQcpboEJQBaEKWqmpkLW2187B5e6yt0dIEf9e3dmJ + TKK+2LqZ2dkd3/p1AJCpKjuDjIPJ/zbh+2Q6Ph6NbsL59Erdz8Y318vlZTaMOls8UilRK3MmrD5x + MC1TMqFQlWNkj04Pvx5+OT09GSUOvVde0Eje9kHvJQ/Xo/N6enc1uXVPK+0LnD2VV5PZrLVr7Tv9 + 5vBycV+Oa7OYj4vLi4vi5Onx2+0q/GorvKAEH+XK5I5tw+T9luL/zUYvTjH5PjcedVyJpiStN5Um + aJ3wGtU+WNqF0yR7ONMyKI5wKcqaPqXRS07MlvvowlakY47GycHxwdHR4cmBY3pWtGrjKOOFQ3JL + eX/bAMgECIUVqMirxlAFYgGNXxHDMpBPasDCBoFSiSIPHworcwidW2CqAE0FvWOFgh+7C7FWx25/ + BgAAr+kZ4bWjOEMdTBtvuGG2yNlWDZAZXCS9X+o8Wm71AFlFvmTluqLsp6c6aKgtgzAar1GUaQDB + oARGDRpNE7ChmI/XoExMDHc/ph1gn4kBQbDQBKU1gsoo05zF/Os87osf9nCQOYGzLsRG1nwubTAS + bWogLOepqj+uQ8YFCbF/F7H3Ubq/ZdjnHFtHHL//TlW6WBdkD46GSnRyvE6K4R7fNfTCyjTZO/qt + d3p7N8pmM7e3ujNID3sY7Nq17/h8aP8JpSlXVVqRFlmQYFygGCg1zoLHhrpVH7z9AwAA//8DAMLD + W7V5BAAA + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e46098b0e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:04 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '42' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_7a24ee7542ac105e7db357f110d9d2dd + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: GET + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/runs/run_zguJAL8433MuBLHiTZ8MIqqF + response: + body: + string: !!binary | + H4sIAAAAAAAAA3xU71PaQBD9zl+xk0/tjFotjlK+KcpAB0sr6IxUJ7NJlnBy3IW7PfHH8L93LgkQ + RPst997u3tvdd3mrAQQiCZoQGKfC19T9POs1juv1K3fe64jhqHHVnc/bwZ6P09EjxexjeWIIkwPj + VMHEhpApCdGzR6eHPw6/n56e1HMOrRWWUXFY3IPWcui69fNxb9A562fThbQRjqZx52w0KsoV5cv4 + 1eG5NYwbYzWbNKJ2qxWdTB8v+gt3W2RYRnY2b4PmThiyIcYstFrT5jN99JwV8RuuUS+5GFVMUq4y + lZMyx8codsFYzzJJvIOXipKVoia81QB8my8ZecnWRTPBIWstQ+04c2xz2fAxtcr3FTweo5Qe/Vui + sObzmGKKPijsdH5PD7tPr+NBdnt7Ov3VbsU3i6Fpl7etipayxk5tRrhm12hz6xqAQOGsaGcuc8Fb + ed4IJnUzUnkHwdt9IFTm+D5o3geDy95lawix4JfQb9Ie+E9oX/evKiD0ry8ur+H8rhqY6cxJ9ILg + 4nLQgl73qjuEo/tgGVRuX9befz3UVqdlviSJlkMyRpvq6mY6IenlphnvH+8fHR2e7GeGngQtCmMJ + Zdm4fCB5W3faARoChEgzJGRFqigB1oDKLsjA3JHNowEj7di3IsjCl0jzBFxZzRlKAFUClWOCjF/L + 56F1ZeEbM3y2t4939r99BQnZ2IisTApuLI2dhLE2wAaV9RNXKSAoZGdQgkSVOkzJ92deQCjfMQz+ + 9EpAP5EBBMZIEsRaMQolVNqsrHKvggNPCDar/RZrp9iXGQNhPMmzqnIzNDgjJmPf2XI9lPLftWXl + zOiMjJ//rplzc+7AvqBgmVfs5hF7O/zqUbMRKg226GXVkltSVv+IrWdcEVLBHna8vFx7+aH4OwlJ + oUhyixTIjBi9gXxDhd+dxZRKq9eW/wAAAP//AwCml2puBwYAAA== + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e482d1f0e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:04 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '39' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_37c4d841ed91a3a7235909c440920d64 + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Given an input question, first + create a syntactically correct sqlite query to run, then look at the results + of the query and return the answer. You can order the results by a relevant + column to return the most interesting examples in the database.\n\nNever query + for all the columns from a specific table, only ask for a few relevant columns + given the question.\n\nPay attention to use only the column names that you can + see in the schema description. Be careful to not query for columns that do not + exist. Pay attention to which column is in which table. Also, qualify column + names with the table name when needed. You are required to use the following + format, each taking one line:\n\nQuestion: Question here\nSQLQuery: SQL Query + to run\nSQLResult: Result of the SQLQuery\nAnswer: Final answer here\n\nOnly + use tables listed below.\nTable ''city_stats'' has columns: city_name (VARCHAR(16)), + population (INTEGER), country (VARCHAR(16)), and foreign keys: .\n\nQuestion: + SELECT city_stats.city FROM city_stats ORDER BY city_stats.population DESC LIMIT + 1\nSQLQuery: "}], "model": "gpt-3.5-turbo", "stream": false, "temperature": + 0.1}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1174' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: !!binary | + H4sIAAAAAAAAA1RRwU7jMBS85yuefG5QWjZtmttSggQqApLuYbVZRW7qJmadZ8t+UUGo/47cpoH1 + 4Ume8YzmjT8CACZ3LAVWt5zqzqgwOegNZa+rSBbNr7vDnJ6Tt5eolze5VA9s4hV6+ypquqiuat0Z + JUhqPNO1FZyEd50uomU0Wyzm8Yno9E4oL2sMhddXcUi93eowms7iQdlqWQvHUvgTAAB8nKbPiDvx + xlKIJhekE87xRrB0fATArFYeYdw56YgjsckXWWskgafYRbbOVhuoJb1XyDsBd/nT4/nqiJODp/w2 + y+HmNxhtesX9bnCbFStY3z/eb2BaYvGyzoXrFaVQ4mhUYjieEouWY9NyWeJPdAdhU7ggbIh1HPdR + ujFWb/3u2Cs14nuJ0rWVFdxp9NkdaXOWHwOAv6fe+v+qYMbqzlBF+p9Abzi7HnpjX1/1jU0GkjRx + 9Q2Pk2BIyNy7I9FVe4mNsMbKc417UyXzaTznyx88YsEx+AQAAP//AwDggum3UAIAAA== + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e4a0c980d61-MXP + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:05 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=JmNIC38qYbbx7T.to4DNMM5B1XUnQCKuQLJ4rkRh0do-1709027765-1.0-AfP5PYbFIwkji/HOjzaGWShxaZFaOOoNZQIVNTdk2k7NHZy5S+gUsGWZUsUgKxivAkX6gTprQawkXFssu/71pwc=; + path=/; expires=Tue, 27-Feb-24 10:26:05 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=jt5ANKAYaA8DspJ9g4Q.p5QFXwneCuw1CXQ.i4c1bsE-1709027765767-0.0-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-3.5-turbo-0125 + openai-organization: + - traceloop + openai-processing-ms: + - '758' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '5000' + x-ratelimit-limit-tokens: + - '160000' + x-ratelimit-remaining-requests: + - '4999' + x-ratelimit-remaining-tokens: + - '159720' + x-ratelimit-reset-requests: + - 12ms + x-ratelimit-reset-tokens: + - 105ms + x-request-id: + - req_f44662c7e6ad83b5862a9ee514a9b02c + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Given an input question, synthesize + a response from the query results.\nQuery: SELECT city_stats.city FROM city_stats + ORDER BY city_stats.population DESC LIMIT 1\nSQL: SELECT city_name FROM city_stats + ORDER BY population DESC LIMIT 1\nSQL Response: [(''Tokyo'',)]\nResponse: "}], + "model": "gpt-3.5-turbo", "stream": false, "temperature": 0.1}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '383' + content-type: + - application/json + cookie: + - __cf_bm=JmNIC38qYbbx7T.to4DNMM5B1XUnQCKuQLJ4rkRh0do-1709027765-1.0-AfP5PYbFIwkji/HOjzaGWShxaZFaOOoNZQIVNTdk2k7NHZy5S+gUsGWZUsUgKxivAkX6gTprQawkXFssu/71pwc=; + _cfuvid=jt5ANKAYaA8DspJ9g4Q.p5QFXwneCuw1CXQ.i4c1bsE-1709027765767-0.0-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: !!binary | + H4sIAAAAAAAAA1SQzW7CMBCE73mKlc+AEgrh59hDT1WlqrSqVFWREzaxi+O1shtRinj3yoGCevFh + Ps9oZo8JgLJbtQZVGS1VG9x4uadNP23c++PrT721zNOX1fNbrUvz8HSvRtFB5RdW8ueaVNQGh2LJ + n3HVoRaMqdkiXaXTxSLPB9DSFl20NUHGd5P5WPqupHGaTecXpyFbIas1fCQAAMfhjR39Fr/VGtLR + n9Iis25Qra+fAFRHLipKM1sW7UWNbrAiL+iH2huDUFk5wN6KATEIxjYGWSBQ6J2OW8D6gcR/BYsW + BtGlQ7AMG9odaKIu2adrKUdN6KiMA3zv3FWvrbdsig41k48FWCic7acE4HMY3//bo0JHbZBCaIc+ + BuaLc5y6nfsGs9kFCol2N32ZJZd+ig8s2Ba19Q12obPnS9ShWObZPNermU5Vckp+AQAA//8DACc8 + 0b4TAgAA + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e505fde0d61-MXP + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:06 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-3.5-turbo-0125 + openai-organization: + - traceloop + openai-processing-ms: + - '577' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '5000' + x-ratelimit-limit-tokens: + - '160000' + x-ratelimit-remaining-requests: + - '4999' + x-ratelimit-remaining-tokens: + - '159915' + x-ratelimit-reset-requests: + - 12ms + x-ratelimit-reset-tokens: + - 31ms + x-request-id: + - req_29ec3dcffd46bdb01d632c8cbb1c9598 + status: + code: 200 + message: OK +- request: + body: '{"tool_outputs": [{"tool_call_id": "call_HHPk0IvzfSpVV7kNFCcUwTrF", "output": + "The city with the highest population in the city_stats table is Tokyo."}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '153' + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: POST + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/runs/run_zguJAL8433MuBLHiTZ8MIqqF/submit_tool_outputs + response: + body: + string: !!binary | + H4sIAAAAAAAAA3RT0U7bQBB8z1es/NRKoYUGQcpboEJQBaEKWqmpkLU+r52Dy91lb4+QIv69OtuJ + TKK+2LqZ2dkd3/p1AJDpMjuDjKPN/9bx+2Q6Ph6NbuL59Erfz8Y318vlZTZMOlc8kpKklTkTlp84 + 2pZRTChU5pjYo9PDr4dfTk9PRg2HIeggaCVv+2AIksfr0Xk1vbua3PqnlQkFzp7U1WQ2a+1a+06/ + Obxc3KtxZRfzcXF5cVGcPD1+u13FX21FEJQYknwZKVK5Rfl/Y9GL10yhz41HHafQKjJmU2mjMQ1e + od4HlVt4Q7KHMy2j5gQr0c72KYNBcmJ23EcXriSTItReDo4Pjo4OTw4807OmVRtH2yAcG7cm6m8X + AZkAoXACJQVdWypBHKANK2JYRgqNGrBwUUBp0RTgQ+FkDrFzi0wloC2hdyxR8GN3F86Z1O3PAADg + tXkmeO0pzVBF28YbbpgtcrZVA2QWF40+LE2eLLd6gKykoFj7rij7GaiKBirHIIw2GBRta0CwKJHR + gEFbR6wp5eM1aJsSw92PaQe4Z2JAECwMgXJWUFtt67OUf52nVQnDHg4yJ/DOx9TI2c/KRSvJpgJC + NW+q+uN6ZFyQEId3EXsfpftRhn3Os/PE6fvvVDUX66PswclQi2kcrxvFcI/vGgZhbevsHf3WO729 + G2Wzmdtb3Rmkhz0Mdu3ad3o+tP+ENpTrslmRFlmQYFqgFKhpnMWANXWrPnj7BwAA//8DALJDdfh0 + BAAA + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e557e880e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:06 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '180' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_8f4c713930f14af6a4bb1ea88b1f49d3 + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: GET + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/runs/run_zguJAL8433MuBLHiTZ8MIqqF + response: + body: + string: !!binary | + H4sIAAAAAAAAA2RTXU/bQBB8z69Y+amVQgsNCmneAhWCKghV0EpNhay1vXYOLneXvT3Ch/jv1Z2d + yJAXWzczO7vjW78OADJVZVPIOJj8pQk/Z/PJ8Wh0FU7nF+p2Mbm6XK/Ps2HU2eKeSolaWTJh9YWD + aZmSCYWqHCN7dHL4/fDbycl4lDj0XnlBI3nbB72XPFyOTuv5zcXs2j1stC9w8VBezBaL1q617/Tb + w9PZbTmpzWo5Kc7Pzorxw/2P603401Z4QQk+ypXJHduGyfsdxfuzjRNHT04x+T43GXVzl2hK0npb + aYLWCa9R7YOlXTlNsoczrYPiCJeirOlTGr3kxGy5j65sRTrmaJwcHB8cHR2ODxzTo6JNG0cZLxyS + W8r71wZAJkAorEBFXjWGKhALaPyGGNaBfFIDFjYIlEoUefhUWFlC6NwCUwVoKugdKxT83F2ItTp2 + +zcAAHhNzwg/O4oz1MG08YZbZodMd2qAzOAq6f1a59FypwfIKvIlK9cVZb891UFDbRmE0XiNokwD + CAYlMGrQaJqADcV8/AzKxMRw82veAfaRGBAEC01QWiOojDLNNOZ/zuO++GEPB1kSOOtCbGTN19IG + I9GmBsJymar64zpkXJEQ+3cRex+l+1uGfc6xdcTx+3+oShfrguzB0VCJTo6XSTHc47uGXliZJntH + v/VOb+9G2W7m7lY/DNLD7gYf7dp3fN61/4TSlKsqrUiLrEgwLlAMlBpnwWND3aoP3v4DAAD//wMA + xi6WAHkEAAA= + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e589bd60e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:07 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '38' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_8cdd94bb349d76824ac08ffb2ddc33a5 + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: GET + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/runs/run_zguJAL8433MuBLHiTZ8MIqqF + response: + body: + string: !!binary | + H4sIAAAAAAAAA2RTXU/bQBB8z69Y+amVQgsNCmneAhWCKghV0EpNhay1vXYOLneXvT3Ch/jv1Z2d + yJAXWzczO7vjW78OADJVZVPIOJj8pQk/Z/PJ8Wh0FU7nF+p2Mbm6XK/Ps2HU2eKeSolaWTJh9YWD + aZmSCYWqHCN7dHL4/fDbycl4lDj0XnlBI3nbB72XPFyOTuv5zcXs2j1stC9w8VBezBaL1q617/Tb + w9PZbTmpzWo5Kc7Pzorxw/2P603401Z4QQk+ypXJHduGyfsdxfuzjRNHT04x+T43GXVzl2hK0npb + aYLWCa9R7YOlXTlNsoczrYPiCJeirOlTGr3kxGy5j65sRTrmaJwcHB8cHR2ODxzTo6JNG0cZLxyS + W8r71wZAJkAorEBFXjWGKhALaPyGGNaBfFIDFjYIlEoUefhUWFlC6NwCUwVoKugdKxT83F2ItTp2 + +zcAAHhNzwg/O4oz1MG08YZbZodMd2qAzOAq6f1a59FypwfIKvIlK9cVZb891UFDbRmE0XiNokwD + CAYlMGrQaJqADcV8/AzKxMRw82veAfaRGBAEC01QWiOojDLNNOZ/zuO++GEPB1kSOOtCbGTN19IG + I9GmBsJymar64zpkXJEQ+3cRex+l+1uGfc6xdcTx+3+oShfrguzB0VCJTo6XSTHc47uGXliZJntH + v/VOb+9G2W7m7lY/DNLD7gYf7dp3fN61/4TSlKsqrUiLrEgwLlAMlBpnwWND3aoP3v4DAAD//wMA + xi6WAHkEAAA= + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e5aafbd0e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:07 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '37' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_72f85aac475339c6458bbcf7f6954d96 + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: GET + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/runs/run_zguJAL8433MuBLHiTZ8MIqqF + response: + body: + string: !!binary | + H4sIAAAAAAAAA2RTXU/bQBB8z69Y+amVQgsNCmneAhWCKghV0EpNhay1vXYOLneXvT3Ch/jv1Z2d + yJAXWzczO7vjW78OADJVZVPIOJj8pQk/Z/PJ8Wh0FU7nF+p2Mbm6XK/Ps2HU2eKeSolaWTJh9YWD + aZmSCYWqHCN7dHL4/fDbycl4lDj0XnlBI3nbB72XPFyOTuv5zcXs2j1stC9w8VBezBaL1q617/Tb + w9PZbTmpzWo5Kc7Pzorxw/2P603401Z4QQk+ypXJHduGyfsdxfuzjRNHT04x+T43GXVzl2hK0npb + aYLWCa9R7YOlXTlNsoczrYPiCJeirOlTGr3kxGy5j65sRTrmaJwcHB8cHR2ODxzTo6JNG0cZLxyS + W8r71wZAJkAorEBFXjWGKhALaPyGGNaBfFIDFjYIlEoUefhUWFlC6NwCUwVoKugdKxT83F2ItTp2 + +zcAAHhNzwg/O4oz1MG08YZbZodMd2qAzOAq6f1a59FypwfIKvIlK9cVZb891UFDbRmE0XiNokwD + CAYlMGrQaJqADcV8/AzKxMRw82veAfaRGBAEC01QWiOojDLNNOZ/zuO++GEPB1kSOOtCbGTN19IG + I9GmBsJymar64zpkXJEQ+3cRex+l+1uGfc6xdcTx+3+oShfrguzB0VCJTo6XSTHc47uGXliZJntH + v/VOb+9G2W7m7lY/DNLD7gYf7dp3fN61/4TSlKsqrUiLrEgwLlAMlBpnwWND3aoP3v4DAAD//wMA + xi6WAHkEAAA= + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e5d3cc80e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:11 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '3126' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_37e3fde94d89403cc270d316c4b3f576 + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: GET + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/runs/run_zguJAL8433MuBLHiTZ8MIqqF + response: + body: + string: !!binary | + H4sIAAAAAAAAA2RTXU/bQBB8z69Y+amVQhsamqS8ARWCKghV0EpNhay1vXaOnO8ud3uEFPHfqzs7 + xiQvtm5mdnbnPl4GAIkoklNIrFfpv8r/OJvPTsbjG38+vxL3i9nN9Xp9mQyDTmePlHPQ8tISFp+s + Vw2TW0KmIsXAHk9H30ZfptPJOHLonHCMitOmDzrHqb8en5fzu6uzW7PaSJfhYpVfnS0WjV1j3+p3 + i+eL+3xWqno5yy4vLrLJ6vH77cb/biocI3sX5LmujSSmoiPs4WSTyNGzEZZcwykvZZMFVU5S7mo6 + vERxCHbd9hrMImtp7YUNZM5Cq36hRMcpWattH611QTKkqAwfnRwdH48mR8bSk6BNE0cox9ZHt5j2 + j/aAlgAh0wwFOVEpKoA1oHIbsrD25KIaMNOeIRcsyMGHTPMSfOvmLRWAqoDeskDGj+1xaC1Dt78D + AICX+A3w1lCYofSqiTfcMR1y2qkBEoV11Lu1TINlpwdICnK5FaYtSn45Kr2EUltgi8pJZKEqQFDI + 3qIEiaryWFHIZ7cgVEgMdz/nLaCfyAICYyYJcq0YhRKqOg35t2m4LW7Yw4GXBEYbHxpp9TnXXnGw + KYEwX8aq/rgGLdbEZN27iL1Nad/KsM8Zqw3ZsP97VfFgjecDOBgKltHxOiqGB3zb0LEVqkre0a+9 + 1eu7UXY3szvVvUF62MNg3675h+9D8zKEpFQU8Yo0SE2M4QKFQLFx4h1W1OULW1EbTlmvKF7kyddZ + M9/uRQmt3tiTHcmaUb7h09FkEAZ5/Q8AAP//AwBuL2DgxwQAAA== + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e729baf0e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:11 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '35' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_f58e67583e8455bfba6d7e5a330840d5 + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: GET + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/messages?order=desc + response: + body: + string: !!binary | + H4sIAAAAAAAAA7yU32/aMBDH3/krTn5GVYEJMl4mytQBo2Jq006iqqIjcWKDY0N85scQ//uUhJ+V + 2B429SVyzt/v3fn8SbYVAGYmUx4SawNT0hKr5rEICVkbXisAANviCcBklKtSmwTPaoBRT9bqpI37 + 1vUXcrqarR4bhbvQnrKSyDhGNym3FhN+UoQZR+JRgLmq1rr9fFtvtZrecR+tlZZQU1DWRWspcP3G + XTx86nVG89lK2QmOZ2GvMx6f0pbl9p7Dy7rrh16sU+FN7rvdSXM2/TpauZeTK3N6b8lXvxI36Ay9 + T43Gg7sb9qQ/9h76i8X9md4ovm+qbPLsXEYT13Qc3/kIyw4388JLfH2ylTt5pH2hBmBLVK4w+IJD + KGkDK0kCSHAQMhHcEszN3CkkaXQVMAxNFkmdAJlClF8m4BKlwoniVZAWfDPbmJuL4vnEtTZUZLF5 + 929nu7vK+9Xb8cCxVDyQUek5RlNOuMdoW3p21Ws4vcT94boWxfr5+2DZin8kPTd6HC6a/45T/RpO + 2in1v5i5yHUgw1mefQQUP4UMRYmFQHuFii8ffdWVvYvFMrOHL/ivfw6m8EL8Ry6YQBukJsunEKOy + vLL7DQAA//8DAFdja+jQBAAA + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e74af0c0e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:11 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '86' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_bf5d0df85613e30ce088123ad15a4444 + status: + code: 200 + message: OK +- request: + body: '' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-type: + - application/json + cookie: + - __cf_bm=3ap6mRGUNPpQNaUTNKd3C4sU6ozk0NS6WJefA70dXuw-1709027762-1.0-AeQ7TwxhZjVeMzxYH83UHghkR8veeUAyZgYBz+hCNSGu+AJVJXejOzq0dstPLQOcBNHfcMjPsLCKBP2ORsewgP4=; + _cfuvid=inh_km31Ubd9c7_b4.HiyOsJywGGaAayJpYsZC1JPfE-1709027762377-0.0-604800000 + host: + - api.openai.com + openai-beta: + - assistants=v1 + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: GET + uri: https://api.openai.com/v1/threads/thread_ixCTc8fnmh8bFCCb6kjDOwuV/messages?order=desc&after=msg_VfILx1dfnUKJv7fPgHuORLq6 + response: + body: + string: !!binary | + H4sIAAAAAAAAA6rmUlBQyk/KSk0uUbJSUMrJLC5R0gGJpSSWJCpZKUTHgnlpmUXFJfGZKUpWCnml + OTlgsZxEDKGMxOL43PyiVCUrhbTEnOJUrloAAAAA//8DAAcD/aBgAAAA + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bf8e764a0b0e5d-MXP + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Tue, 27 Feb 2024 09:56:12 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - traceloop + openai-processing-ms: + - '29' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-request-id: + - req_d04c2e66a9711b012f0dc9d754d93eb5 + status: + code: 200 + message: OK +version: 1 diff --git a/packages/opentelemetry-instrumentation-llamaindex/tests/cassettes/test_agents/test_agents_and_tools.yaml b/packages/opentelemetry-instrumentation-llamaindex/tests/cassettes/test_agents/test_agents_and_tools.yaml new file mode 100644 index 0000000000..3c978500a3 --- /dev/null +++ b/packages/opentelemetry-instrumentation-llamaindex/tests/cassettes/test_agents/test_agents_and_tools.yaml @@ -0,0 +1,251 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "\nYou are designed to help + with a variety of tasks, from answering questions to providing summaries + to other types of analyses.\n\n## Tools\nYou have access to a wide variety of + tools. You are responsible for using\nthe tools in any sequence you deem appropriate + to complete the task at hand.\nThis may require breaking the task into subtasks + and using different tools\nto complete each subtask.\n\nYou have access to the + following tools:\n> Tool Name: multiply\nTool Description: multiply(a: int, + b: int) -> int\nMultiply two integers and returns the result integer\nTool Args: + {\"type\": \"object\", \"properties\": {\"a\": {\"title\": \"A\", \"type\": + \"integer\"}, \"b\": {\"title\": \"B\", \"type\": \"integer\"}}, \"required\": + [\"a\", \"b\"]}\n\n\n## Output Format\nTo answer the question, please use the + following format.\n\n```\nThought: I need to use a tool to help me answer the + question.\nAction: tool name (one of multiply) if using a tool.\nAction Input: + the input to the tool, in a JSON format representing the kwargs (e.g. {\"input\": + \"hello world\", \"num_beams\": 5})\n```\n\nPlease ALWAYS start with a Thought.\n\nPlease + use a valid JSON format for the Action Input. Do NOT do this {''input'': ''hello + world'', ''num_beams'': 5}.\n\nIf this format is used, the user will respond + in the following format:\n\n```\nObservation: tool response\n```\n\nYou should + keep repeating the above format until you have enough information\nto answer + the question without using any more tools. At that point, you MUST respond\nin + the one of the following two formats:\n\n```\nThought: I can answer without + using any more tools.\nAnswer: [your answer here]\n```\n\n```\nThought: I cannot + answer the question with the provided tools.\nAnswer: Sorry, I cannot answer + your query.\n```\n\n## Current Conversation\nBelow is the current conversation + consisting of interleaving human and assistant messages.\n\n"}, {"role": "user", + "content": "What is 2 times 3?"}], "model": "gpt-3.5-turbo-0613", "stream": + false, "temperature": 0.1}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '2073' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: !!binary | + H4sIAAAAAAAAA1RRy27CMBC85ytWewYEhFdza7mUQ0/l1FIhJ1kSt47XtTeCCvHvlcOrvVjrGc9o + Zn1MAFCXmAEWtZKicaa/2OfqkO6JzKo26+fZbPniFk+v82XJwzfsRQXnn1TIVTUouHGGRLM904Un + JRRdR/Ph4mG+GKejjmi4JBNllZN+Opj2pfU594ezUXpR1qwLCpjBewIAcOzOmNGWdMAMhr0r0lAI + qiLMbo8A0LOJCKoQdBBlBXt3smArZLvY65rbqpYMVmCJShCGNhAoEGYTbzUZBw2BsmFPHqQm+G4p + xI6DjX0s4pBB0xrRzvxcEVhZ10oGxw2qDWYw7sEG8zilJ7wEOd0aGK6c5zy2ta0xN3ynrQ711pMK + bGPaIOzO8lMC8NFtqv1XHp3nxslW+ItsNJxMRmc/vH/OnU0nF1JYlPmjmk+TS0IMP0Go2e60rcg7 + r7vFxZzJKfkFAAD//wMAOgmldjcCAAA= + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bad4f75e47bae5-MXP + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 26 Feb 2024 20:10:32 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=FAaKM59UNXNfCR9xvnAbdP8uaSBOmsHHl2o8VR0Fh_c-1708978232-1.0-AR2XDTQCvgBcV6vnpemurfbq7l9KfAAU+K2ygLpxZ7SAUqkrmtr82bm3K3hIb0jmP35fWLO4BJEENjXJrVXBBiA=; + path=/; expires=Mon, 26-Feb-24 20:40:32 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=J.rtBFBAp6rWOfvrHjBEKLv_4fy19auZ5oKuDQHDnmQ-1708978232084-0.0-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-3.5-turbo-0613 + openai-organization: + - traceloop + openai-processing-ms: + - '821' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '5000' + x-ratelimit-limit-tokens: + - '160000' + x-ratelimit-remaining-requests: + - '4999' + x-ratelimit-remaining-tokens: + - '159523' + x-ratelimit-reset-requests: + - 12ms + x-ratelimit-reset-tokens: + - 178ms + x-request-id: + - req_513a83b413fc1e757fe487c635d3f65f + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "system", "content": "\nYou are designed to help + with a variety of tasks, from answering questions to providing summaries + to other types of analyses.\n\n## Tools\nYou have access to a wide variety of + tools. You are responsible for using\nthe tools in any sequence you deem appropriate + to complete the task at hand.\nThis may require breaking the task into subtasks + and using different tools\nto complete each subtask.\n\nYou have access to the + following tools:\n> Tool Name: multiply\nTool Description: multiply(a: int, + b: int) -> int\nMultiply two integers and returns the result integer\nTool Args: + {\"type\": \"object\", \"properties\": {\"a\": {\"title\": \"A\", \"type\": + \"integer\"}, \"b\": {\"title\": \"B\", \"type\": \"integer\"}}, \"required\": + [\"a\", \"b\"]}\n\n\n## Output Format\nTo answer the question, please use the + following format.\n\n```\nThought: I need to use a tool to help me answer the + question.\nAction: tool name (one of multiply) if using a tool.\nAction Input: + the input to the tool, in a JSON format representing the kwargs (e.g. {\"input\": + \"hello world\", \"num_beams\": 5})\n```\n\nPlease ALWAYS start with a Thought.\n\nPlease + use a valid JSON format for the Action Input. Do NOT do this {''input'': ''hello + world'', ''num_beams'': 5}.\n\nIf this format is used, the user will respond + in the following format:\n\n```\nObservation: tool response\n```\n\nYou should + keep repeating the above format until you have enough information\nto answer + the question without using any more tools. At that point, you MUST respond\nin + the one of the following two formats:\n\n```\nThought: I can answer without + using any more tools.\nAnswer: [your answer here]\n```\n\n```\nThought: I cannot + answer the question with the provided tools.\nAnswer: Sorry, I cannot answer + your query.\n```\n\n## Current Conversation\nBelow is the current conversation + consisting of interleaving human and assistant messages.\n\n"}, {"role": "user", + "content": "What is 2 times 3?"}, {"role": "assistant", "content": "Thought: + I need to use a tool to help me answer the question.\nAction: multiply\nAction + Input: {''a'': 2, ''b'': 3}"}, {"role": "user", "content": "Observation: 6"}], + "model": "gpt-3.5-turbo-0613", "stream": false, "temperature": 0.1}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '2269' + content-type: + - application/json + cookie: + - __cf_bm=FAaKM59UNXNfCR9xvnAbdP8uaSBOmsHHl2o8VR0Fh_c-1708978232-1.0-AR2XDTQCvgBcV6vnpemurfbq7l9KfAAU+K2ygLpxZ7SAUqkrmtr82bm3K3hIb0jmP35fWLO4BJEENjXJrVXBBiA=; + _cfuvid=J.rtBFBAp6rWOfvrHjBEKLv_4fy19auZ5oKuDQHDnmQ-1708978232084-0.0-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.12.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.12.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.9.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: !!binary | + H4sIAAAAAAAAA1SQS2/CMBCE7/kVK58BhfBKc6sqlfbSQx/i0FbICUti6ngte1NAiP9eOQSiXnyY + 2Vl/O6cIQKiNyEAUleSitnqY7nN5zO3qd1ku+fHt9eFj90KH1RRXT/FSDEKC8h0WfE2NCqqtRlZk + LnbhUDKGreNFnN4t0mSStEZNG9QhVloeTkazITcup2E8H0+6ZEWqQC8y+IwAAE7tGxjNBg8ig3hw + VWr0XpYostsQgHCkgyKk98qzNCwGvVmQYTQt9ntFTVlxBs9QSAPS+D062CuuqGFovDIlSHOEmhwC + E2k/+jL37VQGCbCq0cMElIf5SHQ/nG9omkrrKA9nmEbrm75VRvlq7VB6MgHDM9lL/BwBfLcVNP+u + EtZRbXnN9IMmLJym6WWf6Fvv3STpTCaWutdn4zjqCIU/esZ6vVWmRGedahsJnNE5+gMAAP//AwC6 + 385JEAIAAA== + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 85bad4fefe57bae5-MXP + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 26 Feb 2024 20:10:33 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-3.5-turbo-0613 + openai-organization: + - traceloop + openai-processing-ms: + - '785' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '5000' + x-ratelimit-limit-tokens: + - '160000' + x-ratelimit-remaining-requests: + - '4999' + x-ratelimit-remaining-tokens: + - '159491' + x-ratelimit-reset-requests: + - 12ms + x-ratelimit-reset-tokens: + - 190ms + x-request-id: + - req_ad19db34ad4befdd0dfee7f94c467941 + status: + code: 200 + message: OK +version: 1 diff --git a/packages/opentelemetry-instrumentation-llamaindex/tests/conftest.py b/packages/opentelemetry-instrumentation-llamaindex/tests/conftest.py index bb0826512c..cb178b3471 100644 --- a/packages/opentelemetry-instrumentation-llamaindex/tests/conftest.py +++ b/packages/opentelemetry-instrumentation-llamaindex/tests/conftest.py @@ -39,7 +39,7 @@ def clear_exporter(exporter): @pytest.fixture(autouse=True) def environment(): os.environ["TOKENIZERS_PARALLELISM"] = "false" - os.environ["OPENAI_API_KEY"] = "test_api_key" + # os.environ["OPENAI_API_KEY"] = "test_api_key" os.environ["COHERE_API_KEY"] = "test_api_key" diff --git a/packages/opentelemetry-instrumentation-llamaindex/tests/test_agents.py b/packages/opentelemetry-instrumentation-llamaindex/tests/test_agents.py new file mode 100644 index 0000000000..12631a5bca --- /dev/null +++ b/packages/opentelemetry-instrumentation-llamaindex/tests/test_agents.py @@ -0,0 +1,112 @@ +import pytest +from sqlalchemy import create_engine, MetaData, Table, Column, String, Integer, insert +from llama_index.core import SQLDatabase +from llama_index.core.agent import ReActAgent +from llama_index.agent.openai import OpenAIAssistantAgent +from llama_index.core.tools import FunctionTool, QueryEngineTool +from llama_index.core.query_engine import NLSQLTableQueryEngine +from llama_index.llms.openai import OpenAI + + +@pytest.mark.vcr +def test_agents_and_tools(exporter): + def multiply(a: int, b: int) -> int: + """Multiply two integers and returns the result integer""" + return a * b + + multiply_tool = FunctionTool.from_defaults(fn=multiply) + llm = OpenAI(model="gpt-3.5-turbo-0613") + agent = ReActAgent.from_tools([multiply_tool], llm=llm, verbose=True) + + agent.chat("What is 2 times 3?") + + spans = exporter.get_finished_spans() + + assert set( + [ + "ReActAgent.agent", + "FunctionTool.tool", + "openai.chat", + ] + ) == set([span.name for span in spans]) + + agent_span = next(span for span in spans if span.name == "ReActAgent.agent") + function_tool = next(span for span in spans if span.name == "FunctionTool.tool") + openai_span = next(span for span in spans if span.name == "openai.chat") + + assert function_tool.parent.span_id == agent_span.context.span_id + assert openai_span.parent.span_id == agent_span.context.span_id + + +@pytest.mark.vcr +def test_agent_with_query_tool(exporter): + engine = create_engine("sqlite:///:memory:", future=True) + metadata_obj = MetaData() + + table_name = "city_stats" + city_stats_table = Table( + table_name, + metadata_obj, + Column("city_name", String(16), primary_key=True), + Column("population", Integer), + Column("country", String(16), nullable=False), + ) + metadata_obj.create_all(engine) + + rows = [ + {"city_name": "Toronto", "population": 2930000, "country": "Canada"}, + {"city_name": "Tokyo", "population": 13960000, "country": "Japan"}, + {"city_name": "Berlin", "population": 3645000, "country": "Germany"}, + ] + for row in rows: + stmt = insert(city_stats_table).values(**row) + with engine.begin() as connection: + connection.execute(stmt) + + sql_database = SQLDatabase(engine, include_tables=["city_stats"]) + + query_engine = NLSQLTableQueryEngine( + sql_database=sql_database, + tables=["city_stats"], + ) + + sql_tool = QueryEngineTool.from_defaults( + query_engine=query_engine, + name="sql_tool", + description=( + "Useful for translating a natural language query into a SQL query over" + " a table containing: city_stats, containing the population/country of" + " each city" + ), + ) + + agent = OpenAIAssistantAgent.from_new( + name="City bot", + instructions="You are a bot designed to answer questions about cities (both unstructured and structured data)", + tools=[sql_tool], + verbose=True, + ) + + agent.chat("Which city has the highest population?") + + spans = exporter.get_finished_spans() + + assert set( + [ + "OpenAIAssistantAgent.agent", + "QueryEngineTool.tool", + "synthesize.task", + "openai.chat", + ] + ) == set([span.name for span in spans]) + + agent_span = next( + span for span in spans if span.name == "OpenAIAssistantAgent.agent" + ) + query_engine_tool = next( + span for span in spans if span.name == "QueryEngineTool.tool" + ) + synthesize_task = next(span for span in spans if span.name == "synthesize.task") + + assert query_engine_tool.parent.span_id == agent_span.context.span_id + assert synthesize_task.parent.span_id == query_engine_tool.context.span_id