ADK ์์ด์ ํธ๋ฅผ ์ํ Ollama ๋ชจ๋ธ ํธ์คํธ¶
Ollama๋ ์คํ ์์ค ๋ชจ๋ธ์ ๋ก์ปฌ์์ ํธ์คํ ํ๊ณ ์คํํ ์ ์๊ฒ ํด์ฃผ๋ ๋๊ตฌ์ ๋๋ค. ADK๋ LiteLLM ๋ชจ๋ธ ์ปค๋ฅํฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํตํด Ollama์์ ํธ์คํ ๋๋ ๋ชจ๋ธ๊ณผ ํตํฉ๋ฉ๋๋ค.
์์ํ๊ธฐ¶
Ollama์์ ํธ์คํ ๋๋ ๋ชจ๋ธ๋ก ์์ด์ ํธ๋ฅผ ๋ง๋ค ๋๋ LiteLLM ๋ํผ๋ฅผ ์ฌ์ฉํฉ๋๋ค. ๋ค์ ์์๋ Gemma ์คํ ๋ชจ๋ธ์ ์์ด์ ํธ์์ ์ฌ์ฉํ๋ ๊ธฐ๋ณธ ๊ตฌํ์ ๋ณด์ฌ์ค๋๋ค.
root_agent = Agent(
model=LiteLlm(model="ollama_chat/gemma3:latest"),
name="dice_agent",
description=(
"hello world agent that can roll a dice of 8 sides and check prime"
" numbers."
),
instruction="""
You roll dice and answer questions about the outcome of the dice rolls.
""",
tools=[
roll_die,
check_prime,
],
)
๊ฒฝ๊ณ : ollama_chat ์ธํฐํ์ด์ค ์ฌ์ฉ
ollama ๋์ ๋ฐ๋์ ollama_chat ํ๋ก๋ฐ์ด๋๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค.
ollama๋ฅผ ์ฌ์ฉํ๋ฉด ๋๊ตฌ ํธ์ถ ๋ฌดํ ๋ฃจํ ๋๋ ์ด์ ์ปจํ
์คํธ ๋ฌด์ ๊ฐ์ ์๊ธฐ์น ์์ ๋์์ด ๋ฐ์ํ ์ ์์ต๋๋ค.
OLLAMA_API_BASE ํ๊ฒฝ ๋ณ์ ์ฌ์ฉ
์์ฑ ์์ฒญ์์ api_base ํ๋ผ๋ฏธํฐ๋ฅผ ์ง์ ํ ์ ์์ง๋ง,
v1.65.5์์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ๋ค๋ฅธ API ํธ์ถ์ ํ๊ฒฝ ๋ณ์๋ฅผ ์ฌ์ฉํฉ๋๋ค.
๋ชจ๋ ์์ฒญ์ด ์ฌ๋ฐ๋ฅธ ๊ฒฝ๋ก๋ก ๋ผ์ฐํ
๋๋๋ก Ollama ์๋ฒ URL์ ๋ํ
OLLAMA_API_BASE๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค.
๋ชจ๋ธ ์ ํ¶
์์ด์ ํธ์์ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ Ollama ์น์ฌ์ดํธ์์ ๋๊ตฌ ์ง์ ๋ชจ๋ธ์ ์ ํํด์ผ ํฉ๋๋ค. ์์ ์ ์ธ ๊ฒฐ๊ณผ๋ฅผ ์ํด์๋ ๋๊ตฌ๊ฐ ์ง์๋๋ ๋ชจ๋ธ์ ์ฌ์ฉํ์ธ์. ๋ค์ ๋ช ๋ น์ผ๋ก ๋ชจ๋ธ์ ๋๊ตฌ ์ง์ ์ฌ๋ถ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
ollama show mistral-small3.1
Model
architecture mistral3
parameters 24.0B
context length 131072
embedding length 5120
quantization Q4_K_M
Capabilities
completion
vision
tools
Capabilities ํญ๋ชฉ์ tools๊ฐ ํ์๋์ด์ผ ํฉ๋๋ค.
๋ชจ๋ธ์ด ์ฌ์ฉํ๋ ํ
ํ๋ฆฟ์ ํ์ธํด ํ์์ ๋ง๊ฒ ์กฐ์ ํ ์๋ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด ์ ๋ชจ๋ธ์ ๊ธฐ๋ณธ ํ ํ๋ฆฟ์ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ชจ๋ธ์ด ํญ์ ํจ์๋ฅผ ํธ์ถํ๋๋ก ์ง์ํฉ๋๋ค. ์ด๋ก ์ธํด ๋ฌดํ ํจ์ ํธ์ถ ๋ฃจํ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค.
Given the following functions, please respond with a JSON for a function call
with its proper arguments that best answers the given prompt.
Respond in the format {"name": function name, "parameters": dictionary of
argument name and its value}. Do not use variables.
๋ค์๊ณผ ๊ฐ์ด ๋ ์ค๋ช ์ ์ธ ํ๋กฌํํธ๋ก ๊ต์ฒดํ๋ฉด ๋ฌดํ ํธ์ถ์ ์ค์ผ ์ ์์ต๋๋ค.
Review the user's prompt and the available functions listed below.
First, determine if calling one of these functions is the most appropriate way
to respond. A function call is likely needed if the prompt asks for a specific
action, requires external data lookup, or involves calculations handled by the
functions. If the prompt is a general question or can be answered directly, a
function call is likely NOT needed.
If you determine a function call IS required: Respond ONLY with a JSON object in
the format {"name": "function_name", "parameters": {"argument_name": "value"}}.
Ensure parameter values are concrete, not variables.
If you determine a function call IS NOT required: Respond directly to the user's
prompt in plain text, providing the answer or information requested. Do not
output any JSON.
๊ทธ๋ฐ ๋ค์ ์๋ ๋ช ๋ น์ผ๋ก ์ ๋ชจ๋ธ์ ์์ฑํ ์ ์์ต๋๋ค.
OpenAI ํ๋ก๋ฐ์ด๋ ์ฌ์ฉ¶
๋์ openai๋ฅผ ํ๋ก๋ฐ์ด๋ ์ด๋ฆ์ผ๋ก ์ฌ์ฉํ ์๋ ์์ต๋๋ค. ์ด ๋ฐฉ์์
OLLAMA_API_BASE ๋์ ๋ค์ ํ๊ฒฝ๋ณ์๋ฅผ ์ค์ ํฉ๋๋ค.
- OPENAI_API_BASE=http://localhost:11434/v1
- OPENAI_API_KEY=anything
์ฐธ๊ณ : API_BASE ๊ฐ ๋ค์ "/v1"์ด ๋ถ์ต๋๋ค.
root_agent = Agent(
model=LiteLlm(model="openai/mistral-small3.1"),
name="dice_agent",
description=(
"hello world agent that can roll a dice of 8 sides and check prime"
" numbers."
),
instruction="""
You roll dice and answer questions about the outcome of the dice rolls.
""",
tools=[
roll_die,
check_prime,
],
)
๋๋ฒ๊น ¶
๋ค์ ์ฝ๋๋ฅผ ์ํฌํธ ์งํ์ ์ถ๊ฐํ๋ฉด Ollama ์๋ฒ๋ก ์ ์ก๋๋ ์์ฒญ์ ํ์ธํ ์ ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ ํ์์ ๋ผ์ธ์ ํ์ธํ์ธ์.