Agent with Tools
Code
1"""Build a Web Search Agent using xAI."""23from kern.agent import Agent4from kern.models.vllm import VLLM5from kern.tools.hackernews import HackerNewsTools67agent = Agent(8 model=VLLM(9 id="NousResearch/Nous-Hermes-2-Mistral-7B-DPO", top_k=20, enable_thinking=False10 ),11 tools=[HackerNewsTools()],12 markdown=True,13)14agent.print_response("Whats happening in France?")Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateInstall Libraries
1uv pip install -U kern-ai openai vllmStart vLLM server
1vllm serve NousResearch/Nous-Hermes-2-Mistral-7B-DPO \2 --enable-auto-tool-choice \3 --tool-call-parser hermes \4 --dtype float16 \5 --max-model-len 8192 \6 --gpu-memory-utilization 0.9Run Agent
1python cookbook/11_models/vllm/tool_use.py