Skip to content

[Docs] Document StandardLoggingVectorStoreRequest #10535

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

Merged
merged 1 commit into from
May 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/my-website/docs/proxy/logging_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ Inherits from `StandardLoggingUserAPIKeyMetadata` and adds:
| `spend_logs_metadata` | `Optional[dict]` | Key-value pairs for spend logging |
| `requester_ip_address` | `Optional[str]` | Requester's IP address |
| `requester_metadata` | `Optional[dict]` | Additional requester metadata |
| `vector_store_request_metadata` | `Optional[List[StandardLoggingVectorStoreRequest]]` | Vector store request metadata |


## StandardLoggingVectorStoreRequest

| Field | Type | Description |
|-------|------|-------------|
| vector_store_id | Optional[str] | ID of the vector store |
| custom_llm_provider | Optional[str] | Custom LLM provider the vector store is associated with (e.g., bedrock, openai, anthropic) |
| query | Optional[str] | Query to the vector store |
| vector_store_search_response | Optional[VectorStoreSearchResponse] | OpenAI format vector store search response |
| start_time | Optional[float] | Start time of the vector store request |
| end_time | Optional[float] | End time of the vector store request |


## StandardLoggingAdditionalHeaders

Expand Down
12 changes: 6 additions & 6 deletions litellm/integrations/vector_stores/bedrock_vector_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
from litellm.types.utils import StandardLoggingVectorStoreRequest
from litellm.types.vector_stores import (
VectorStoreResultContent,
VectorStoreSearchResponse,
VectorStoreSearchResult,
VectorStorSearchResponse,
)
from litellm.utils import load_credentials_from_list

Expand Down Expand Up @@ -110,7 +110,7 @@ async def async_get_chat_completion_prompt(
#################################################################################################
########## LOGGING for Standard Logging Payload, Langfuse, s3, LiteLLM DB etc. ##################
#################################################################################################
vector_store_search_response: VectorStorSearchResponse = (
vector_store_search_response: VectorStoreSearchResponse = (
self.transform_bedrock_kb_response_to_vector_store_search_response(
bedrock_kb_response=bedrock_kb_response, query=query
)
Expand All @@ -136,15 +136,15 @@ def transform_bedrock_kb_response_to_vector_store_search_response(
self,
bedrock_kb_response: BedrockKBResponse,
query: str,
) -> VectorStorSearchResponse:
) -> VectorStoreSearchResponse:
"""
Transform a BedrockKBResponse to a VectorStorSearchResponse
Transform a BedrockKBResponse to a VectorStoreSearchResponse
"""
retrieval_results: Optional[List[BedrockKBRetrievalResult]] = (
bedrock_kb_response.get("retrievalResults", None)
)
vector_store_search_response: VectorStorSearchResponse = (
VectorStorSearchResponse(search_query=query, data=[])
vector_store_search_response: VectorStoreSearchResponse = (
VectorStoreSearchResponse(search_query=query, data=[])
)
if retrieval_results is None:
return vector_store_search_response
Expand Down
6 changes: 3 additions & 3 deletions litellm/types/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
from .rerank import RerankResponse

if TYPE_CHECKING:
from .vector_stores import VectorStorSearchResponse
from .vector_stores import VectorStoreSearchResponse
else:
VectorStorSearchResponse = Any
VectorStoreSearchResponse = Any


def _generate_id(): # private helper function
Expand Down Expand Up @@ -1740,7 +1740,7 @@ class StandardLoggingVectorStoreRequest(TypedDict, total=False):
Query to the vector store
"""

vector_store_search_response: Optional[VectorStorSearchResponse]
vector_store_search_response: Optional[VectorStoreSearchResponse]
"""
OpenAI format vector store search response
"""
Expand Down
2 changes: 1 addition & 1 deletion litellm/types/vector_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class VectorStoreSearchResult(TypedDict, total=False):
content: Optional[List[VectorStoreResultContent]]


class VectorStorSearchResponse(TypedDict, total=False):
class VectorStoreSearchResponse(TypedDict, total=False):
"""Response after searching a vector store"""

object: Literal[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from litellm.llms.custom_httpx.http_handler import HTTPHandler, AsyncHTTPHandler
from litellm.integrations.custom_logger import CustomLogger
from litellm.types.utils import StandardLoggingPayload, StandardLoggingVectorStoreRequest
from litellm.types.vector_stores import VectorStorSearchResponse
from litellm.types.vector_stores import VectorStoreSearchResponse

class TestCustomLogger(CustomLogger):
def __init__(self):
Expand Down Expand Up @@ -262,7 +262,7 @@ async def test_logging_with_knowledge_base_hook(setup_vector_store_registry):
assert vector_store_request_metadata.get("custom_llm_provider") == "bedrock"


vector_store_search_response: VectorStorSearchResponse = vector_store_request_metadata.get("vector_store_search_response")
vector_store_search_response: VectorStoreSearchResponse = vector_store_request_metadata.get("vector_store_search_response")
assert vector_store_search_response is not None
assert vector_store_search_response.get("search_query") == "what is litellm?"
assert len(vector_store_search_response.get("data", [])) >=0
Expand Down
Loading