Google ADK:Hello World
官方源码
py
from google.adk.agents import Agent
from google.adk.tools import google_search
root_agent = Agent(
name="search_assistant",
model="gemini-2.0-flash-exp", # Or your preferred Gemini model
instruction="You are a helpful assistant. Answer user questions using Google Search when needed.",
description="An assistant that can search the web.",
tools=[google_search],
)
改造成qwen的源码
py
from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
from google.adk.tools import google_search
# 创建使用qwen模型
root_agent = LlmAgent(
model=LiteLlm(
model="openai/qwen-max-latest",
api_base="https://dashscope.aliyuncs.com/compatible-mode/v1",
api_key="sk-xxx",
),
name="天蓬元帅",
description=("a helpful assistant."),
instruction=("You are a helpful assistant"),
# tools=[google_search],
)
# Google search tool is not supported for model openai/qwen-max-latest
# NotImplementedError: Live connection is not supported for openai/qwen-max-latest
运行界面:
学习笔记
google_search不支持qwen模型,语音和视频模式也不支持qwen模型。其他自带工具是否能适配,待测试。
与openai sdk类似,自家模型配置方便,但是别家的模型配置就稍微麻烦。也是同样需要先配置model类型,然后再构建agent。
刚出来问题不少,比如windows下的ollama使用、网页解析结果比较丑等。