-
Notifications
You must be signed in to change notification settings - Fork 0
prompt management first pass - AGENT-431 #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis update introduces a new prompt compilation client ( Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AgentContext
participant PromptClient
participant AgentuityService
User->>AgentContext: Request prompt compilation
AgentContext->>PromptClient: compile(name, variables, version)
PromptClient->>AgentuityService: HTTP POST /prompt/compile
AgentuityService-->>PromptClient: JSON response (compiled prompt data)
PromptClient-->>AgentContext: PromptCompileResult
AgentContext-->>User: Return compiled prompt
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
agentuity/server/context.py (1)
69-71: Consider maintaining consistency with other services initialization pattern.While the implementation is functionally correct, the
PromptClientis instantiated directly in the constructor whereas other services (kv,vector,objectstore) are passed in via theservicesdict. For consistency, consider either:
- Adding
promptto the services dict passed to the constructor, or- Document why
promptis treated differently from other servicesagentuity/server/prompt.py (4)
154-154: Consider making the API version configurable.The API endpoint uses a hardcoded date version
2025-03-17. This should either be:
- Made configurable via environment variable or parameter
- Documented why this specific date version is used
- Updated to reflect the actual API version pattern
159-164: Consider reusing HTTP client for better performance.Creating a new
httpx.AsyncClientfor each request prevents connection pooling. Consider creating a client instance at the class level and reusing it across requests for better performance.Example implementation:
def __init__(self, base_url: str, api_key: str, tracer: trace.Tracer): self.base_url = base_url self.api_key = api_key self.tracer = tracer self._client = httpx.AsyncClient() async def __aenter__(self): return self async def __aexit__(self, exc_type, exc_val, exc_tb): await self._client.aclose()
230-235: Consider using more specific exception types.The code raises generic
Exceptioninstances throughout. Consider creating specific exception classes likePromptCompilationError,PromptServiceConnectionError, etc., to make error handling more precise for callers.
222-225: Improve error message for non-200 responses.When the response status is not 200, the error message only includes the status code. Consider including more context such as the actual HTTP status code and potentially the response body (if not sensitive).
- raise Exception(f"Failed to compile prompt: {response.status_code}") + raise Exception(f"Failed to compile prompt: HTTP {response.status_code} - {error_msg}")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
agentuity/__init__.py(2 hunks)agentuity/server/__init__.py(1 hunks)agentuity/server/context.py(2 hunks)agentuity/server/prompt.py(1 hunks)agentuity/server/types.py(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
agentuity/server/context.py (1)
agentuity/server/prompt.py (1)
PromptClient(82-235)
agentuity/server/__init__.py (1)
agentuity/server/prompt.py (2)
PromptClient(82-235)PromptCompileResult(70-79)
agentuity/__init__.py (1)
agentuity/server/prompt.py (2)
PromptClient(82-235)PromptCompileResult(70-79)
agentuity/server/types.py (1)
agentuity/io/telegram.py (2)
chat_id(64-65)message_id(60-61)
🔇 Additional comments (3)
agentuity/__init__.py (1)
15-16: LGTM! Properly exposed new prompt management classes.The new
PromptClientandPromptCompileResultclasses are correctly imported and added to the__all__list, following the existing pattern for public API exposure.Also applies to: 32-33
agentuity/server/__init__.py (1)
27-30: LGTM! Explicit re-export pattern properly implemented.The use of
Name as Namealiasing pattern is correct for ensuring these classes are properly re-exported from the server module.agentuity/server/types.py (1)
300-306: LGTM! Clean formatting improvement.The multi-line parameter formatting with trailing comma improves readability and makes future changes cleaner.
Add Prompt Management Service Integration
🎯 What We Built
This PR introduces a new Prompt Management Service integration to the Agentuity Python SDK, enabling dynamic prompt template compilation with variable substitution and version management. This feature allows agents to compile prompt templates stored in Agentuity Cloud at runtime, providing flexibility and centralized prompt management.
🔧 Key Components Added
1. PromptClient (
agentuity/server/prompt.py)2. Data Models
CompilePromptRequest: Request model for prompt compilationCompilePromptResponse: Response model with success/error handlingPromptCompileResult: Result container with compiled content and metadata3. Integration Points
promptclient for easy access in agent implementationsPromptClientandPromptCompileResultin main package🚀 Why We Built This
Centralized Prompt Management
Dynamic Variable Substitution
Observability & Debugging
Developer Experience
await context.prompt.compile("template_name", variables)�� Usage Example
Summary by CodeRabbit
New Features
Style