Basic Agent

Code

1from kern.agent import Agent
2from kern.models.vllm import VLLM
3
4agent = Agent(
5 model=VLLM(id="Qwen/Qwen2.5-7B-Instruct", top_k=20, enable_thinking=False),
6 markdown=True,
7)
8
9agent.print_response("Share a 2 sentence horror story")

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Setup vLLM Server

Start a vLLM server locally:

1uv pip install vllm
2python -m vllm.entrypoints.openai.api_server \
3 --model Qwen/Qwen2.5-7B-Instruct \
4 --port 8000

Install dependencies

1uv pip install -U openai kern-ai

Run Agent

1python cookbook/11_models/vllm/basic.py