From 7cf2f03612ba864e894380119558303e741fe120 Mon Sep 17 00:00:00 2001 From: Abram Date: Wed, 29 May 2024 14:50:04 +0100 Subject: [PATCH] Style: format code with black@23.12.0 --- agenta-cli/agenta/sdk/decorators/llm_entrypoint.py | 8 ++++---- agenta-cli/agenta/sdk/tracing/llm_tracing.py | 8 ++++++-- examples/app_with_observability/app_async.py | 7 ++++++- examples/app_with_observability/dict_app_async.py | 7 ++++++- .../app_with_observability/workflows/tracing_from_bash.py | 7 ++++++- .../workflows/tracing_plus_entrypoint.py | 7 ++++++- 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/agenta-cli/agenta/sdk/decorators/llm_entrypoint.py b/agenta-cli/agenta/sdk/decorators/llm_entrypoint.py index cd32268176..c02d472ffc 100644 --- a/agenta-cli/agenta/sdk/decorators/llm_entrypoint.py +++ b/agenta-cli/agenta/sdk/decorators/llm_entrypoint.py @@ -82,7 +82,7 @@ async def wrapper(*args, **kwargs) -> Any: # Set the configuration and environment of the LLM app parent span at run-time agenta.tracing.set_span_attribute( - {"config": config_params, "environment": "playground"} + {"config": config_params, "environment": "playground"} ) llm_result = await self.execute_function( @@ -105,7 +105,7 @@ async def wrapper_deployed(*args, **kwargs) -> Any: # Set the configuration and environment of the LLM app parent span at run-time agenta.tracing.set_span_attribute( - {"config": config_params, "environment": kwargs["environment"]} + {"config": config_params, "environment": kwargs["environment"]} ) llm_result = await self.execute_function( @@ -391,8 +391,8 @@ def handle_terminal_run( # Set the configuration and environment of the LLM app parent span at run-time agenta.tracing.set_span_attribute( - {"config": agenta.config.all(), "environment": "bash"} - ) + {"config": agenta.config.all(), "environment": "bash"} + ) loop = asyncio.get_event_loop() result = loop.run_until_complete( diff --git a/agenta-cli/agenta/sdk/tracing/llm_tracing.py b/agenta-cli/agenta/sdk/tracing/llm_tracing.py index 195fd9b67e..cd0e70a18b 100644 --- a/agenta-cli/agenta/sdk/tracing/llm_tracing.py +++ b/agenta-cli/agenta/sdk/tracing/llm_tracing.py @@ -76,7 +76,9 @@ def __init__( self.active_trace_id: Optional[str] = None self.pending_spans: List[CreateSpan] = [] self.tags: List[str] = [] - self.trace_config_cache: Dict[str, Any] = {} # used to save the trace configuration before starting the first span + self.trace_config_cache: Dict[ + str, Any + ] = {} # used to save the trace configuration before starting the first span self.span_dict: Dict[str, CreateSpan] = {} # type: ignore @property @@ -95,7 +97,9 @@ def set_span_attribute( self, attributes: Dict[str, Any] = {}, ): - if self.active_span is None: # This is the case where entrypoint wants to save the trace information but the parent span has not been initialized yet + if ( + self.active_span is None + ): # This is the case where entrypoint wants to save the trace information but the parent span has not been initialized yet for key, value in attributes.items(): self.trace_config_cache[key] = value else: diff --git a/examples/app_with_observability/app_async.py b/examples/app_with_observability/app_async.py index 0ba8dfc942..4ed457a577 100644 --- a/examples/app_with_observability/app_async.py +++ b/examples/app_with_observability/app_async.py @@ -23,7 +23,12 @@ async def llm_call(prompt): model="gpt-3.5-turbo", messages=[{"role": "user", "content": prompt}] ) ag.tracing.set_span_attribute( - {"model_config":{"model": "gpt-3.5-turbo", "temperature": ag.config.temperature}} + { + "model_config": { + "model": "gpt-3.5-turbo", + "temperature": ag.config.temperature, + } + } ) # translate to {"model_config": {"model": "gpt-3.5-turbo", "temperature": 0.2}} tokens_usage = chat_completion.usage.dict() return { diff --git a/examples/app_with_observability/dict_app_async.py b/examples/app_with_observability/dict_app_async.py index 34953d731d..fa91517457 100644 --- a/examples/app_with_observability/dict_app_async.py +++ b/examples/app_with_observability/dict_app_async.py @@ -64,7 +64,12 @@ async def litellm_call(prompt_system: str, prompt_user: str): response_format=response_format, ) ag.tracing.set_span_attribute( - {"model_config": {"model": ag.config.model, "temperature": ag.config.temperature}} + { + "model_config": { + "model": ag.config.model, + "temperature": ag.config.temperature, + } + } ) tokens_usage = response.usage.dict() return { diff --git a/examples/app_with_observability/workflows/tracing_from_bash.py b/examples/app_with_observability/workflows/tracing_from_bash.py index 929937a09a..35f56b8b45 100644 --- a/examples/app_with_observability/workflows/tracing_from_bash.py +++ b/examples/app_with_observability/workflows/tracing_from_bash.py @@ -25,7 +25,12 @@ async def llm_call(prompt): model="gpt-3.5-turbo", messages=[{"role": "user", "content": prompt}] ) ag.tracing.set_span_attribute( - {"model_config": {"model": "gpt-3.5-turbo", "temperature": ag.config.temperature}} + { + "model_config": { + "model": "gpt-3.5-turbo", + "temperature": ag.config.temperature, + } + } ) # translates to {"model_config": {"model": "gpt-3.5-turbo", "temperature": 0.2}} tokens_usage = chat_completion.usage.dict() return { diff --git a/examples/app_with_observability/workflows/tracing_plus_entrypoint.py b/examples/app_with_observability/workflows/tracing_plus_entrypoint.py index 4b7e5f94b8..35ea1f51dd 100644 --- a/examples/app_with_observability/workflows/tracing_plus_entrypoint.py +++ b/examples/app_with_observability/workflows/tracing_plus_entrypoint.py @@ -24,7 +24,12 @@ async def llm_call(prompt): model="gpt-3.5-turbo", messages=[{"role": "user", "content": prompt}] ) ag.tracing.set_span_attribute( - {"model_config": {"model": "gpt-3.5-turbo", "temperature": ag.config.temperature}} + { + "model_config": { + "model": "gpt-3.5-turbo", + "temperature": ag.config.temperature, + } + } ) # translates to {"model_config": {"model": "gpt-3.5-turbo", "temperature": 0.2}} tokens_usage = chat_completion.usage.dict() return {