MCPcopy Create free account
hub / github.com/google/adk-python / LlmRequest

Class LlmRequest

src/google/adk/models/llm_request.py:50–300  ·  view source on GitHub ↗

LLM request class that allows passing in tools, output schema and system instructions to the model. Attributes: model: The model name. contents: The contents to send to the model. config: Additional config for the generate content request. tools_dict: The tools dictionary.

Source from the content-addressed store, hash-verified

48
49
50class LlmRequest(BaseModel):
51 """LLM request class that allows passing in tools, output schema and system
52
53 instructions to the model.
54
55 Attributes:
56 model: The model name.
57 contents: The contents to send to the model.
58 config: Additional config for the generate content request.
59 tools_dict: The tools dictionary.
60 cache_config: Context cache configuration for this request.
61 cache_metadata: Cache metadata from previous requests, used for cache management.
62 """
63
64 model_config = ConfigDict(arbitrary_types_allowed=True)
65 """The pydantic model config."""
66
67 model: Optional[str] = None
68 """The model name."""
69
70 contents: list[types.Content] = Field(default_factory=list)
71 """The contents to send to the model."""
72
73 config: types.GenerateContentConfig = Field(
74 default_factory=types.GenerateContentConfig
75 )
76 live_connect_config: types.LiveConnectConfig = Field(
77 default_factory=types.LiveConnectConfig
78 )
79 """Additional config for the generate content request.
80
81 tools in generate_content_config should not be set.
82 """
83 tools_dict: dict[str, BaseTool] = Field(default_factory=dict, exclude=True)
84 """The tools dictionary."""
85
86 cache_config: Optional[ContextCacheConfig] = None
87 """Context cache configuration for this request."""
88
89 cache_metadata: Optional[CacheMetadata] = None
90 """Cache metadata from previous requests, used for cache management."""
91
92 cacheable_contents_token_count: Optional[int] = None
93 """Token count from previous request's prompt, used for cache size validation."""
94
95 previous_interaction_id: Optional[str] = None
96 """The ID of the previous interaction for stateful conversations.
97
98 When using the interactions API, this ID is used to chain interactions
99 together, allowing the API to maintain conversation state without sending
100 the full history.
101 """
102
103 def append_instructions(
104 self, instructions: Union[list[str], types.Content]
105 ) -> list[types.Content]:
106 """Appends instructions to the system instruction.
107

Callers 15

analyzeMethod · 0.90
mockMethod · 0.90
llm_requestFunction · 0.90
llm_request_with_toolsFunction · 0.90
gemma_requestFunction · 0.90
llm_requestFunction · 0.90
llm_requestFunction · 0.90

Calls

no outgoing calls