MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / LLMResponse

Class LLMResponse

web/pgadmin/llm/models.py:158–187  ·  view source on GitHub ↗

Represents a response from an LLM.

Source from the content-addressed store, hash-verified

156
157@dataclass
158class LLMResponse:
159 """Represents a response from an LLM."""
160 content: str
161 tool_calls: list[ToolCall] = field(default_factory=list)
162 stop_reason: StopReason = StopReason.END_TURN
163 model: str = ''
164 usage: Usage = field(default_factory=Usage)
165 raw_response: Optional[Any] = None
166
167 @property
168 def has_tool_calls(self) -> bool:
169 """Check if the response contains tool calls."""
170 return len(self.tool_calls) > 0
171
172 def to_message(self) -> Message:
173 """Convert response to an assistant message."""
174 return Message.assistant(
175 content=self.content,
176 tool_calls=self.tool_calls
177 )
178
179 def to_dict(self) -> dict:
180 """Convert to dictionary representation."""
181 return {
182 'content': self.content,
183 'tool_calls': [tc.to_dict() for tc in self.tool_calls],
184 'stop_reason': self.stop_reason.value,
185 'model': self.model,
186 'usage': self.usage.to_dict()
187 }
188
189
190@dataclass

Callers 10

_parse_responseMethod · 0.90
_read_openai_streamMethod · 0.90
_parse_responseMethod · 0.90
_read_ollama_streamMethod · 0.90
_parse_responseMethod · 0.90
_read_openai_streamMethod · 0.90
_parse_responseMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected