feat(memory-store,agents-api): Add special foreign fields to usage table#1480
feat(memory-store,agents-api): Add special foreign fields to usage table#1480
Conversation
Signed-off-by: Diwank Singh Tomer <diwank.singh@gmail.com>
CI Feedback 🧐(Feedback updated until commit 832f644)A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
| "user": str(developer.id), | ||
| "tags": developer.tags, | ||
| "custom_api_key": x_custom_api_key, | ||
| "session_id": session_id, |
There was a problem hiding this comment.
entry_id isn't being passed.
| ADD COLUMN session_id UUID NULL, | ||
| ADD COLUMN execution_id UUID NULL, | ||
| ADD COLUMN transition_id UUID NULL, | ||
| ADD COLUMN entry_id UUID NULL, | ||
| ADD COLUMN provider TEXT NULL; |
There was a problem hiding this comment.
entry_id and transition_id would be enough, though it's not that bad to add them as fields as well.
| custom_api_used: bool = False, | ||
| estimated: bool = False, | ||
| metadata: dict[str, Any] | None = None, | ||
| session_id: UUID | None = None, | ||
| execution_id: UUID | None = None, | ||
| transition_id: UUID | None = None, | ||
| entry_id: UUID | None = None, | ||
| provider: str | None = None, |
There was a problem hiding this comment.
a lot of variables, better to create a model in typespec to clean up the parameters.
| "input_messages": messages, | ||
| "output_content": [ | ||
| choice.message.content | ||
| for choice in response.choices | ||
| if hasattr(choice, "message") | ||
| and choice.message | ||
| and hasattr(choice.message, "content") | ||
| ] |
There was a problem hiding this comment.
adding all messages to the metadata adds a huge unnecessary memory overhead to the usage table.
| def extract_provider_from_model(model: str) -> str | None: | ||
| """ | ||
| Extract the provider from a model name. | ||
|
|
||
| Args: | ||
| model (str): The model name (e.g., "gpt-4", "claude-3-sonnet", "openai/gpt-4") | ||
|
|
||
| Returns: | ||
| str | None: The provider name (e.g., "openai", "anthropic") or None if unknown |
There was a problem hiding this comment.
not sure about the functionality of this function. Litellm in general with a self-hosted proxy acts very weirdly towards providers. A better way I think is to determine the provider by the api key provided in the litellm-config.
Signed-off-by: Diwank Singh Tomer diwank.singh@gmail.com