From 7c84545c0bf17b9beaf972b9eb70797dd27c46f3 Mon Sep 17 00:00:00 2001 From: Abraham 'Abram' Israel Date: Tue, 12 Nov 2024 09:27:40 +0100 Subject: [PATCH 1/7] refactor (cli): add Prompt sdk type --- agenta-cli/agenta/__init__.py | 1 + agenta-cli/agenta/sdk/__init__.py | 1 + agenta-cli/agenta/sdk/types.py | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/agenta-cli/agenta/__init__.py b/agenta-cli/agenta/__init__.py index 4b713d02a8..3a823a9c22 100644 --- a/agenta-cli/agenta/__init__.py +++ b/agenta-cli/agenta/__init__.py @@ -16,6 +16,7 @@ TextParam, FileInputURL, BinaryParam, + Prompt, ) from .sdk.tracing.logger import llm_logger as logging diff --git a/agenta-cli/agenta/sdk/__init__.py b/agenta-cli/agenta/sdk/__init__.py index f972482a85..435e33b386 100644 --- a/agenta-cli/agenta/sdk/__init__.py +++ b/agenta-cli/agenta/sdk/__init__.py @@ -16,6 +16,7 @@ MessagesInput, FileInputURL, BinaryParam, + Prompt, ) from .tracing.llm_tracing import Tracing diff --git a/agenta-cli/agenta/sdk/types.py b/agenta-cli/agenta/sdk/types.py index b34f380bae..cab9fb4b2c 100644 --- a/agenta-cli/agenta/sdk/types.py +++ b/agenta-cli/agenta/sdk/types.py @@ -222,7 +222,10 @@ class LifecyclesResponse(ReferencesResponse): deployed_by_id: Optional[str] = None def __str__(self): - return str(self.model_dump(exclude_none=True)) + return self.model_dump_json(indent=4) + + def __repr__(self): + return self.__str__() class ConfigurationResponse(LifecyclesResponse): @@ -231,3 +234,14 @@ class ConfigurationResponse(LifecyclesResponse): class DeploymentResponse(LifecyclesResponse): pass + + +class Prompt(BaseModel): + temperature: float + model: str + max_tokens: int + prompt_system: str + prompt_user: str + top_p: float + frequency_penalty: float + presence_penalty: float From 5740b57896af4c53b1630836260052f9e0c96ca6 Mon Sep 17 00:00:00 2001 From: Abraham 'Abram' Israel Date: Tue, 12 Nov 2024 09:28:15 +0100 Subject: [PATCH 2/7] refactor (docs): update prompt management docs based on new development in the sdk & backend --- .../03-prompt-management-sdk.mdx | 169 +++++++++++------- .../tutorials/sdk/manage-prompts-with-SDK.mdx | 127 +++++++------ 2 files changed, 184 insertions(+), 112 deletions(-) diff --git a/docs/docs/prompt-management/03-prompt-management-sdk.mdx b/docs/docs/prompt-management/03-prompt-management-sdk.mdx index 3660dd54aa..0b4c0e0871 100644 --- a/docs/docs/prompt-management/03-prompt-management-sdk.mdx +++ b/docs/docs/prompt-management/03-prompt-management-sdk.mdx @@ -39,11 +39,14 @@ The workflow of deploying something to production is therefore as follows: Before using the SDK, you need to initialize it using the `ag.init()` method. ```python +import os import agenta as ag + # Initialize the SDK with your API key -os.environment["AGENTA_API_KEY"] = "xxx" # Only needs setting in oss -os.environment["AGENTA_HOST"] = "https://cloud.agenta.ai" # default value no need setting explicitly +os.environ["AGENTA_API_KEY"] = "xxx" # Only needs setting in oss +os.environ["AGENTA_HOST"] = "https://cloud.agenta.ai" # default value no need setting explicitly + ag.init() ``` @@ -55,13 +58,14 @@ Each prompt in agenta is a unique application. Currently creating a prompt is on ### Creating a New Variant -To create a new variant, use the `VariantManager.create_variant` method. +To create a new variant, use the `VariantManager.create` method. ```python from agenta import Prompt -# Prompt is a pydantic BaseModel, for additional validation +# Prompt is a pydantic BaseModel we created for common prompt settings. +# To add more fields or validations, create your own custom model. my_prompt = Prompt( temperature=0.7, model="gpt-3.5-turbo", @@ -74,7 +78,7 @@ my_prompt = Prompt( ) # Create a new variant -variant = ag.VariantManager.create_variant( +variant = ag.VariantManager.create( parameters=my_prompt.model_dump(), app_slug="my-app-slug", # app_id="my-app-id", # you can also use `app_id` @@ -83,6 +87,18 @@ variant = ag.VariantManager.create_variant( print("Created variant:") print(variant) + +# Create a new version asynchronously (optional) +# async def create_variant(): +# variant = ag.VariantManager.acreate( +# parameters=my_prompt.model_dump(), +# app_slug="my-app-slug", +# app_id="my-app-id", # you can also use `app_id` +# variant_slug="my-variant-slug", +# ) + +# print("Created variant (async):") +# print(variant) ``` This command will create a new variant and initialize it with the first commit containing the parameters provided @@ -122,7 +138,7 @@ Created variant: ### Committing Changes to a Variant -To save changes to a variant (creating a new version), use the `VariantManager.commit_variant` method with explicit parameters. +To save changes to a variant (creating a new version), use the `VariantManager.commit` method with explicit parameters. ```python my_prompt2 = Prompt( @@ -137,7 +153,7 @@ my_prompt2 = Prompt( ) # Commit the new version -variant = ag.VariantManager.commit_variant( +variant = ag.VariantManager.commit( parameters=my_prompt2.model_dump(), app_slug="my-app-slug", variant_slug="my-variant-slug", @@ -145,6 +161,17 @@ variant = ag.VariantManager.commit_variant( print("Committed new version of variant:") print(variant) + +# Commit the new version asynchronously (optional) +# async def commit_variant(): +# variant = ag.VariantManager.acommit( +# parameters=my_prompt2.model_dump(), +# app_slug="my-app-slug", +# variant_slug="my-variant-slug", +# ) + +# print("Committed new version of variant (async):") +# print(variant) ``` :::info Immutability @@ -179,11 +206,11 @@ Committed new version of variant: ## Deploying to an Environment -To deploy a variant to an environment, use the `DeploymentManager.deploy_variant` method with the variant reference and `environment_slug`: The slug of the environment (`development`, `staging`, or `production`). +To deploy a variant to an environment, use the `DeploymentManager.deploy` method with the variant reference and `environment_slug`: The slug of the environment (`development`, `staging`, or `production`). ```python # Deploy the variant to the staging environment -deployment = ag.DeploymentManager.deploy_variant( +deployment = ag.DeploymentManager.deploy( app_slug="my-app-slug", # app_id="my-app-id", # you can also use `app_id` variant_slug="my-variant-slug", @@ -193,6 +220,19 @@ deployment = ag.DeploymentManager.deploy_variant( print("Deployed variant to environment:") print(deployment) + +# Deploy the variant to the staging environment asynchronously (optional) +# async def deploy_variant(): +# deployment = await ag.DeploymentManager.adeploy( +# app_slug="my-app-slug", +# # app_id="my-app-id", # you can also use `app_id` +# variant_slug="my-variant-slug", +# variant_version=None, # Optional: If not provided, deploys the latest version +# environment_slug="staging" +# ) + +# print("Deployed variant to environment (async):") +# print(deployment) ``` :::warning @@ -269,24 +309,14 @@ print(config) ```python Fetched configuration: { - 'parameters': { - 'temperature': 1.0, - 'model': 'gpt-4', - 'max_tokens': 150, - 'prompt_system': 'You are an assistant that provides concise answers.', - 'prompt_user': 'Explain {topic} in simple terms.', - 'top_p': 1.0, - 'frequency_penalty': 0.0, - 'presence_penalty': 0.0 - } - 'app_id': 'my-app-id', - 'app_slug': 'my-app-slug', - 'variant_id': 'updated-variant-id', - 'variant_slug': 'my-variant-slug', - 'variant_version': 2, - 'committed_at': 'current-datetime', - 'committed_by': 'my-email-address', - 'committed_by_id': 'my-user-id', + 'temperature': 1.0, + 'model': 'gpt-4', + 'max_tokens': 150, + 'prompt_system': 'You are an assistant that provides concise answers.', + 'prompt_user': 'Explain {topic} in simple terms.', + 'top_p': 1.0, + 'frequency_penalty': 0.0, + 'presence_penalty': 0.0 } ``` @@ -309,42 +339,37 @@ print(config) ```python Fetched configuration from staging: { - 'parameters': { - 'temperature': 0.7, - 'model': 'gpt-3.5-turbo', - 'max_tokens': 150, - 'prompt_system': 'You are an assistant that provides concise answers.', - 'prompt_user': 'Explain {topic} in simple terms.', - 'top_p': 1.0, - 'frequency_penalty': 0.0, - 'presence_penalty': 0.0 - }, - 'app_id': 'my-app-id', - 'app_slug': 'my-app-slug', - 'variant_id': 'new-variant-id', - 'variant_slug': 'my-variant-slug', - 'variant_version': 1, - 'environment_id': 'staging-enviroment-id', - 'environment_slug': 'staging', - 'environment_version': 1, - 'deployed_at': 'current-datetime', - 'deployed_by': 'my-email-address', - 'deployed_by_id': 'my-user-id', + 'temperature': 0.7, + 'model': 'gpt-3.5-turbo', + 'max_tokens': 150, + 'prompt_system': 'You are an assistant that provides concise answers.', + 'prompt_user': 'Explain {topic} in simple terms.', + 'top_p': 1.0, + 'frequency_penalty': 0.0, + 'presence_penalty': 0.0 } ``` ## Deleting a Variant -To delete a variant, use the `VariantManager.delete_variant` method. +To delete a variant, use the `VariantManager.delete` method. ```python # Delete a variant -ag.VariantManager.delete_variant( +ag.VariantManager.delete( app_slug="my-app", # app_id="my-app-id", # you can also use `app_id` variant_slug="obsolete-variant" ) +# Delete a variant asynchronously (optional) +# async def delete_variant(): +# versions = await ag.VariantManager.adelete( +# app_slug="my-app", +# # app_id="my-app-id", # you can also use `app_id` +# variant_slug="obsolete-variant", +# ) + print("Variant deleted successfully.") ``` @@ -356,11 +381,11 @@ print("Variant deleted successfully.") ## Listing All Variants -To list all variants of an application, use the `VariantManager.list_variants` method. +To list all variants of an application, use the `VariantManager.list` method. ```python -# List all variants -variants = ag.VariantManager.list_variants( +# List all variants (syncrhonously) +variants = ag.VariantManager.list( app_slug="my-app" # app_id="my-app-id", # you can also use `app_id` ) @@ -368,6 +393,17 @@ variants = ag.VariantManager.list_variants( print("List of variants:") for variant in variants: print(variant) + +# List all variants asynchronously (optional) +# async def list_variants(): +# variants = await ag.VariantManager.alist( +# app_slug="my-app" +# # app_id="my-app-id", # you can also use `app_id` +# ) + +# print("List of variants (async):") +# for variant in variants: +# print(variant) ``` **Sample Output:** @@ -418,18 +454,31 @@ List of variants: ## Fetching a Variant's history -To list all versions for a variant of an application, use the `VariantManager.list_variants` method. +To list all versions for a variant of an application, use the `VariantManager.list` method. ```python -# List all variants -variants = ag.VariantManager.list_variants( +# List all variant versions/history (synchronously) +versions = ag.VariantManager.history( + variant_slug="variant-slug", app_slug="my-app" # app_id="my-app-id", # you can also use `app_id` ) -print("List of variants:") -for variant in variants: - print(variant) +print("History of variant:") +for version in versions: + print(version) + +# List all variant versions/history asynchronously (optional) +# async def fetch_variant_history(): +# versions = await ag.VariantManager.ahistory( +# variant_slug="variant-slug", +# app_slug="my-app" +# # app_id="my-app-id", # you can also use `app_id` +# ) + +# print("History of variant:") +# for version in versions: +# print(version) ``` **Sample Output:** @@ -484,7 +533,7 @@ If your application uses asynchronous programming, you can use the async version ```python # Asynchronous fetching of configuration -config = await ag.ConfigManager.aget_from_registry( +config = await ag.ConfigManager.async_get_from_registry( app_slug="my-app", # app_id="my-app-id", # you can also use `app_id` variant_slug="my-variant-slug", diff --git a/docs/docs/tutorials/sdk/manage-prompts-with-SDK.mdx b/docs/docs/tutorials/sdk/manage-prompts-with-SDK.mdx index c009202c77..c5486eb831 100644 --- a/docs/docs/tutorials/sdk/manage-prompts-with-SDK.mdx +++ b/docs/docs/tutorials/sdk/manage-prompts-with-SDK.mdx @@ -46,7 +46,7 @@ We're going to create a new completion prompt called `topic-explainer`. [Todo: Image showing before and after. The new elements are added in different colors] -Variants are similar to branches in **git**. Any change to the prompt must first be committed to a variant. Here, we'll create a new variant and make our first commit to it using the `VariantManager.create_variant` method: +Variants are similar to branches in **git**. Any change to the prompt must first be committed to a variant. Here, we'll create a new variant and make our first commit to it using the `VariantManager.create` method: ```python @@ -56,14 +56,14 @@ from agenta import Prompt my_prompt = Prompt(temperature=0.6, model="gpt-3.5-turbo", max_tokens=150, - prompt=[{"role": "system", "content": "You are an assistant that provides concise answers"}, - {"role": "user", "content": "Explain {topic} in simple terms"}], + prompt_system="You are an assistant that provides concise answers", + prompt_user="Explain {topic} in simple terms", top_p=1.0, frequency_penalty=0.0, presence_penalty=0.0 ) # Create a new variant -variant = ag.VariantManager.create_variant( +variant = ag.VariantManager.create( app_slug="topic-explainer", variant_slug="new-variant", config_parameters=my_prompt.dict() @@ -85,21 +85,24 @@ This command will create a new variant and initialize it with the first commit c ```python Created variant: { - 'app_slug': 'topic-explainer', - 'variant_slug': 'new-variant', + 'parameters': { + 'temperature': 0.6, + 'model': 'gpt-3.5-turbo', + 'max_tokens': 150, + 'prompt_system': 'You are an assistant that provides concise answers.', + 'prompt_user': 'Explain {topic} in simple terms.', + 'top_p': 1.0, + 'frequency_penalty': 0.0, + 'presence_penalty': 0.0 + }, + 'app_id': 'my-app-id', + 'app_slug': 'my-app-slug', + 'variant_id': 'new-variant-id', + 'variant_slug': 'my-variant-slug', 'variant_version': 1, - 'config': { - 'parameters': { - 'temperature': 0.7, - 'model': 'gpt-3.5-turbo', - 'max_tokens': 150, - 'prompt_system': 'You are an assistant that provides concise answers.', - 'prompt_user': 'Explain {topic} in simple terms.', - 'top_p': 1.0, - 'frequency_penalty': 0.0, - 'presence_penalty': 0.0 - }, - } + 'committed_at': 'current-datetime', + 'committed_by': 'my-email-address', + 'committed_by_id': 'my-user-id', } ``` @@ -107,11 +110,11 @@ Created variant: [Todo: Image showing before and after. The new elements are added in a different colors] -To deploy our commit to an environment, use the `DeploymentManager.deploy_variant` method. +To deploy our commit to an environment, use the `DeploymentManager.deploy` method. ```python # Deploy the variant to the production environment -deployment = ag.DeploymentManager.deploy_variant( +deployment = ag.DeploymentManager.deploy( app_slug="topic-explainer", variant_slug="new-variant", environment_slug="production", @@ -133,11 +136,27 @@ print(deployment) ```python Deployed variant to environment: { + 'parameters': { + 'temperature': 0.7, + 'model': 'gpt-3.5-turbo', + 'max_tokens': 150, + 'prompt_system': 'You are an assistant that provides concise answers.', + 'prompt_user': 'Explain {topic} in simple terms.', + 'top_p': 1.0, + 'frequency_penalty': 0.0, + 'presence_penalty': 0.0 + }, + 'app_id': 'my-app-id', 'app_slug': 'topic-explainer', - 'variant_slug': 'new-variant', - 'variant_version': 1 + 'variant_id': 'new-variant-id', + 'variant_slug': 'my-variant-slug', + 'variant_version': 1, + 'environment_id': 'production-enviroment-id', 'environment_slug': 'production', - 'environment_version': 1 + 'environment_version': 1, + 'deployed_at': 'current-datetime', + 'deployed_by': 'my-email-address', + 'deployed_by_id': 'my-user-id', } ``` @@ -150,14 +169,15 @@ We're now going to commit changes to our variant. Note that this will not modify To save changes to a variant (creating a new version), we are goin to use the `VariantManager.commit_variant` method with explicit parameters. ```python -my_prompt2 = Prompt(temperature=0.6, - model="gpt-3.5-turbo", - max_tokens=150, - prompt=[{"role": "system", "content": "You are an assistant that provides concise answers"}, - {"role": "user", "content": "Use Paul Graham style to explain {topic} in simple terms."}], - top_p=1.0, - frequency_penalty=0.0, - presence_penalty=0.0 ) +my_prompt2 = Prompt( + temperature=0.9, + model="gpt-3.5-turbo", + max_tokens=150, + prompt_system="You are an assistant that provides concise answers", + prompt_user="Use Paul Graham style to explain {topic} in simple terms.", + top_p=1.0, + frequency_penalty=0.0, + presence_penalty=0.0 ) # Commit the new version @@ -180,21 +200,24 @@ Each commit creates a new version of the variant. Versions are immutable once cr ```python Committed new version of variant: { + 'parameters': { + 'temperature': 0.9, + 'model': 'gpt-3.5-turbo', + 'max_tokens': 150, + 'prompt_system': 'You are an assistant that provides concise answers.', + 'prompt_user': 'Use Paul Graham style to explain {topic} in simple terms.', + 'top_p': 1.0, + 'frequency_penalty': 0.0, + 'presence_penalty': 0.0 + }, + 'app_id': 'my-app-id', 'app_slug': 'topic-explainer', - 'variant_slug': 'new-variant', + 'variant_id': 'new-variant-id', + 'variant_slug': 'new-variant-slug', 'variant_version': 2, - 'config': { - 'parameters': { - 'temperature': 0.9, - 'model': 'gpt-3.5-turbo', - 'max_tokens': 150, - 'prompt_system': 'You are an assistant that provides concise answers.', - 'prompt_user': 'Use Paul Graham style to explain {topic} in simple terms.', - 'top_p': 1.0, - 'frequency_penalty': 0.0, - 'presence_penalty': 0.0 - } - } + 'committed_at': 'current-datetime', + 'committed_by': 'my-email-address', + 'committed_by_id': 'my-user-id', } ``` @@ -213,14 +236,14 @@ print("Fetched configuration from production:") print(config) client.completion( - model=myprompt.model, - messages=format_prompt(myprompt.prompt, topic), - temperature=myprompt.temperature, - max_tokens=myprompt.max_tokens, - top_p=myprompt.top_p, - frequency_penalty=myprompt.frequency_penalty, - presence_penalty=myprompt.presence_penalty, - ) + model=myprompt.model, + messages=format_prompt(myprompt.prompt, topic), + temperature=myprompt.temperature, + max_tokens=myprompt.max_tokens, + top_p=myprompt.top_p, + frequency_penalty=myprompt.frequency_penalty, + presence_penalty=myprompt.presence_penalty, +) ``` ## Next Steps From 037c9569a9236d1f91a9eec9bb40f6f8a318a22e Mon Sep 17 00:00:00 2001 From: Abraham 'Abram' Israel Date: Tue, 12 Nov 2024 09:38:36 +0100 Subject: [PATCH 3/7] minor refactor (docs): rename 'commit_variant' to 'commit' --- docs/docs/tutorials/sdk/manage-prompts-with-SDK.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/tutorials/sdk/manage-prompts-with-SDK.mdx b/docs/docs/tutorials/sdk/manage-prompts-with-SDK.mdx index c5486eb831..b009dfcd2e 100644 --- a/docs/docs/tutorials/sdk/manage-prompts-with-SDK.mdx +++ b/docs/docs/tutorials/sdk/manage-prompts-with-SDK.mdx @@ -166,7 +166,7 @@ Deployed variant to environment: We're now going to commit changes to our variant. Note that this will not modify the version in deployment! -To save changes to a variant (creating a new version), we are goin to use the `VariantManager.commit_variant` method with explicit parameters. +To save changes to a variant (creating a new version), we are goin to use the `VariantManager.commit` method with explicit parameters. ```python my_prompt2 = Prompt( @@ -181,7 +181,7 @@ my_prompt2 = Prompt( # Commit the new version -variant = ag.VariantManager.commit_variant( +variant = ag.VariantManager.commit( app_slug="topic-explainer", variant_slug="new-variant", config_parameters=my_prompt2.dict() From 2477f46a02f3bd64915a3dab1811397f68fdfbd1 Mon Sep 17 00:00:00 2001 From: Abraham 'Abram' Israel Date: Tue, 12 Nov 2024 09:42:45 +0100 Subject: [PATCH 4/7] minor refactor (docs): add 'await' keyword to execute coroutines in VariantManager and DeploymentManager method(s) --- docs/docs/prompt-management/03-prompt-management-sdk.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/prompt-management/03-prompt-management-sdk.mdx b/docs/docs/prompt-management/03-prompt-management-sdk.mdx index 0b4c0e0871..221634ce58 100644 --- a/docs/docs/prompt-management/03-prompt-management-sdk.mdx +++ b/docs/docs/prompt-management/03-prompt-management-sdk.mdx @@ -90,7 +90,7 @@ print(variant) # Create a new version asynchronously (optional) # async def create_variant(): -# variant = ag.VariantManager.acreate( +# variant = await ag.VariantManager.acreate( # parameters=my_prompt.model_dump(), # app_slug="my-app-slug", # app_id="my-app-id", # you can also use `app_id` @@ -164,7 +164,7 @@ print(variant) # Commit the new version asynchronously (optional) # async def commit_variant(): -# variant = ag.VariantManager.acommit( +# variant = await ag.VariantManager.acommit( # parameters=my_prompt2.model_dump(), # app_slug="my-app-slug", # variant_slug="my-variant-slug", From c812422efd7e43b993f5a22952f1e1f80574ab6d Mon Sep 17 00:00:00 2001 From: Abraham 'Abram' Israel Date: Tue, 12 Nov 2024 11:08:50 +0100 Subject: [PATCH 5/7] refactor (docs): update async method naming in config manager for consistency across manager methods --- agenta-cli/agenta/sdk/managers/config_manager.py | 4 ++-- docs/docs/prompt-management/02-quick-start.mdx | 2 +- docs/docs/prompt-management/03-prompt-management-sdk.mdx | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/agenta-cli/agenta/sdk/managers/config_manager.py b/agenta-cli/agenta/sdk/managers/config_manager.py index 8e5e4aadd5..a58ddb94f1 100644 --- a/agenta-cli/agenta/sdk/managers/config_manager.py +++ b/agenta-cli/agenta/sdk/managers/config_manager.py @@ -93,7 +93,7 @@ def get_from_route( return parameters @staticmethod - async def async_get_from_route( + async def aget_from_route( schema: Optional[Type[T]] = None, ) -> Union[Dict[str, Any], T]: """ @@ -214,7 +214,7 @@ def get_from_registry( return config.parameters @staticmethod - async def async_get_from_registry( + async def aget_from_registry( schema: Optional[Type[T]] = None, # app_id: Optional[str] = None, diff --git a/docs/docs/prompt-management/02-quick-start.mdx b/docs/docs/prompt-management/02-quick-start.mdx index bda5a2c186..6e62c3bf1f 100644 --- a/docs/docs/prompt-management/02-quick-start.mdx +++ b/docs/docs/prompt-management/02-quick-start.mdx @@ -145,7 +145,7 @@ If your application is asynchronous, you can use the async version of the method ```python # Asynchronous fetching of configuration -config = await ag.ConfigManager.async_get_from_registry( +config = await ag.ConfigManager.aget_from_registry( app_slug="your-app-slug" ) ``` diff --git a/docs/docs/prompt-management/03-prompt-management-sdk.mdx b/docs/docs/prompt-management/03-prompt-management-sdk.mdx index 221634ce58..e0bbb18565 100644 --- a/docs/docs/prompt-management/03-prompt-management-sdk.mdx +++ b/docs/docs/prompt-management/03-prompt-management-sdk.mdx @@ -484,7 +484,7 @@ for version in versions: **Sample Output:** ```python -List of variants: +History of variants: { 'parameters': { 'temperature': 1.0, @@ -533,7 +533,7 @@ If your application uses asynchronous programming, you can use the async version ```python # Asynchronous fetching of configuration -config = await ag.ConfigManager.async_get_from_registry( +config = await ag.ConfigManager.aget_from_registry( app_slug="my-app", # app_id="my-app-id", # you can also use `app_id` variant_slug="my-variant-slug", From 064aaa5fc7a0e0b190bff87aba3d73f43bbf0e2d Mon Sep 17 00:00:00 2001 From: Abraham 'Abram' Israel Date: Tue, 12 Nov 2024 11:11:09 +0100 Subject: [PATCH 6/7] fix (tests): resolve failing sdk tests --- agenta-cli/agenta/tests/prompt_sdk/test_config_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agenta-cli/agenta/tests/prompt_sdk/test_config_manager.py b/agenta-cli/agenta/tests/prompt_sdk/test_config_manager.py index 778366800b..21febee154 100644 --- a/agenta-cli/agenta/tests/prompt_sdk/test_config_manager.py +++ b/agenta-cli/agenta/tests/prompt_sdk/test_config_manager.py @@ -151,7 +151,7 @@ async def test_afetch_configuration_and_return_dict(mock_aget_config): "max_tokens": 100, } - config = await ConfigManager.async_get_from_registry( + config = await ConfigManager.aget_from_registry( app_slug="my-app", variant_slug="new-variant", variant_version=2 ) @@ -169,7 +169,7 @@ async def test_afetch_configuration_and_return_schema(mock_aget_config): temperature=0.9, model="gpt-3.5-turbo", max_tokens=100 ) - config_as_schema = await ConfigManager.async_get_from_registry( + config_as_schema = await ConfigManager.aget_from_registry( schema=Parameters, app_slug="my-app", variant_slug="new-variant", From a13becca39f43d135ed56bef715aacfc855bd719 Mon Sep 17 00:00:00 2001 From: Abraham 'Abram' Israel Date: Tue, 12 Nov 2024 11:20:16 +0100 Subject: [PATCH 7/7] fix (cli:tests): resolve failing patched ConfigManager method --- agenta-cli/agenta/tests/prompt_sdk/test_config_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agenta-cli/agenta/tests/prompt_sdk/test_config_manager.py b/agenta-cli/agenta/tests/prompt_sdk/test_config_manager.py index 21febee154..ef99baf08d 100644 --- a/agenta-cli/agenta/tests/prompt_sdk/test_config_manager.py +++ b/agenta-cli/agenta/tests/prompt_sdk/test_config_manager.py @@ -141,7 +141,7 @@ def test_fetch_configuration_and_return_schema(mock_get_config): @pytest.mark.asyncio -@patch("agenta.ConfigManager.async_get_from_registry") +@patch("agenta.ConfigManager.aget_from_registry") async def test_afetch_configuration_and_return_dict(mock_aget_config): # Mock the API response for fetching configuration @@ -161,7 +161,7 @@ async def test_afetch_configuration_and_return_dict(mock_aget_config): @pytest.mark.asyncio -@patch("agenta.ConfigManager.async_get_from_registry") +@patch("agenta.ConfigManager.aget_from_registry") async def test_afetch_configuration_and_return_schema(mock_aget_config): # Mock the API response for fetching configuration