AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(backend/chat): Use latest prompt label in non-production environments (#11977)
Swifty3ae5eabf9de8
diff --git a/autogpt_platform/backend/backend/api/features/chat/service.py b/autogpt_platform/backend/backend/api/features/chat/service.pyindex bf7dbb6c7e..06da6bdf2b 100644--- a/autogpt_platform/backend/backend/api/features/chat/service.py+++ b/autogpt_platform/backend/backend/api/features/chat/service.py@@ -33,7 +33,7 @@ from backend.data.understanding import (get_business_understanding,)from backend.util.exceptions import NotFoundError-from backend.util.settings import Settings+from backend.util.settings import AppEnvironment, Settingsfrom . import db as chat_dbfrom . import stream_registry@@ -222,8 +222,18 @@ async def _get_system_prompt_template(context: str) -> str:try:# cache_ttl_seconds=0 disables SDK caching to always get the latest prompt# Use asyncio.to_thread to avoid blocking the event loop+ # In non-production environments, fetch the latest prompt version+ # instead of the production-labeled version for easier testing+ label = (+ None+ if settings.config.app_env == AppEnvironment.PRODUCTION+ else "latest"+ )prompt = await asyncio.to_thread(- langfuse.get_prompt, config.langfuse_prompt_name, cache_ttl_seconds=0+ langfuse.get_prompt,+ config.langfuse_prompt_name,+ label=label,+ cache_ttl_seconds=0,)return prompt.compile(users_information=context)except Exception as e: