chore: Updates model_config docstring to explicitly mentioning pydantic.

This is to disambiguate between pydantic model and LLM.

PiperOrigin-RevId: 754981617
This commit is contained in:
Wei Sun (Jack) 2025-05-05 10:12:09 -07:00 committed by Copybara-Service
parent a930633fad
commit dbea793cf5
15 changed files with 18 additions and 13 deletions

View File

@ -30,6 +30,7 @@ class ActiveStreamingTool(BaseModel):
arbitrary_types_allowed=True, arbitrary_types_allowed=True,
extra='forbid', extra='forbid',
) )
"""The pydantic model config."""
task: Optional[asyncio.Task] = None task: Optional[asyncio.Task] = None
"""The active task of this streaming tool.""" """The active task of this streaming tool."""

View File

@ -50,6 +50,7 @@ class BaseAgent(BaseModel):
arbitrary_types_allowed=True, arbitrary_types_allowed=True,
extra='forbid', extra='forbid',
) )
"""The pydantic model config."""
name: str name: str
"""The agent's name. """The agent's name.

View File

@ -110,6 +110,7 @@ class InvocationContext(BaseModel):
arbitrary_types_allowed=True, arbitrary_types_allowed=True,
extra="forbid", extra="forbid",
) )
"""The pydantic model config."""
artifact_service: Optional[BaseArtifactService] = None artifact_service: Optional[BaseArtifactService] = None
session_service: BaseSessionService session_service: BaseSessionService

View File

@ -53,6 +53,7 @@ class LangGraphAgent(BaseAgent):
model_config = ConfigDict( model_config = ConfigDict(
arbitrary_types_allowed=True, arbitrary_types_allowed=True,
) )
"""The pydantic model config."""
graph: CompiledGraph graph: CompiledGraph

View File

@ -24,6 +24,7 @@ class LiveRequest(BaseModel):
"""Request send to live agents.""" """Request send to live agents."""
model_config = ConfigDict(ser_json_bytes='base64', val_json_bytes='base64') model_config = ConfigDict(ser_json_bytes='base64', val_json_bytes='base64')
"""The pydantic model config."""
content: Optional[types.Content] = None content: Optional[types.Content] = None
"""If set, send the content to the model in turn-by-turn mode.""" """If set, send the content to the model in turn-by-turn mode."""

View File

@ -37,6 +37,7 @@ class RunConfig(BaseModel):
model_config = ConfigDict( model_config = ConfigDict(
extra='forbid', extra='forbid',
) )
"""The pydantic model config."""
speech_config: Optional[types.SpeechConfig] = None speech_config: Optional[types.SpeechConfig] = None
"""Speech configuration for the live agent.""" """Speech configuration for the live agent."""

View File

@ -26,6 +26,7 @@ class TranscriptionEntry(BaseModel):
arbitrary_types_allowed=True, arbitrary_types_allowed=True,
extra='forbid', extra='forbid',
) )
"""The pydantic model config."""
role: str role: str
"""The role that created this data, typically "user" or "model""" """The role that created this data, typically "user" or "model"""

View File

@ -13,17 +13,16 @@
# limitations under the License. # limitations under the License.
from enum import Enum from enum import Enum
from typing import Any from typing import Any, Dict, List, Optional
from typing import Dict
from typing import List
from typing import Optional
from pydantic import BaseModel from pydantic import BaseModel
from pydantic import ConfigDict
from pydantic import Field from pydantic import Field
class BaseModelWithConfig(BaseModel): class BaseModelWithConfig(BaseModel):
model_config = {"extra": "allow"} model_config = ConfigDict(extra="allow")
"""The pydantic model config."""
class HttpCredentials(BaseModelWithConfig): class HttpCredentials(BaseModelWithConfig):

View File

@ -48,6 +48,7 @@ class Event(LlmResponse):
model_config = ConfigDict( model_config = ConfigDict(
extra='forbid', ser_json_bytes='base64', val_json_bytes='base64' extra='forbid', ser_json_bytes='base64', val_json_bytes='base64'
) )
"""The pydantic model config."""
# TODO: revert to be required after spark migration # TODO: revert to be required after spark migration
invocation_id: str = '' invocation_id: str = ''

View File

@ -27,6 +27,7 @@ class EventActions(BaseModel):
"""Represents the actions attached to an event.""" """Represents the actions attached to an event."""
model_config = ConfigDict(extra='forbid') model_config = ConfigDict(extra='forbid')
"""The pydantic model config."""
skip_summarization: Optional[bool] = None skip_summarization: Optional[bool] = None
"""If true, it won't call model to summarize function response. """If true, it won't call model to summarize function response.

View File

@ -14,11 +14,9 @@
from __future__ import annotations from __future__ import annotations
from abc import abstractmethod from abc import abstractmethod
from typing import AsyncGenerator from typing import AsyncGenerator, TYPE_CHECKING
from typing import TYPE_CHECKING
from google.genai import types from google.genai import types
from pydantic import BaseModel from pydantic import BaseModel
from pydantic import ConfigDict from pydantic import ConfigDict
@ -34,14 +32,13 @@ class BaseLlm(BaseModel):
Attributes: Attributes:
model: The name of the LLM, e.g. gemini-1.5-flash or gemini-1.5-flash-001. model: The name of the LLM, e.g. gemini-1.5-flash or gemini-1.5-flash-001.
model_config: The model config
""" """
model_config = ConfigDict( model_config = ConfigDict(
# This allows us to use arbitrary types in the model. E.g. PIL.Image. # This allows us to use arbitrary types in the model. E.g. PIL.Image.
arbitrary_types_allowed=True, arbitrary_types_allowed=True,
) )
"""The model config.""" """The pydantic model config."""
model: str model: str
"""The name of the LLM, e.g. gemini-1.5-flash or gemini-1.5-flash-001.""" """The name of the LLM, e.g. gemini-1.5-flash or gemini-1.5-flash-001."""

View File

@ -573,7 +573,6 @@ class LiteLlm(BaseLlm):
Attributes: Attributes:
model: The name of the LiteLlm model. model: The name of the LiteLlm model.
llm_client: The LLM client to use for the model. llm_client: The LLM client to use for the model.
model_config: The model config.
""" """
llm_client: LiteLLMClient = Field(default_factory=LiteLLMClient) llm_client: LiteLLMClient = Field(default_factory=LiteLLMClient)

View File

@ -37,7 +37,7 @@ class LlmRequest(BaseModel):
""" """
model_config = ConfigDict(arbitrary_types_allowed=True) model_config = ConfigDict(arbitrary_types_allowed=True)
"""The model config.""" """The pydantic model config."""
model: Optional[str] = None model: Optional[str] = None
"""The model name.""" """The model name."""

View File

@ -41,7 +41,7 @@ class LlmResponse(BaseModel):
""" """
model_config = ConfigDict(extra='forbid') model_config = ConfigDict(extra='forbid')
"""The model config.""" """The pydantic model config."""
content: Optional[types.Content] = None content: Optional[types.Content] = None
"""The content of the response.""" """The content of the response."""

View File

@ -38,6 +38,7 @@ class Session(BaseModel):
extra='forbid', extra='forbid',
arbitrary_types_allowed=True, arbitrary_types_allowed=True,
) )
"""The pydantic model config."""
id: str id: str
"""The unique identifier of the session.""" """The unique identifier of the session."""