Python: updated docstrings (#1225)

* updated docstrings

* fix tests and mypy

* hosted file search docstring update

* updated versions
This commit is contained in:
Eduard van Valkenburg
2025-10-06 18:04:39 +02:00
committed by GitHub
Unverified
parent b2ab9931fd
commit 714e7b50d4
32 changed files with 592 additions and 319 deletions
@@ -82,7 +82,7 @@ class A2AAgent(BaseAgent):
) -> None:
"""Initialize the A2AAgent.
Args:
Keyword Args:
name: The name of the agent.
id: The unique identifier for the agent, will be created automatically if not provided.
description: A brief description of the agent's purpose.
@@ -155,6 +155,8 @@ class A2AAgent(BaseAgent):
Args:
messages: The message(s) to send to the agent.
Keyword Args:
thread: The conversation thread associated with the message(s).
kwargs: Additional keyword arguments.
@@ -179,6 +181,8 @@ class A2AAgent(BaseAgent):
Args:
messages: The message(s) to send to the agent.
Keyword Args:
thread: The conversation thread associated with the message(s).
kwargs: Additional keyword arguments.
@@ -16,6 +16,7 @@ DEFAULT_SCOPES = ["https://api.powerplatform.com/.default"]
def acquire_token(
*,
client_id: str,
tenant_id: str,
username: str | None = None,
@@ -27,7 +28,7 @@ def acquire_token(
This function attempts to acquire a token silently first (using cached tokens),
and falls back to interactive authentication if needed.
Args:
Keyword Args:
client_id: The client ID of the application.
tenant_id: The tenant ID for authentication.
username: Optional username to filter accounts.
@@ -102,6 +102,8 @@ class CopilotStudioAgent(BaseAgent):
a new client will be created using the other parameters.
settings: Optional pre-configured ConnectionSettings. If not provided,
settings will be created from the other parameters.
Keyword Args:
id: id of the CopilotAgent
name: Name of the CopilotAgent
description: Description of the CopilotAgent
@@ -224,6 +226,8 @@ class CopilotStudioAgent(BaseAgent):
Args:
messages: The message(s) to send to the agent.
Keyword Args:
thread: The conversation thread associated with the message(s).
kwargs: Additional keyword arguments.
@@ -263,6 +267,8 @@ class CopilotStudioAgent(BaseAgent):
Args:
messages: The message(s) to send to the agent.
Keyword Args:
thread: The conversation thread associated with the message(s).
kwargs: Additional keyword arguments.
@@ -159,6 +159,8 @@ class AgentProtocol(Protocol):
Args:
messages: The message(s) to send to the agent.
Keyword Args:
thread: The conversation thread associated with the message(s).
kwargs: Additional keyword arguments.
@@ -183,6 +185,8 @@ class AgentProtocol(Protocol):
Args:
messages: The message(s) to send to the agent.
Keyword Args:
thread: The conversation thread associated with the message(s).
kwargs: Additional keyword arguments.
@@ -261,7 +265,7 @@ class BaseAgent(SerializationMixin):
) -> None:
"""Initialize a BaseAgent instance.
Args:
Keyword Args:
id: The unique identifier of the agent. If no id is provided,
a new UUID will be generated.
name: The name of the agent, can be None.
@@ -319,7 +323,7 @@ class BaseAgent(SerializationMixin):
def get_new_thread(self, **kwargs: Any) -> AgentThread:
"""Return a new AgentThread instance that is compatible with the agent.
Args:
Keyword Args:
kwargs: Additional keyword arguments passed to AgentThread.
Returns:
@@ -332,6 +336,8 @@ class BaseAgent(SerializationMixin):
Args:
serialized_thread: The serialized thread data.
Keyword Args:
kwargs: Additional keyword arguments.
Returns:
@@ -354,7 +360,7 @@ class BaseAgent(SerializationMixin):
) -> AIFunction[BaseModel, str]:
"""Create an AIFunction tool that wraps this agent.
Args:
Keyword Args:
name: The name for the tool. If None, uses the agent's name.
description: The description for the tool. If None, uses the agent's description or empty string.
arg_name: The name of the function argument (default: "task").
@@ -554,6 +560,8 @@ class ChatAgent(BaseAgent):
chat_client: The chat client to use for the agent.
instructions: Optional instructions for the agent.
These will be put into the messages sent to the chat client service as a system message.
Keyword Args:
id: The unique identifier for the agent. Will be created automatically if not provided.
name: The name of the agent.
description: A brief description of the agent's purpose.
@@ -718,6 +726,8 @@ class ChatAgent(BaseAgent):
Args:
messages: The messages to process.
Keyword Args:
thread: The thread to use for the agent.
frequency_penalty: The frequency penalty to use.
logit_bias: The logit bias to use.
@@ -847,6 +857,8 @@ class ChatAgent(BaseAgent):
Args:
messages: The messages to process.
Keyword Args:
thread: The thread to use for the agent.
frequency_penalty: The frequency penalty to use.
logit_bias: The logit bias to use.
@@ -963,7 +975,7 @@ class ChatAgent(BaseAgent):
If you run with ``store=True``, the response will include a thread_id and that will be set.
Otherwise a message store is created from the default factory.
Args:
Keyword Args:
service_thread_id: Optional service managed thread ID.
kwargs: Not used at present.
@@ -1030,7 +1042,7 @@ class ChatAgent(BaseAgent):
This method prepares the conversation thread, merges context provider data,
and assembles the final message list for the chat client.
Args:
Keyword Args:
thread: The conversation thread.
input_messages: Messages to process.
@@ -123,6 +123,8 @@ class ChatClientProtocol(Protocol):
Args:
messages: The sequence of input messages to send.
Keyword Args:
frequency_penalty: The frequency penalty to use.
logit_bias: The logit bias to use.
max_tokens: The maximum number of tokens to generate.
@@ -180,6 +182,8 @@ class ChatClientProtocol(Protocol):
Args:
messages: The sequence of input messages to send.
Keyword Args:
frequency_penalty: The frequency penalty to use.
logit_bias: The logit bias to use.
max_tokens: The maximum number of tokens to generate.
@@ -259,7 +263,7 @@ def merge_chat_options(
parameters take precedence and override the corresponding values in base_chat_options.
Tools from both sources are combined into a single list.
Args:
Keyword Args:
base_chat_options: Optional base ChatOptions to merge with direct parameters.
model: The model to use for the agent.
frequency_penalty: The frequency penalty to use.
@@ -398,7 +402,7 @@ class BaseChatClient(SerializationMixin, ABC):
) -> None:
"""Initialize a BaseChatClient instance.
Args:
Keyword Args:
middleware: Middleware for the client.
additional_properties: Additional properties for the client.
kwargs: Additional keyword arguments (merged into additional_properties).
@@ -414,7 +418,7 @@ class BaseChatClient(SerializationMixin, ABC):
Extracts additional_properties fields to the root level.
Args:
Keyword Args:
exclude: Set of field names to exclude from serialization.
exclude_none: Whether to exclude None values from the output. Defaults to True.
@@ -452,7 +456,7 @@ class BaseChatClient(SerializationMixin, ABC):
def _filter_internal_kwargs(self, kwargs: dict[str, Any]) -> dict[str, Any]:
"""Filter out internal framework parameters that shouldn't be passed to chat client implementations.
Args:
Keyword Args:
kwargs: The original kwargs dictionary.
Returns:
@@ -510,7 +514,7 @@ class BaseChatClient(SerializationMixin, ABC):
) -> ChatResponse:
"""Send a chat request to the AI service.
Args:
Keyword Args:
messages: The chat messages to send.
chat_options: The options for the request.
kwargs: Any additional keyword arguments.
@@ -529,7 +533,7 @@ class BaseChatClient(SerializationMixin, ABC):
) -> AsyncIterable[ChatResponseUpdate]:
"""Send a streaming chat request to the AI service.
Args:
Keyword Args:
messages: The chat messages to send.
chat_options: The chat_options for the request.
kwargs: Any additional keyword arguments.
@@ -582,6 +586,8 @@ class BaseChatClient(SerializationMixin, ABC):
Args:
messages: The message or messages to send to the model.
Keyword Args:
frequency_penalty: The frequency penalty to use.
logit_bias: The logit bias to use.
max_tokens: The maximum number of tokens to generate.
@@ -674,6 +680,8 @@ class BaseChatClient(SerializationMixin, ABC):
Args:
messages: The message or messages to send to the model.
Keyword Args:
frequency_penalty: The frequency penalty to use.
logit_bias: The logit bias to use.
max_tokens: The maximum number of tokens to generate.
@@ -802,7 +810,7 @@ class BaseChatClient(SerializationMixin, ABC):
This is a convenience method that creates a ChatAgent instance with this
chat client already configured.
Args:
Keyword Args:
id: The unique identifier for the agent. Will be created automatically if not provided.
name: The name of the agent.
description: A brief description of the agent's purpose.
@@ -542,6 +542,8 @@ class MCPTool:
Args:
tool_name: The name of the tool to call.
Keyword Args:
kwargs: Arguments to pass to the tool.
Returns:
@@ -569,6 +571,8 @@ class MCPTool:
Args:
prompt_name: The name of the prompt to retrieve.
Keyword Args:
kwargs: Arguments to pass to the prompt.
Returns:
@@ -683,6 +687,8 @@ class MCPStdioTool(MCPTool):
Args:
name: The name of the tool.
command: The command to run the MCP server.
Keyword Args:
load_tools: Whether to load tools from the MCP server.
load_prompts: Whether to load prompts from the MCP server.
request_timeout: The default timeout in seconds for all requests.
@@ -782,6 +788,8 @@ class MCPStreamableHTTPTool(MCPTool):
Args:
name: The name of the tool.
url: The URL of the MCP server.
Keyword Args:
load_tools: Whether to load tools from the MCP server.
load_prompts: Whether to load prompts from the MCP server.
request_timeout: The default timeout in seconds for all requests.
@@ -880,6 +888,8 @@ class MCPWebsocketTool(MCPTool):
Args:
name: The name of the tool.
url: The URL of the MCP server.
Keyword Args:
load_tools: Whether to load tools from the MCP server.
load_prompts: Whether to load prompts from the MCP server.
request_timeout: The default timeout in seconds for all requests.
@@ -131,6 +131,8 @@ class ContextProvider(ABC):
request_messages: The messages that were sent to the model/agent.
response_messages: The messages that were returned by the model/agent.
invoke_exception: The exception that was thrown, if any.
Keyword Args:
kwargs: Additional keyword arguments (not used at present).
"""
pass
@@ -144,6 +146,8 @@ class ContextProvider(ABC):
Args:
messages: The most recent messages that the agent is being invoked with.
Keyword Args:
kwargs: Additional keyword arguments (not used at present).
Returns:
@@ -4,6 +4,7 @@ import inspect
from abc import ABC, abstractmethod
from collections.abc import AsyncIterable, Awaitable, Callable, MutableSequence
from enum import Enum
from functools import update_wrapper
from typing import TYPE_CHECKING, Any, ClassVar, Generic, TypeAlias, TypeVar
from ._serialization import SerializationMixin
@@ -1290,8 +1291,8 @@ def use_agent_middleware(agent_class: type[TAgent]) -> type[TAgent]:
# No middleware, execute directly
return original_run_stream(self, normalized_messages, thread=thread, **kwargs) # type: ignore
agent_class.run = middleware_enabled_run # type: ignore
agent_class.run_stream = middleware_enabled_run_stream # type: ignore
agent_class.run = update_wrapper(middleware_enabled_run, original_run) # type: ignore
agent_class.run_stream = update_wrapper(middleware_enabled_run_stream, original_run_stream) # type: ignore
return agent_class
@@ -1440,8 +1441,10 @@ def use_chat_middleware(chat_client_class: type[TChatClient]) -> type[TChatClien
return _stream_generator()
# Replace methods
chat_client_class.get_response = middleware_enabled_get_response # type: ignore
chat_client_class.get_streaming_response = middleware_enabled_get_streaming_response # type: ignore
chat_client_class.get_response = update_wrapper(middleware_enabled_get_response, original_get_response) # type: ignore
chat_client_class.get_streaming_response = update_wrapper( # type: ignore
middleware_enabled_get_streaming_response, original_get_streaming_response
)
return chat_client_class
@@ -1525,12 +1528,14 @@ def _merge_and_filter_chat_middleware(
return middleware["chat"] # type: ignore[return-value]
def extract_and_merge_function_middleware(chat_client: Any, kwargs: dict[str, Any]) -> None:
def extract_and_merge_function_middleware(chat_client: Any, **kwargs: Any) -> None:
"""Extract function middleware from chat client and merge with existing pipeline in kwargs.
Args:
chat_client: The chat client instance to extract middleware from.
kwargs: Dictionary containing middleware and pipeline information.
Keyword Args:
**kwargs: Dictionary containing middleware and pipeline information.
"""
# Get middleware sources
client_middleware = getattr(chat_client, "middleware", None) if hasattr(chat_client, "middleware") else None
@@ -47,7 +47,7 @@ class SerializationProtocol(Protocol):
def to_dict(self, **kwargs: Any) -> dict[str, Any]:
"""Convert the instance to a dictionary.
Args:
Keyword Args:
kwargs: Additional keyword arguments for serialization.
Returns:
@@ -61,6 +61,8 @@ class SerializationProtocol(Protocol):
Args:
value: Dictionary containing the instance data (positional-only).
Keyword Args:
kwargs: Additional keyword arguments for deserialization.
Returns:
@@ -123,7 +125,7 @@ class SerializationMixin:
Examples:
.. code-block:: python
from libary import Client
from library import Client
class MyClass(SerializationMixin):
@@ -147,7 +149,7 @@ class SerializationMixin:
def to_dict(self, *, exclude: set[str] | None = None, exclude_none: bool = True) -> dict[str, Any]:
"""Convert the instance and any nested objects to a dictionary.
Args:
Keyword Args:
exclude: The set of field names to exclude from serialization.
exclude_none: Whether to exclude None values from the output. Defaults to True.
@@ -213,7 +215,7 @@ class SerializationMixin:
def to_json(self, *, exclude: set[str] | None = None, exclude_none: bool = True) -> str:
"""Convert the instance to a JSON string.
Args:
Keyword Args:
exclude: The set of field names to exclude from serialization.
exclude_none: Whether to exclude None values from the output. Defaults to True.
@@ -224,12 +226,14 @@ class SerializationMixin:
@classmethod
def from_dict(
cls: type[TClass], value: MutableMapping[str, Any], /, dependencies: MutableMapping[str, Any] | None = None
cls: type[TClass], value: MutableMapping[str, Any], /, *, dependencies: MutableMapping[str, Any] | None = None
) -> TClass:
"""Create an instance from a dictionary.
Args:
value: The dictionary containing the instance data (positional-only).
Keyword Args:
dependencies: The dictionary mapping dependency keys to values.
Keys should be in format ``"<type>.<parameter>"`` or ``"<type>.<dict-parameter>.<key>"``.
@@ -278,11 +282,13 @@ class SerializationMixin:
return cls(**kwargs)
@classmethod
def from_json(cls: type[TClass], value: str, /, dependencies: MutableMapping[str, Any] | None = None) -> TClass:
def from_json(cls: type[TClass], value: str, /, *, dependencies: MutableMapping[str, Any] | None = None) -> TClass:
"""Create an instance from a JSON string.
Args:
value: The JSON string containing the instance data (positional-only).
Keyword Args:
dependencies: The dictionary mapping dependency keys to values.
Keys should be in format ``"<type>.<parameter>"`` or ``"<type>.<dict-parameter>.<key>"``.
@@ -81,6 +81,8 @@ class ChatMessageStoreProtocol(Protocol):
Args:
serialized_store_state: The previously serialized state data containing messages.
Keyword Args:
**kwargs: Additional arguments for deserialization.
Returns:
@@ -93,7 +95,9 @@ class ChatMessageStoreProtocol(Protocol):
Args:
serialized_store_state: Previously serialized state data containing messages.
**kwargs: Additional arguments for deserialization.
Keyword Args:
kwargs: Additional arguments for deserialization.
"""
...
@@ -103,8 +107,8 @@ class ChatMessageStoreProtocol(Protocol):
This method, together with ``deserialize()`` can be used to save and load messages from a persistent store
if this store only has messages in memory.
Args:
**kwargs: Additional arguments for serialization.
Keyword Args:
kwargs: Additional arguments for serialization.
Returns:
The serialized state data that can be used with ``deserialize()``.
@@ -215,6 +219,8 @@ class ChatMessageStore:
Args:
serialized_store_state: Previously serialized state data containing messages.
Keyword Args:
**kwargs: Additional arguments for deserialization.
Returns:
@@ -230,6 +236,8 @@ class ChatMessageStore:
Args:
serialized_store_state: Previously serialized state data containing messages.
Keyword Args:
**kwargs: Additional arguments for deserialization.
"""
if not serialized_store_state:
@@ -241,7 +249,7 @@ class ChatMessageStore:
async def serialize(self, **kwargs: Any) -> Any:
"""Serialize the current store state for persistence.
Args:
Keyword Args:
**kwargs: Additional arguments for serialization.
Returns:
@@ -385,7 +393,7 @@ class AgentThread:
async def serialize(self, **kwargs: Any) -> dict[str, Any]:
"""Serializes the current object's state.
Args:
Keyword Args:
**kwargs: Arguments for serialization.
"""
chat_message_store_state = None
@@ -409,6 +417,8 @@ class AgentThread:
Args:
serialized_thread_state: The serialized thread state as a dictionary.
Keyword Args:
message_store: Optional ChatMessageStoreProtocol to use for managing messages.
If not provided, a new ChatMessageStore will be created if needed.
**kwargs: Additional arguments for deserialization.
@@ -442,7 +452,14 @@ class AgentThread:
serialized_thread_state: dict[str, Any],
**kwargs: Any,
) -> None:
"""Deserializes the state from a dictionary into the thread properties."""
"""Deserializes the state from a dictionary into the thread properties.
Args:
serialized_thread_state: The serialized thread state as a dictionary.
Keyword Args:
**kwargs: Additional arguments for deserialization.
"""
state = AgentThreadState.model_validate(serialized_thread_state)
if state.service_thread_id is not None:
+12 -9
View File
@@ -223,7 +223,7 @@ class BaseTool(SerializationMixin):
) -> None:
"""Initialize the BaseTool.
Args:
Keyword Args:
name: The name of the tool.
description: A description of the tool.
additional_properties: Additional properties associated with the tool.
@@ -270,7 +270,7 @@ class HostedCodeInterpreterTool(BaseTool):
) -> None:
"""Initialize the HostedCodeInterpreterTool.
Args:
Keyword Args:
inputs: A list of contents that the tool can accept as input. Defaults to None.
This should mostly be HostedFileContent or HostedVectorStoreContent.
Can also be DataContent, depending on the service used.
@@ -322,7 +322,7 @@ class HostedWebSearchTool(BaseTool):
):
"""Initialize a HostedWebSearchTool.
Args:
Keyword Args:
description: A description of the tool.
additional_properties: Additional properties associated with the tool
(e.g., {"user_location": {"city": "Seattle", "country": "US"}}).
@@ -405,7 +405,7 @@ class HostedMCPTool(BaseTool):
) -> None:
"""Create a hosted MCP tool.
Args:
Keyword Args:
name: The name of the tool.
description: A description of the tool.
url: The URL of the tool.
@@ -476,6 +476,7 @@ class HostedFileSearchTool(BaseTool):
def __init__(
self,
*,
inputs: "Contents | dict[str, Any] | str | list[Contents | dict[str, Any] | str] | None" = None,
max_results: int | None = None,
description: str | None = None,
@@ -484,7 +485,7 @@ class HostedFileSearchTool(BaseTool):
):
"""Initialize a FileSearchTool.
Args:
Keyword Args:
inputs: A list of contents that the tool can accept as input. Defaults to None.
This should be one or more HostedVectorStoreContents.
When supplying a list, it can contain:
@@ -597,7 +598,7 @@ class AIFunction(BaseTool, Generic[ArgsT, ReturnT]):
) -> None:
"""Initialize the AIFunction.
Args:
Keyword Args:
name: The name of the function.
description: A description of the function.
approval_mode: Whether or not approval is required to run this tool.
@@ -630,7 +631,7 @@ class AIFunction(BaseTool, Generic[ArgsT, ReturnT]):
) -> ReturnT:
"""Run the AI function with the provided arguments as a Pydantic model.
Args:
Keyword Args:
arguments: A Pydantic model instance containing the arguments for the function.
kwargs: Keyword arguments to pass to the function, will not be used if ``arguments`` is provided.
@@ -938,6 +939,8 @@ async def _auto_invoke_function(
Args:
function_call_content: The function call content from the model.
custom_args: Additional custom arguments to merge with parsed arguments.
Keyword Args:
tool_map: A mapping of tool names to AIFunction instances.
sequence_index: The index of the function call in the sequence.
request_index: The index of the request iteration.
@@ -1214,7 +1217,7 @@ def _handle_function_calls_response(
)
# Extract and merge function middleware from chat client with kwargs pipeline
extract_and_merge_function_middleware(self, kwargs)
extract_and_merge_function_middleware(self, **kwargs)
# Extract the middleware pipeline before calling the underlying function
# because the underlying function may not preserve it in kwargs
@@ -1346,7 +1349,7 @@ def _handle_function_calls_streaming_response(
)
# Extract and merge function middleware from chat client with kwargs pipeline
extract_and_merge_function_middleware(self, kwargs)
extract_and_merge_function_middleware(self, **kwargs)
# Extract the middleware pipeline before calling the underlying function
# because the underlying function may not preserve it in kwargs
+182 -64
View File
@@ -246,6 +246,8 @@ class UsageDetails(SerializationMixin):
input_token_count: The number of tokens in the input.
output_token_count: The number of tokens in the output.
total_token_count: The total number of tokens used to produce the response.
Keyword Args:
**kwargs: Additional token counts, can be set by passing keyword arguments.
They can be retrieved through the `additional_counts` property.
"""
@@ -263,7 +265,7 @@ class UsageDetails(SerializationMixin):
def to_dict(self, *, exclude_none: bool = True, exclude: set[str] | None = None) -> dict[str, Any]:
"""Convert the UsageDetails instance to a dictionary.
Args:
Keyword Args:
exclude_none: Whether to exclude None values from the output.
exclude: Set of field names to exclude from the output.
@@ -382,7 +384,7 @@ class TextSpanRegion(SerializationMixin):
) -> None:
"""Initialize TextSpanRegion.
Args:
Keyword Args:
start_index: The start index of the text span.
end_index: The end index of the text span.
**kwargs: Additional keyword arguments.
@@ -415,7 +417,7 @@ class BaseAnnotation(SerializationMixin):
) -> None:
"""Initialize BaseAnnotation.
Args:
Keyword Args:
annotated_regions: A list of regions that have been annotated. Can be region objects or dicts.
additional_properties: Optional additional properties associated with the content.
raw_representation: Optional raw representation of the content from an underlying implementation.
@@ -447,7 +449,7 @@ class BaseAnnotation(SerializationMixin):
Extracts additional_properties fields to the root level.
Args:
Keyword Args:
exclude: Set of field names to exclude from serialization.
exclude_none: Whether to exclude None values from the output. Defaults to True.
@@ -508,7 +510,7 @@ class CitationAnnotation(BaseAnnotation):
) -> None:
"""Initialize CitationAnnotation.
Args:
Keyword Args:
title: The title of the cited content.
url: The URL of the cited content.
file_id: The file identifier of the cited content, if applicable.
@@ -563,7 +565,7 @@ class BaseContent(SerializationMixin):
) -> None:
"""Initialize BaseContent.
Args:
Keyword Args:
annotations: Optional annotations associated with the content. Can be annotation objects or dicts.
additional_properties: Optional additional properties associated with the content.
raw_representation: Optional raw representation of the content from an underlying implementation.
@@ -597,7 +599,7 @@ class BaseContent(SerializationMixin):
Extracts additional_properties fields to the root level.
Args:
Keyword Args:
exclude: Set of field names to exclude from serialization.
exclude_none: Whether to exclude None values from the output. Defaults to True.
@@ -653,6 +655,8 @@ class TextContent(BaseContent):
Args:
text: The text content represented by this instance.
Keyword Args:
additional_properties: Optional additional properties associated with the content.
raw_representation: Optional raw representation of the content.
annotations: Optional annotations associated with the content.
@@ -793,6 +797,8 @@ class TextReasoningContent(BaseContent):
Args:
text: The text content represented by this instance.
Keyword Args:
additional_properties: Optional additional properties associated with the content.
raw_representation: Optional raw representation of the content.
annotations: Optional annotations associated with the content.
@@ -891,6 +897,10 @@ class TextReasoningContent(BaseContent):
class DataContent(BaseContent):
"""Represents binary data content with an associated media type (also known as a MIME type).
Important:
This is for binary data that is represented as a data URI, not for online resources.
Use ``UriContent`` for online resources.
Attributes:
uri: The URI of the data represented by this instance, typically in the form of a data URI.
Should be in the form: "data:{media_type};base64,{base64_data}".
@@ -930,11 +940,11 @@ class DataContent(BaseContent):
) -> None:
"""Initializes a DataContent instance with a URI.
Remarks:
Important:
This is for binary data that is represented as a data URI, not for online resources.
Use `UriContent` for online resources.
Use ``UriContent`` for online resources.
Args:
Keyword Args:
uri: The URI of the data represented by this instance.
Should be in the form: "data:{media_type};base64,{base64_data}".
annotations: Optional annotations associated with the content.
@@ -956,11 +966,11 @@ class DataContent(BaseContent):
) -> None:
"""Initializes a DataContent instance with binary data.
Remarks:
Important:
This is for binary data that is represented as a data URI, not for online resources.
Use `UriContent` for online resources.
Use ``UriContent`` for online resources.
Args:
Keyword Args:
data: The binary data represented by this instance.
The data is transformed into a base64-encoded data URI.
media_type: The media type of the data.
@@ -983,11 +993,11 @@ class DataContent(BaseContent):
) -> None:
"""Initializes a DataContent instance.
Remarks:
Important:
This is for binary data that is represented as a data URI, not for online resources.
Use `UriContent` for online resources.
Use ``UriContent`` for online resources.
Args:
Keyword Args:
uri: The URI of the data represented by this instance.
Should be in the form: "data:{media_type};base64,{base64_data}".
data: The binary data represented by this instance.
@@ -1041,9 +1051,9 @@ class DataContent(BaseContent):
class UriContent(BaseContent):
"""Represents a URI content.
Remarks:
Important:
This is used for content that is identified by a URI, such as an image or a file.
For (binary) data URIs, use `DataContent` instead.
For (binary) data URIs, use ``DataContent`` instead.
Attributes:
uri: The URI of the content, e.g., 'https://example.com/image.png'.
@@ -1094,6 +1104,8 @@ class UriContent(BaseContent):
Args:
uri: The URI of the content.
media_type: The media type of the content.
Keyword Args:
annotations: Optional annotations associated with the content.
additional_properties: Optional additional properties associated with the content.
raw_representation: Optional raw representation of the content.
@@ -1110,6 +1122,13 @@ class UriContent(BaseContent):
self.type: Literal["uri"] = "uri"
def has_top_level_media_type(self, top_level_media_type: Literal["application", "audio", "image", "text"]) -> bool:
"""Returns a boolean indicating if the media type has the specified top-level media type.
Args:
top_level_media_type: The top-level media type to check for, allowed values:
"image", "text", "application", "audio".
"""
return _has_top_level_media_type(self.media_type, top_level_media_type)
@@ -1172,7 +1191,7 @@ class ErrorContent(BaseContent):
) -> None:
"""Initializes an ErrorContent instance.
Args:
Keyword Args:
message: The error message.
error_code: The error code associated with the error.
details: Additional details about the error.
@@ -1224,14 +1243,22 @@ class FunctionCallContent(BaseContent):
# Parse arguments
args = func_call.parse_arguments()
print(args) # {"location": "Seattle", "unit": "celsius"}
print(args["location"]) # "Seattle"
# Create with string arguments (gradual completion)
func_call_partial = FunctionCallContent(
func_call_partial_1 = FunctionCallContent(
call_id="call_124",
name="search",
arguments='{"query": "weather"}',
arguments='{"query": ',
)
func_call_partial_2 = FunctionCallContent(
call_id="call_124",
name="search",
arguments='"latest news"}',
)
full_call = func_call_partial_1 + func_call_partial_2
args = full_call.parse_arguments()
print(args["query"]) # "latest news"
"""
def __init__(
@@ -1248,7 +1275,7 @@ class FunctionCallContent(BaseContent):
) -> None:
"""Initializes a FunctionCallContent instance.
Args:
Keyword Args:
call_id: The function call identifier.
name: The name of the function requested.
arguments: The arguments requested to be provided to the function,
@@ -1272,6 +1299,11 @@ class FunctionCallContent(BaseContent):
self.type: Literal["function_call"] = "function_call"
def parse_arguments(self) -> dict[str, Any | None] | None:
"""Parse the arguments into a dictionary.
If they cannot be parsed as json or if the resulting json is not a dict,
they are returned as a dictionary with a single key "raw".
"""
if isinstance(self.arguments, str):
# If arguments are a string, try to parse it as JSON
try:
@@ -1352,7 +1384,7 @@ class FunctionResultContent(BaseContent):
) -> None:
"""Initializes a FunctionResultContent instance.
Args:
Keyword Args:
call_id: The identifier of the function call for which this is the result.
result: The result of the function call, or a generic error message if the function call failed.
exception: An exception that occurred if the function call failed.
@@ -1449,7 +1481,16 @@ class HostedFileContent(BaseContent):
raw_representation: Any | None = None,
**kwargs: Any,
) -> None:
"""Initializes a HostedFileContent instance."""
"""Initializes a HostedFileContent instance.
Args:
file_id: The identifier of the hosted file.
Keyword Args:
additional_properties: Optional additional properties associated with the content.
raw_representation: Optional raw representation of the content.
**kwargs: Any additional keyword arguments.
"""
super().__init__(
additional_properties=additional_properties,
raw_representation=raw_representation,
@@ -1486,7 +1527,16 @@ class HostedVectorStoreContent(BaseContent):
raw_representation: Any | None = None,
**kwargs: Any,
) -> None:
"""Initializes a HostedVectorStoreContent instance."""
"""Initializes a HostedVectorStoreContent instance.
Args:
vector_store_id: The identifier of the hosted vector store.
Keyword Args:
additional_properties: Optional additional properties associated with the content.
raw_representation: Optional raw representation of the content.
**kwargs: Any additional keyword arguments.
"""
super().__init__(
additional_properties=additional_properties,
raw_representation=raw_representation,
@@ -1510,7 +1560,7 @@ class BaseUserInputRequest(BaseContent):
) -> None:
"""Initialize BaseUserInputRequest.
Args:
Keyword Args:
id: The unique identifier for the request.
annotations: Optional annotations associated with the content.
additional_properties: Optional additional properties associated with the content.
@@ -1566,6 +1616,8 @@ class FunctionApprovalResponseContent(BaseContent):
Args:
approved: Whether the function call was approved.
Keyword Args:
id: The unique identifier for the request.
function_call: The function call content to be approved. Can be a FunctionCallContent object or dict.
annotations: Optional list of annotations for the request.
@@ -1626,7 +1678,7 @@ class FunctionApprovalRequestContent(BaseContent):
) -> None:
"""Initializes a FunctionApprovalRequestContent instance.
Args:
Keyword Args:
id: The unique identifier for the request.
function_call: The function call content to be approved. Can be a FunctionCallContent object or dict.
annotations: Optional list of annotations for the request.
@@ -1843,7 +1895,7 @@ class FinishReason(SerializationMixin, metaclass=EnumLike):
class ChatMessage(SerializationMixin):
r"""Represents a chat message.
"""Represents a chat message.
Attributes:
role: The role of the author of the message.
@@ -1905,6 +1957,8 @@ class ChatMessage(SerializationMixin):
Args:
role: The role of the author of the message.
Keyword Args:
text: The text content of the message.
author_name: Optional name of the author of the message.
message_id: Optional ID of the chat message.
@@ -1929,6 +1983,8 @@ class ChatMessage(SerializationMixin):
Args:
role: The role of the author of the message.
Keyword Args:
contents: Optional list of BaseContent items to include in the message.
author_name: Optional name of the author of the message.
message_id: Optional ID of the chat message.
@@ -1953,6 +2009,8 @@ class ChatMessage(SerializationMixin):
Args:
role: The role of the author of the message (Role, string, or dict).
Keyword Args:
text: Optional text content of the message.
contents: Optional list of BaseContent items or dicts to include in the message.
author_name: Optional name of the author of the message.
@@ -2174,7 +2232,7 @@ class ChatResponse(SerializationMixin):
) -> None:
"""Initializes a ChatResponse with the provided parameters.
Args:
Keyword Args:
messages: A single ChatMessage or a sequence of ChatMessage objects to include in the response.
response_id: Optional ID of the chat response.
conversation_id: Optional identifier for the state of the conversation.
@@ -2209,7 +2267,7 @@ class ChatResponse(SerializationMixin):
) -> None:
"""Initializes a ChatResponse with the provided parameters.
Args:
Keyword Args:
text: The text content to include in the response. If provided, it will be added as a ChatMessage.
response_id: Optional ID of the chat response.
conversation_id: Optional identifier for the state of the conversation.
@@ -2242,7 +2300,23 @@ class ChatResponse(SerializationMixin):
raw_representation: Any | None = None,
**kwargs: Any,
) -> None:
"""Initializes a ChatResponse with the provided parameters."""
"""Initializes a ChatResponse with the provided parameters.
Keyword Args:
messages: A single ChatMessage or a sequence of ChatMessage objects to include in the response.
text: The text content to include in the response. If provided, it will be added as a ChatMessage.
response_id: Optional ID of the chat response.
conversation_id: Optional identifier for the state of the conversation.
model_id: Optional model ID used in the creation of the chat response.
created_at: Optional timestamp for the chat response.
finish_reason: Optional reason for the chat response.
usage_details: Optional usage details for the chat response.
value: Optional value of the structured output.
response_format: Optional response format for the chat response.
additional_properties: Optional additional properties associated with the chat response.
raw_representation: Optional raw representation of the chat response from an underlying implementation.
**kwargs: Any additional keyword arguments.
"""
# Handle messages conversion
if messages is None:
messages = []
@@ -2293,7 +2367,29 @@ class ChatResponse(SerializationMixin):
*,
output_format_type: type[BaseModel] | None = None,
) -> TChatResponse:
"""Joins multiple updates into a single ChatResponse."""
"""Joins multiple updates into a single ChatResponse.
Example:
.. code-block:: python
from agent_framework import ChatResponse, ChatResponseUpdate
# Create some response updates
updates = [
ChatResponseUpdate(role="assistant", text="Hello"),
ChatResponseUpdate(text=" How can I help you?"),
]
# Combine updates into a single ChatResponse
response = ChatResponse.from_chat_response_updates(updates)
print(response.text) # "Hello How can I help you?"
Args:
updates: A sequence of ChatResponseUpdate objects to combine.
Keyword Args:
output_format_type: Optional Pydantic model type to parse the response text into structured data.
"""
msg = cls(messages=[])
for update in updates:
_process_update(msg, update)
@@ -2309,7 +2405,25 @@ class ChatResponse(SerializationMixin):
*,
output_format_type: type[BaseModel] | None = None,
) -> TChatResponse:
"""Joins multiple updates into a single ChatResponse."""
"""Joins multiple updates into a single ChatResponse.
Example:
.. code-block:: python
from agent_framework import ChatResponse, ChatResponseUpdate, ChatClient
client = ChatClient() # should be a concrete implementation
response = await ChatResponse.from_chat_response_generator(
client.get_streaming_response("Hello, how are you?")
)
print(response.text)
Args:
updates: An async iterable of ChatResponseUpdate objects to combine.
Keyword Args:
output_format_type: Optional Pydantic model type to parse the response text into structured data.
"""
msg = cls(messages=[])
async for update in updates:
_process_update(msg, update)
@@ -2406,7 +2520,7 @@ class ChatResponseUpdate(SerializationMixin):
) -> None:
"""Initializes a ChatResponseUpdate with the provided parameters.
Args:
Keyword Args:
contents: Optional list of BaseContent items or dicts to include in the update.
text: Optional text content to include in the update.
role: Optional role of the author of the response update (Role, string, or dict
@@ -2461,20 +2575,6 @@ class ChatResponseUpdate(SerializationMixin):
def __str__(self) -> str:
return self.text
def with_(self, contents: list[BaseContent] | None = None, message_id: str | None = None) -> "ChatResponseUpdate":
"""Returns a new instance with the specified contents and message_id."""
if contents is None:
contents = []
# Create a dictionary of current instance data
current_data = self.to_dict()
# Update with new values
current_data["contents"] = self.contents + contents
current_data["message_id"] = message_id or self.message_id
return ChatResponseUpdate.from_dict(current_data)
# region AgentRunResponse
@@ -2522,6 +2622,7 @@ class AgentRunResponse(SerializationMixin):
def __init__(
self,
*,
messages: ChatMessage
| list[ChatMessage]
| MutableMapping[str, Any]
@@ -2537,15 +2638,15 @@ class AgentRunResponse(SerializationMixin):
) -> None:
"""Initialize an AgentRunResponse.
Attributes:
messages: The list of chat messages in the response.
response_id: The ID of the chat response.
created_at: A timestamp for the chat response.
usage_details: The usage details for the chat response.
value: The structured output of the agent run response, if applicable.
additional_properties: Any additional properties associated with the chat response.
raw_representation: The raw representation of the chat response from an underlying implementation.
**kwargs: Additional properties to set on the response.
Keyword Args:
messages: The list of chat messages in the response.
response_id: The ID of the chat response.
created_at: A timestamp for the chat response.
usage_details: The usage details for the chat response.
value: The structured output of the agent run response, if applicable.
additional_properties: Any additional properties associated with the chat response.
raw_representation: The raw representation of the chat response from an underlying implementation.
**kwargs: Additional properties to set on the response.
"""
processed_messages: list[ChatMessage] = []
if messages is not None:
@@ -2597,7 +2698,14 @@ class AgentRunResponse(SerializationMixin):
*,
output_format_type: type[BaseModel] | None = None,
) -> TAgentRunResponse:
"""Joins multiple updates into a single AgentRunResponse."""
"""Joins multiple updates into a single AgentRunResponse.
Args:
updates: A sequence of AgentRunResponseUpdate objects to combine.
Keyword Args:
output_format_type: Optional Pydantic model type to parse the response text into structured data.
"""
msg = cls(messages=[])
for update in updates:
_process_update(msg, update)
@@ -2613,7 +2721,14 @@ class AgentRunResponse(SerializationMixin):
*,
output_format_type: type[BaseModel] | None = None,
) -> TAgentRunResponse:
"""Joins multiple updates into a single AgentRunResponse."""
"""Joins multiple updates into a single AgentRunResponse.
Args:
updates: An async iterable of AgentRunResponseUpdate objects to combine.
Keyword Args:
output_format_type: Optional Pydantic model type to parse the response text into structured data
"""
msg = cls(messages=[])
async for update in updates:
_process_update(msg, update)
@@ -2688,7 +2803,7 @@ class AgentRunResponseUpdate(SerializationMixin):
) -> None:
"""Initialize an AgentRunResponseUpdate.
Args:
Keyword Args:
contents: Optional list of BaseContent items or dicts to include in the update.
text: Optional text content of the update.
role: The role of the author of the response update (Role, string, or dict
@@ -2780,12 +2895,15 @@ class ToolMode(SerializationMixin, metaclass=EnumLike):
def __init__(
self,
mode: Literal["auto", "required", "none"] = "none",
*,
required_function_name: str | None = None,
) -> None:
"""Initialize ToolMode.
Args:
mode: The tool mode - "auto", "required", or "none".
Keyword Args:
required_function_name: Optional function name for required mode.
"""
self.mode = mode
@@ -2896,7 +3014,7 @@ class ChatOptions(SerializationMixin):
):
"""Initialize ChatOptions.
Args:
Keyword Args:
additional_properties: Provider-specific additional properties.
model_id: The AI model ID to use.
allow_multiple_tool_calls: Whether to allow multiple tool calls.
@@ -3015,10 +3133,10 @@ class ChatOptions(SerializationMixin):
return ToolMode.from_dict(tool_choice) # type: ignore
return tool_choice
def to_provider_settings(self, by_alias: bool = True, exclude: set[str] | None = None) -> dict[str, Any]:
def to_provider_settings(self, *, by_alias: bool = True, exclude: set[str] | None = None) -> dict[str, Any]:
"""Convert the ChatOptions to a dictionary suitable for provider requests.
Args:
Keyword Args:
by_alias: Use alias names for fields if True.
exclude: Additional keys to exclude from the output.
@@ -75,6 +75,8 @@ class WorkflowAgent(BaseAgent):
Args:
workflow: The workflow to wrap as an agent.
Keyword Args:
id: Unique identifier for the agent. If None, will be generated.
name: Optional name for the agent.
description: Optional description of the agent.
@@ -117,6 +119,8 @@ class WorkflowAgent(BaseAgent):
Args:
messages: The message(s) to send to the workflow.
Keyword Args:
thread: The conversation thread. If None, a new thread will be created.
**kwargs: Additional keyword arguments.
@@ -151,6 +155,8 @@ class WorkflowAgent(BaseAgent):
Args:
messages: The message(s) to send to the workflow.
Keyword Args:
thread: The conversation thread. If None, a new thread will be created.
**kwargs: Additional keyword arguments.
@@ -213,6 +213,8 @@ class Executor(DictConvertible):
Args:
id: A unique identifier for the executor.
Keyword Args:
type: The executor type name. If not provided, uses class name.
type_: Alternative parameter name for executor type.
defer_discovery: If True, defer handler method discovery until later.
@@ -1394,6 +1396,8 @@ class AgentExecutor(Executor):
Args:
agent: The agent to be wrapped by this executor.
Keyword Args:
agent_thread: The thread to use for running the agent. If None, a new thread will be created.
streaming: Enable streaming (emits incremental AgentRunUpdateEvent events) vs single response.
id: A unique identifier for the executor. If None, a new UUID will be generated.
@@ -700,6 +700,8 @@ class StandardMagenticManager(MagenticManagerBase):
Args:
chat_client: The chat client to use for LLM calls.
instructions: Instructions for the orchestrator agent.
Keyword Args:
task_ledger: Optional task ledger for managing task state.
task_ledger_facts_prompt: Optional prompt for the task ledger facts.
task_ledger_plan_prompt: Optional prompt for the task ledger plan.
@@ -138,6 +138,8 @@ class WorkflowGraphValidator:
edge_groups: list of edge groups in the workflow
executors: Map of executor IDs to executor instances
start_executor: The starting executor (can be instance or ID)
Keyword Args:
duplicate_executor_ids: Optional list of known duplicate executor IDs to pre-populate
Raises:
@@ -588,6 +590,8 @@ def validate_workflow_graph(
edge_groups: list of edge groups in the workflow
executors: Map of executor IDs to executor instances
start_executor: The starting executor (can be instance or ID)
Keyword Args:
duplicate_executor_ids: Optional list of known duplicate executor IDs to pre-populate
Raises:
@@ -210,6 +210,8 @@ class WorkflowExecutor(Executor):
Args:
workflow: The workflow to execute as a sub-workflow.
id: Unique identifier for this executor.
Keyword Args:
**kwargs: Additional keyword arguments passed to the parent constructor.
"""
super().__init__(id, **kwargs)
@@ -67,7 +67,7 @@ class AzureOpenAIChatClient(AzureOpenAIConfigMixin, OpenAIBaseChatClient):
) -> None:
"""Initialize an Azure OpenAI Chat completion client.
Args:
Keyword Args:
api_key: The API key. If provided, will override the value in the env vars or .env file.
Can also be set via environment variable AZURE_OPENAI_API_KEY.
deployment_name: The deployment name. If provided, will override the value
@@ -27,6 +27,8 @@ def get_entra_auth_token(
Args:
credential: The Azure credential to use for authentication.
token_endpoint: The token endpoint to use to retrieve the authentication token.
Keyword Args:
**kwargs: Additional keyword arguments to pass to the token retrieval method.
Returns:
@@ -57,6 +59,8 @@ async def get_entra_auth_token_async(
Args:
credential: The async Azure credential to use for authentication.
token_endpoint: The token endpoint to use to retrieve the authentication token.
Keyword Args:
**kwargs: Additional keyword arguments to pass to the token retrieval method.
Returns:
@@ -122,6 +122,8 @@ class AzureOpenAISettings(AFBaseSettings):
Args:
credential: The Azure AD credential to use.
token_endpoint: The token endpoint to use. Defaults to `https://cognitiveservices.azure.com/.default`.
Keyword Args:
**kwargs: Additional keyword arguments to pass to the token retrieval method.
Returns:
@@ -809,6 +809,8 @@ def _trace_get_response(
Args:
func: The function to trace.
Keyword Args:
provider_name: The model provider name.
"""
@@ -895,6 +897,8 @@ def _trace_get_streaming_response(
Args:
func: The function to trace.
Keyword Args:
provider_name: The model provider name.
"""
@@ -1136,7 +1140,6 @@ def _trace_agent_run_stream(
"""Decorator to trace streaming agent run activities.
Args:
agent: The agent that is wrapped.
run_streaming_func: The function to trace.
provider_name: The system name used for Open Telemetry.
"""
@@ -33,8 +33,7 @@ class ContentFilterResult:
"""Creates a ContentFilterResult from the inner error results.
Args:
key (str): The key to get the inner error result from.
inner_error_results (Dict[str, Any]): The inner error results.
inner_error_results: The inner error results.
Returns:
ContentFilterResult: The ContentFilterResult.
@@ -75,8 +74,8 @@ class OpenAIContentFilterException(ServiceContentFilterException):
"""Initializes a new instance of the ContentFilterAIException class.
Args:
message (str): The error message.
inner_exception (Exception): The inner exception.
message: The error message.
inner_exception: The inner exception.
"""
super().__init__(message)
@@ -105,7 +105,7 @@ class OpenAIBase(SerializationMixin):
def __init__(self, *, client: AsyncOpenAI, model_id: str, **kwargs: Any) -> None:
"""Initialize OpenAIBase.
Args:
Keyword Args:
client: The AsyncOpenAI client instance.
model_id: The AI model ID to use (non-empty, whitespace stripped).
**kwargs: Additional keyword arguments.
@@ -14,6 +14,7 @@ from agent_framework import (
Role,
chat_middleware,
function_middleware,
use_chat_middleware,
use_function_invocation,
)
@@ -326,6 +327,7 @@ class TestChatMiddleware:
async def test_function_middleware(
context: FunctionInvocationContext, next: Callable[[FunctionInvocationContext], Awaitable[None]]
) -> None:
nonlocal execution_order
execution_order.append(f"function_middleware_before_{context.function.name}")
await next(context)
execution_order.append(f"function_middleware_after_{context.function.name}")
@@ -336,7 +338,7 @@ class TestChatMiddleware:
return f"Weather in {location}: sunny"
# Create function-invocation enabled chat client
chat_client = use_function_invocation(MockBaseChatClient)()
chat_client = use_chat_middleware(use_function_invocation(MockBaseChatClient))()
# Set function middleware directly on the chat client
chat_client.middleware = [test_function_middleware]
@@ -580,14 +580,6 @@ def test_chat_response_update():
assert response_update.text == "I'm doing well, thank you!"
def test_chat_response_update_with_method():
u = ChatResponseUpdate(text="Hello", message_id="1")
v = u.with_(contents=[TextContent(" world")])
assert v is not u
assert v.text == "Hello world"
assert v.message_id == "1"
def test_chat_response_updates_to_chat_response_one():
"""Test converting ChatResponseUpdate to ChatResponse."""
# Create a ChatMessage
@@ -58,9 +58,6 @@ class SlidingWindowChatMessageStore(ChatMessageStore):
def get_token_count(self) -> int:
"""Estimate token count for a list of messages using tiktoken.
Args:
messages: List of ChatMessage objects
system_message: Optional system message to include in count
Returns:
Estimated token count
"""
@@ -135,7 +135,9 @@ class Mem0Provider(ContextProvider):
Args:
messages: List of new messages in the thread.
kwargs: not used at present.
Keyword Args:
**kwargs: not used at present.
Returns:
Context: Context object containing instructions with memories.
@@ -227,7 +227,7 @@ class RedisChatMessageStore:
Captures the Redis connection configuration and thread information needed to
reconstruct the store and reconnect to the same conversation data.
Args:
Keyword Args:
**kwargs: Additional arguments passed to Pydantic model_dump() for serialization.
Common options: exclude_none=True, by_alias=True
@@ -254,6 +254,8 @@ class RedisChatMessageStore:
Args:
serialized_store_state: Previously serialized state data from serialize_state().
Should be a dictionary with thread_id, redis_url, etc.
Keyword Args:
**kwargs: Additional arguments passed to Pydantic model validation.
Returns:
@@ -286,6 +288,8 @@ class RedisChatMessageStore:
Args:
serialized_store_state: Previously serialized state data from serialize_state().
Should be a dictionary with thread_id, redis_url, etc.
Keyword Args:
**kwargs: Additional arguments passed to Pydantic model validation.
"""
if not serialized_store_state:
@@ -154,7 +154,7 @@ class RedisProvider(ContextProvider):
Defines text and tag fields for messages plus an optional vector field enabling KNN/hybrid search.
Args:
Keyword Args:
index_name: Index name.
prefix: Key prefix.
vector_field_name: Vector field name or None.
@@ -300,7 +300,7 @@ class RedisProvider(ContextProvider):
Fills default partition fields, optionally embeds content when configured, and loads documents in a batch.
Args:
Keyword Args:
data: Single document or list of documents to insert.
metadata: Optional metadata dictionary (unused placeholder).
@@ -363,6 +363,8 @@ class RedisProvider(ContextProvider):
Args:
text: Query text.
Keyword Args:
text_scorer: Scorer to use for text ranking.
filter_expression: Additional filter expression to AND with partition filters.
return_fields: Fields to return in results.
@@ -526,7 +528,9 @@ class RedisProvider(ContextProvider):
Args:
messages: List of new messages in the thread.
kwargs: not used at present at present.
Keyword Args:
**kwargs: not used at present at present.
Returns:
Context: Context object containing instructions with memories.