diff --git a/python/langsmith/wrappers/_openai.py b/python/langsmith/wrappers/_openai.py index a630e15b0..22b4e25c5 100644 --- a/python/langsmith/wrappers/_openai.py +++ b/python/langsmith/wrappers/_openai.py @@ -92,13 +92,13 @@ def _reduce_choices(choices: List[Choice]) -> dict: "arguments": "", } if chunk.function.name: - message["tool_calls"][index]["function"]["name"] += ( - chunk.function.name - ) + message["tool_calls"][index]["function"][ + "name" + ] += chunk.function.name if chunk.function.arguments: - message["tool_calls"][index]["function"]["arguments"] += ( - chunk.function.arguments - ) + message["tool_calls"][index]["function"][ + "arguments" + ] += chunk.function.arguments return { "index": choices[0].index, "finish_reason": next( diff --git a/python/tests/integration_tests/test_context_propagation.py b/python/tests/integration_tests/test_context_propagation.py index fbdb178df..32cd1f74d 100644 --- a/python/tests/integration_tests/test_context_propagation.py +++ b/python/tests/integration_tests/test_context_propagation.py @@ -37,7 +37,9 @@ async def the_parent_function(): headers = {} if span := get_current_run_tree(): headers.update(span.to_headers()) - return await client.post("/fake-route", headers=headers) + response = await client.post("/fake-route", headers=headers) + assert response.status_code == 200 + return response.json() @traceable @@ -47,7 +49,11 @@ async def the_root_function(foo: str): @pytest.mark.asyncio async def test_tracing_fake_server(fake_server): - response = await the_root_function( - langsmith_extra={"metadata": {"some-cool-value": 42}, "tags": ["did-propagate"]} + result = await the_root_function( + "test input", + langsmith_extra={ + "metadata": {"some-cool-value": 42}, + "tags": ["did-propagate"], + }, ) - assert response.status_code == 200 + assert result["message"] == "Fake route response"