ADK Plugin: LLM
Overview
Section titled “Overview”FlotorchADKLLM
is an ADK-compatible LLM wrapper that uses FloTorch’s Gateway for model inference. It handles tool calls, response parsing, and provides async generation.
from flotorch.adk.llm import FlotorchADKLLM
API_KEY = "<your_api_key>"BASE_URL = "https://gateway.flotorch.cloud"MODEL_ID = "<your_flotorch_model_id>"
FlotorchADKLLM
Section titled “FlotorchADKLLM”FlotorchADKLLM( model_id: str, api_key: str, base_url: str,)
Creates an ADK-compatible LLM that wraps FloTorch’s Gateway LLM.
generate_content_async(…) -> AsyncGenerator[LlmResponse, None]
Section titled “generate_content_async(…) -> AsyncGenerator[LlmResponse, None]”async def generate_content_async( self, llm_request: LlmRequest,) -> AsyncGenerator[LlmResponse, None]
Generates content asynchronously with support for:
- Tool calls and function responses
- JSON schema responses via
response_schema
in request config
Features
Section titled “Features”Tool Call Support
Section titled “Tool Call Support”Automatically handles OpenAI-format tool calls and converts them to ADK types.Part
objects.
Response Schema
Section titled “Response Schema”Supports structured responses by converting Pydantic models to JSON schema format.
Usage Example
Section titled “Usage Example”from google.adk.models.llm_request import LlmRequestfrom google.genai import types
# Create LLMllm = FlotorchADKLLM( model_id=MODEL_ID, api_key=API_KEY, base_url=BASE_URL)
# Create requestrequest = LlmRequest( content=types.Content( role="user", parts=[types.Part(text="What's the weather like?")] ))
# Generate responseasync for response in llm.generate_content_async(request): print(response.content.parts[0].text)
- Uses FloTorch Gateway’s
/api/openai/v1/chat/completions
endpoint