Shopping Cart
Total:

$0.00

Items:

0

Your cart is empty
Keep Shopping

Agent-Based Task Execution – onprem


This notebook demonstrates how to use the Agent pipeline from OnPrem.LLM to create autonomous agents that can execute complex tasks using a variety of tools.

The pipeline works with any LiteLLM-supported model that supports tool-calling:

  • Cloud: openai/gpt-5.2-codex, anthropic/claude-sonnet-4-5, gemini/gemini-1.5-pro
  • Local: Ollama (ollama/llama3.1), vLLM (hosted_vllm/), llama.cpp (use OpenAI interface)

For llama.cpp: Use openai/<model_name> (e.g., gpt-oss-120b) as model parameter and then set env variable OPENAI_API_BASE=http://localhost:<port>/v1

The AgentExecutor

The AgentExecutor allows you to launch AI agents to solve various tasks using both cloud and local models. We will use anthropic/claude-sonnet-4-5 (cloud) and glm-4.7-flash (local) for these examples.

By default, the AgentExecutor has access to 9 built-in tools. You remove access to built-in-tools as necessary. You can optionally give the agent access to custom tools, as we’ll illustrate below.

The AgentExecutor is implemented using our coding agent, PatchPal, which you’ll need to install: pip install patchpal.

AgentExecutor supports local models. By default, it will assume the local model supports native function-calling (e.g., gpt-oss-120b). If you use a local model that does not have good native support for function-calling (a.k.a. tool-calling), you can change the agent_type to react. In this example, we will use llama3.1:8b.

Note: The default context window length in Ollama is typically too small for agentic workflows. Depending on the model and task, we recommend inreasing to at least 8192. Reasoning models like gpt-oss:120b may require 32K or 64K.

Custom Tools

You can give the agent custom tools by simply defining them as Python functions or callables.

In this example, we’ll build a financial analysis agent with custom tools.

Let’s first definte the tools, which are based on yfinance.

pip install yfinance

Step 1: Define the custom tools as Python functions

Source link

0
Show Comments (0) Hide Comments (0)
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments