用 Ollama 和 Python 构建首个多工具 AI 智能体

在本系列的第一部分(链接见文末),我们构建了一个 AI 智能体,它回答了一个关于只有一个订单的商店数据库的简单查询。用户提供了订单 ID,该智能体使用了一个大语言模型(LLM),该模型调用了一个工具来计算订单金额并返回答案。
模型只需请求 get_order_total(1001)。
一个问题,一次工具调用,一个答案。
这并非客户或客服人员通常询问订单历史的方式。他们更可能知道客户的姓名,而不是记住订单号。为了支持这一点,我们将扩展数据库,以包含两位客户和四个订单。
Sarah Jones 将拥有以下三个订单:
订单 | 状态 | 总额 ||------|------------|------------|| 1001 | 已送达 | GBP 96.95 || 1002 | 已送达 | GBP 284.49 || 1003 | 处理中 | GBP 42.00 |
我们将把订单 1004 分配给我们的第二位客户 David Smith,这样智能体就有东西可查,并能与 Sarah 的记录区分开。
| 订单| 状态 | 总额 ||------|------------|------------|| 1004 | 已送达 | GBP 58.25 |
智能体不会获得任何客户 ID 或订单 ID。相反,它会被问到这样的问题:
找到 Sarah Jones,并告诉我她的哪一笔订单金额最大。
正确答案是订单 1002,金额 284.49 英镑。要得到这个答案,需要三种数据库查询。程序必须找到 Sarah 的客户 ID、列出她的订单、计算每笔订单的总额并比较结果。我们不会把这个顺序硬编码进 Python 的控制流。模型会在看到每个结果后自行选择下一个工具。
这正是调用工具的聊天机器人变成基础智能体的地方。也正是在这里,一个不加限制的 while True 循环可能把一次错误决策变成数百次模型调用,所以你需要谨慎行事。
承接第一部分继续这个项目
我们将继续使用 Python、SQLite、Ollama 和 qwen3.5:4b LLM。如果你是从这里开始,请安装 Windows 版 Ollama(https://ollama.com/download/windows),安装 uv(https://docs.astral.sh/uv/getting-started/installation/),然后运行以下命令:
PS D:\projects> ollama pull qwen3.5:4bPS D:\projects> uv init local-shop-agentPS D:\projects> cd local-shop-agentPS D:\projects\local-shop-agent> uv python pin 3.14PS D:\projects\local-shop-agent> uv add ollama
现在数据库需要包含客户和若干订单。请用这个版本替换我们在第一部分中的原始 build_shop_database.py:
import sqlite3 from contextlib import closing from pathlib import Path DATABASE_PATH = Path(__file__).with_name("shop_agent.db") def build_database() -> None: DATABASE_PATH.unlink(missing_ok=True) with closing(sqlite3.connect(DATABASE_PATH)) as connection: connection.executescript( """ CREATE TABLE customers ( customer_id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT NOT NULL UNIQUE ); CREATE TABLE orders ( order_id INTEGER PRIMARY KEY, customer_id INTEGER NOT NULL REFERENCES customers(customer_id), order_date TEXT NOT NULL, status TEXT NOT NULL ); CREATE TABLE order_items ( order_id INTEGER NOT NULL REFERENCES orders(order_id), product_name TEXT NOT NULL, quantity INTEGER NOT NULL, unit_price REAL NOT NULL ); """ ) connection.executemany( "INSERT INTO customers VALUES (?, ?, ?)", [ (101, "Sarah Jones", "[email protected]"), (102, "David Smith", "[email protected]"), ], ) connection.executemany( "INSERT INTO orders VALUES (?, ?, ?, ?)", [ (1001, 101, "2026-08-03", "delivered"), (1002, 101, "2026-08-19", "delivered"), (1003, 101, "2026-09-02", "processing"), (1004, 102, "2026-09-04", "delivered"), ], ) connection.executemany( "INSERT INTO order_items VALUES (?, ?, ?, ?)", [ (1001, "Mechanical keyboard", 1, 79.95), (1001, "USB-C cable", 2, 8.50), (1002, "27-inch monitor", 1, 219.99), (1002, "Monitor arm", 1, 64.50), (1003, "Laptop stand", 1, 42.00), (1004, "Webcam", 2, 58.25), ], ) connection.commit() print(f"Created {DATABASE_PATH}") if __name__ == "__main__": build_database()
运行它即可替换之前的数据库:
PS D:\projects\local-shop-agent> uv run python build_shop_database.py Created D:\projects\local-shop-agent\shop_agent.db
创建文件 shop_tools.py,内容如下。模型并不需要一个通用的 run_sql() 函数,它需要的是一些范围狭窄、行为可被我们理解和测试的操作。
import json import sqlite3 from contextlib import contextmanager from pathlib import Path from typing import Iterator DATABASE_PATH = Path(__file__).with_name("shop_agent.db") @contextmanager def open_read_only_database() -> Iterator[sqlite3.Connection]: uri = f"file:{DATABASE_PATH.as_posix()}?mode=ro" connection = sqlite3.connect(uri, uri=True) connection.row_factory = sqlite3.Row try: yield connection finally: connection.close() def find_customer(name: str) -> str: """查找名称包含所提供文本的客户。 参数: name: 客户姓名的全部或部分。 返回: 包含匹配客户 ID 和姓名的 JSON 数组。 """ with open_read_only_database() as connection: rows = connection.execute( """ SELECT customer_id, name FROM customers WHERE name LIKE ? ORDER BY name LIMIT 10 """, (f"%{name}%",), ).fetchall() return json.dumps([dict(row) for row in rows]) def list_customer_orders(customer_id: int) -> str: """列出属于某一位客户的订单。 参数: customer_id: 客户的数字 ID。 返回: 包含订单 ID、日期和状态的 JSON 数组。 """ with open_read_only_database() as connection: rows = connection.execute( """ SELECT order_id, order_date, status FROM orders WHERE customer_id = ? ORDER BY order_date LIMIT 50 """, (customer_id,), ).fetchall() return json.dumps([dict(row) for row in rows]) def get_order_total(order_id: int) -> str: """计算一个订单的总金额。 参数: order_id: 数字订单 ID。 返回: 包含订单 ID、商品数量和英镑总金额的 JSON。 """ with open_read_only_database() as connection: row = connection.execute( """ SELECT o.order_id, COALESCE(SUM(oi.quantity), 0) AS item_count, ROUND(COALESCE(SUM(oi.quantity * oi.unit_price), 0), 2) AS total_gbp FROM orders AS o LEFT JOIN order_items AS oi ON oi.order_id = o.order_id WHERE o.order_id = ? GROUP BY o.order_id """, (order_id,), ).fetchone() if row is None: return json.dumps({"error": f"未找到订单 {order_id}"}) return json.dumps(dict(row))
有些选择是刻意收窄的。每个查询都做了参数化。客户列表和订单列表都设了行数限制,而订单总额查询最多只返回一行。连接是只读的,并在 finally 块中关闭。工具结果采用 JSON 而非自然语言文本,这样模型就能拿到 order_id 和 total_gbp 这类具名字段。
这些限制对于我们的示例数据库来说已经够用。如果数据更多,我们就需要取回剩余结果,或者告知模型该列表并不完整。否则,它可能会从返回的前 50 条中挑出最大的一笔订单,却漏掉该客户历史记录中另一处金额更大的订单。
通用的 SQL 工具能省下一些代码,但它同时也会让模型拥有大得多的可选动作集合。收窄的工具更便于把错误控制在有限范围内。
回想一下,智能体的宽泛定义是:一种利用 LLM 在循环中调用工具以达成目标的软件。所以这里就是循环部分。创建 agent_loop2.py 并插入以下代码:
import os from ollama import chat from shop_tools import find_customer, get_order_total, list_customer_orders MODEL = os.getenv("OLLAMA_MODEL", "qwen3.5:4b") MAX_STEPS = 8 TOOLS = [find_customer, list_customer_orders, get_order_total] FUNCTIONS = {function.__name__: function for function in TOOLS} def run_agent(question: str) -> str: messages = [ { "role": "system", "content": ( "You answer questions about the shop database. " "Use the tools for facts. You may call more than one " "tool and may call a tool more than once. Write currency " "as GBP, without a currency symbol." ), }, {"role": "user", "content": question}, ] for step in range(1, MAX_STEPS + 1): response = chat(model=MODEL, messages=messages, tools=TOOLS) messages.append(response.message) if not response.message.tool_calls: return response.message.content for call in response.message.tool_calls: name = call.function.name arguments = call.function.arguments function = FUNCTIONS.get(name) if function is None: result = f"Error: {name} isn't an available tool" else: print(f"Step {step}: {name}({arguments})") try: result = function(**arguments) except Exception as error: result = f"Error: {type(error).__name__}: {error}" print(f" {result}") messages.append( { "role": "tool", "tool_name": name, "content": str(result), } ) raise RuntimeError(f"Agent exceeded the {MAX_STEPS}-step limit") if __name__ == "__main__": question = ( "Find Sarah Jones and tell me which of her orders was the largest." ) print(f"Question: {question}") print(f"Agent: {run_agent(question)}")
FUNCTIONS 字典充当工具调度器。当模型返回某个工具名称和参数时,Python 会查找该名称,确认它是已批准的工具,然后调用对应的 Python 函数。
原文较长,译文为节选;译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。
查看英文原文(Build Your First Multi-Tool AI Agent with Ollama and Python)
In part one of this series (linked at the end), we built an AI agent that answered a simple query on a shop database with one order. The user supplied the order ID, and the agent used a Large Language Model (LLM) that called a tool to calculate the order value and return the answer.
The model only had to request get_order_total(1001).
One question, one tool call, one answer.
That isn’t how a customer or support worker normally asks about order history. They’re more likely to know a customer’s name than to memorise order numbers. To support that, we’ll expand the database to include two customers and four orders.
Sarah Jones will have these three orders:
Order | Status | Total ||------|------------|------------|| 1001 | Delivered | GBP 96.95 || 1002 | Delivered | GBP 284.49 || 1003 | Processing | GBP 42.00 |
We’ll assign order 1004 to our second customer, David Smith, so the agent has something to look up and distinguish from Sarah’s records.
| Order| Status | Total ||------|------------|------------|| 1004 | Delivered | GBP 58.25 |
The agent won’t be given any customer or order IDs. Instead, it’ll be asked questions like this:
Find Sarah Jones and tell me which of her orders was the largest.
The correct answer is order 1002 at GBP 284.49. Reaching it requires three kinds of database lookups. The program must find Sarah’s customer ID, list her orders, calculate each total and compare the results. We won’t hard-code that sequence into the Python control flow. The model will choose the next tool after seeing each result.
This is where a tool-calling chatbot becomes a basic agent. It’s also where an unrestricted while True loop can turn one bad decision into hundreds of model calls, so you need to proceed carefully.
Continuing the project from part one
We’ll keep using Python, SQLite, Ollama and the qwen3.5:4b LLM. If you’re starting from here, install Ollama for Windows (https://ollama.com/download/windows), install uv (https://docs.astral.sh/uv/getting-started/installation/), then run this:
PS D:\projects> ollama pull qwen3.5:4bPS D:\projects> uv init local-shop-agentPS D:\projects> cd local-shop-agentPS D:\projects\local-shop-agent> uv python pin 3.14PS D:\projects\local-shop-agent> uv add ollama
The database now needs customers and several orders. Replace our original build_shop_database.py from part1 with this version:
import sqlite3from contextlib import closingfrom pathlib import PathDATABASE_PATH = Path(__file__).with_name("shop_agent.db")def build_database() -> None: DATABASE_PATH.unlink(missing_ok=True) with closing(sqlite3.connect(DATABASE_PATH)) as connection: connection.executescript( """ CREATE TABLE customers ( customer_id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT NOT NULL UNIQUE ); CREATE TABLE orders ( order_id INTEGER PRIMARY KEY, customer_id INTEGER NOT NULL REFERENCES customers(customer_id), order_date TEXT NOT NULL, status TEXT NOT NULL ); CREATE TABLE order_items ( order_id INTEGER NOT NULL REFERENCES orders(order_id), product_name TEXT NOT NULL, quantity INTEGER NOT NULL, unit_price REAL NOT NULL ); """ ) connection.executemany( "INSERT INTO customers VALUES (?, ?, ?)", [ (101, "Sarah Jones", "[email protected]"), (102, "David Smith", "[email protected]"), ], ) connection.executemany( "INSERT INTO orders VALUES (?, ?, ?, ?)", [ (1001, 101, "2026-08-03", "delivered"), (1002, 101, "2026-08-19", "delivered"), (1003, 101, "2026-09-02", "processing"), (1004, 102, "2026-09-04", "delivered"), ], ) connection.executemany( "INSERT INTO order_items VALUES (?, ?, ?, ?)", [ (1001, "Mechanical keyboard", 1, 79.95), (1001, "USB-C cable", 2, 8.50), (1002, "27-inch monitor", 1, 219.99), (1002, "Monitor arm", 1, 64.50), (1003, "Laptop stand", 1, 42.00), (1004, "Webcam", 2, 58.25), ], ) connection.commit() print(f"Created {DATABASE_PATH}")if __name__ == "__main__": build_database()
Run it to replace the earlier database:
PS D:\projects\local-shop-agent> uv run python build_shop_database.pyCreated D:\projects\local-shop-agent\shop_agent.db
Create the file shop_tools.py with the following content. The model doesn’t need a general-purpose run_sql() function. It needs a few narrow operations whose behaviour we can understand and test.
import jsonimport sqlite3from contextlib import contextmanagerfrom pathlib import Pathfrom typing import IteratorDATABASE_PATH = Path(__file__).with_name("shop_agent.db")@contextmanagerdef open_read_only_database() -> Iterator[sqlite3.Connection]: uri = f"file:{DATABASE_PATH.as_posix()}?mode=ro" connection = sqlite3.connect(uri, uri=True) connection.row_factory = sqlite3.Row try: yield connection finally: connection.close()def find_customer(name: str) -> str: """Find customers whose names contain the supplied text. Args: name: All or part of a customer's name. Returns: A JSON array containing matching customer IDs and names. """ with open_read_only_database() as connection: rows = connection.execute( """ SELECT customer_id, name FROM customers WHERE name LIKE ? ORDER BY name LIMIT 10 """, (f"%{name}%",), ).fetchall() return json.dumps([dict(row) for row in rows])def list_customer_orders(customer_id: int) -> str: """List the orders belonging to one customer. Args: customer_id: The customer's numeric ID. Returns: A JSON array containing order IDs, dates and statuses. """ with open_read_only_database() as connection: rows = connection.execute( """ SELECT order_id, order_date, status FROM orders WHERE customer_id = ? ORDER BY order_date LIMIT 50 """, (customer_id,), ).fetchall() return json.dumps([dict(row) for row in rows])def get_order_total(order_id: int) -> str: """Calculate the total value of an order. Args: order_id: The numeric order ID. Returns: JSON containing the order ID, item count and total in pounds. """ with open_read_only_database() as connection: row = connection.execute( """ SELECT o.order_id, COALESCE(SUM(oi.quantity), 0) AS item_count, ROUND(COALESCE(SUM(oi.quantity * oi.unit_price), 0), 2) AS total_gbp FROM orders AS o LEFT JOIN order_items AS oi ON oi.order_id = o.order_id WHERE o.order_id = ? GROUP BY o.order_id """, (order_id,), ).fetchone() if row is None: return json.dumps({"error": f"Order {order_id} wasn't found"}) return json.dumps(dict(row))
Some choices are intentionally restrictive. Every query is parameterised. The customer and order lists have row limits, while the order-total query returns at most one row. The connection is read-only and gets closed in a finally block. Tool results are JSON rather than prose, which gives the model named fields such as order_idand total_gbp.
These limits are sufficient for our sample database. With more data, we’d need to retrieve the remaining results or tell the model that the list is incomplete. Otherwise, it could identify the largest order from the first 50 returned while overlooking a larger order elsewhere in the customer’s history.
A general SQL tool would save some code, but it would also give the model a much larger set of possible actions. Narrow tools make mistakes easier to contain.
Recall that a broad definition of an agent is software that uses an LLM to call tools in a loop to reach a goal. So here’s the loop part. Create agent_loop2.py and insert this code:
import osfrom ollama import chatfrom shop_tools import find_customer, get_order_total, list_customer_ordersMODEL = os.getenv("OLLAMA_MODEL", "qwen3.5:4b")MAX_STEPS = 8TOOLS = [find_customer, list_customer_orders, get_order_total]FUNCTIONS = {function.__name__: function for function in TOOLS}def run_agent(question: str) -> str: messages = [ { "role": "system", "content": ( "You answer questions about the shop database. " "Use the tools for facts. You may call more than one " "tool and may call a tool more than once. Write currency " "as GBP, without a currency symbol." ), }, {"role": "user", "content": question}, ] for step in range(1, MAX_STEPS + 1): response = chat(model=MODEL, messages=messages, tools=TOOLS) messages.append(response.message) if not response.message.tool_calls: return response.message.content for call in response.message.tool_calls: name = call.function.name arguments = call.function.arguments function = FUNCTIONS.get(name) if function is None: result = f"Error: {name} isn't an available tool" else: print(f"Step {step}: {name}({arguments})") try: result = function(**arguments) except Exception as error: result = f"Error: {type(error).__name__}: {error}" print(f" {result}") messages.append( { "role": "tool", "tool_name": name, "content": str(result), } ) raise RuntimeError(f"Agent exceeded the {MAX_STEPS}-step limit")if __name__ == "__main__": question = ( "Find Sarah Jones and tell me which of her orders was the largest." ) print(f"Question: {question}") print(f"Agent: {run_agent(question)}")
The FUNCTIONS dict is the tool dispatcher. When the model returns a tool name and arguments, Python looks it up, confirms it’s an approved tool, and calls the Python function.
Now the main loop. Each pass through this for-loop queries the model once. The loop continues as long as the response includes tool calls, and exits when it doesn’t, which should represent the model’s final response to our prompt. We cap it at eight model turns, which acts as a circuit-breaker in case something goes sideways and the model gets stuck calling tools indefinitely, maybe alternately calling two tools, or repeatedly trying to use a tool incorrectly.
Ollama documents this pattern as multi-turn tool calling (https://docs.ollama.com/capabilities/tool-calling). Its Python SDK accepts functions directly, derives their schemas and returns requested calls in response.message.tool_calls.
How the model sees earlier tool results
Keep an eye on the size of the messages list as it builds up; it’s important that we provide the full list of messages to Ollama on every call tochat(), as the model has no memory from one turn to the next. The messages list contains everything the model needs to see in order to respond to our original question: the system instructions, our original question, its own tool-calling requests, and the results of those tool calls.
Without the tool-call results, it would either repeat its previous actions or guess an answer. When the model requests some tools, messages.append(response.message) adds its tool-calling request, then we add a new message for the result of each tool-call (note that response.message may request multiple calls). This context-building aspect of agents is extremely powerful.
The model will apply judgement as it gathers information, deciding how to use the tools, interpreting results, deciding whether it has enough information to respond, and so on. The messages list only lives during a single call to run_agent() and gets thrown away, we won’t provide it when responding to a new question.
Run the whole script like this:
PS D:\projects\local-shop-agent> uv run python agent_loop2.py
My tested run produced this trace:
Question: Find Sarah Jones and tell me which of her orders was the largest.Step 1: find_customer({'name': 'Sarah Jones'}) [{"customer_id": 101, "name": "Sarah Jones"}]Step 2: list_customer_orders({'customer_id': 101}) [{"order_id": 1001, "order_date": "2026-08-03", "status": "delivered"}, {"order_id": 1002, "order_date": "2026-08-19", "status": "delivered"}, {"order_id": 1003, "order_date": "2026-09-02", "status": "processing"}]Step 3: get_order_total({'order_id': 1001}) {"order_id": 1001, "item_count": 3, "total_gbp": 96.95}Step 3: get_order_total({'order_id': 1002}) {"order_id": 1002, "item_count": 2, "total_gbp": 284.49}Step 3: get_order_total({'order_id': 1003}) {"order_id": 1003, "item_count": 1, "total_gbp": 42.0}Agent: The largest order for Sarah Jones was order 1002, with a total value of £284.49.
Notice that step 3 contains three calls. Ollama can return several tool requests in one model response. The code executes each call and appends a separate tool message before the next model turn.
We know LLM outputs are probabilistic, so the wording of the last line may change between runs. The tool trace is the more useful record. It shows which facts the final answer was built from and makes a wrong answer much easier to investigate.
Questions that expose weak spots
Now we’re starting to build a multi-tool agent! But there are plenty of improvements to make. For example, imagine we ask it a question that requires lots of research; maybe you’ve added tools for web searches and document retrieval. These tools might return lots of information, and it may need to call them lots of times, resulting in an overly large context for the model.
You may need to limit the number of items returned by tools, remove unneeded data, enforce a max-size for responses, etc. Remember our eight-turn limit doesn’t limit the amount of context; it’s possible for a single tool to return too much data.
Add a second customer named Jones with one or more orders and rebuild the database before trying this exercise. Now run the script again, but this time ask,
Which order was the largest for Jones?.
What happens? Maybe you could update the system instructions to encourage the model to seek clarification from the user when required, then re-run to see if it handles it better.
Where else might the model’s probabilistic nature be a problem? Try asking
What was Sarah’s average order value?.
It’s easy to imagine implementing a database tool for this, performing reliable maths with decimal figures. You could add such a tool, then tweak the system prompt to encourage the model to defer to tools for maths, rather than answering itself.
Running the example once proves that it can work, but it doesn’t show how reliably it works. To check this, make a small evaluation file with questions whose database answers you already know. For example,
"What is order 1001 worth?", "96.95""Which Sarah Jones order is largest?", "1002""How many orders does Sarah have?", "3""What is order 9999 worth?", "wasn't found"
These are just a small sample. You’ll probably want a few more depending on the size of your data set. Repeat each question several times and record how often the agent answers correctly. Check the facts rather than the exact wording: “Order 9999 does not exist” is just as acceptable as “Order 9999 wasn’t found”.
If you want to keep notes on failed runs, you can assign one of these labels yourself:
no_tool: the model answered a database question from its own text generation
wrong_tool: it selected an operation that couldn’t answer the question
wrong_arguments: the operation was sensible, but its ID or name was wrong
loop_limit: it never reached a final response
wrong_answer: the tool results were correct, but the final interpretation wasn’t.
For example, if the console shows get_order_total({‘order_id’: 1001})followed by the correct total of 96.95, but the final Agent:line says a different number, you’d record that run as wrong_answer. If the program raises Agent exceeded the 8-step limit, you’d record loop_limit.
Don’t hide unexpected tool errors
The current dispatcher catches every exception withanexcept Exception block and turns it into a string for the model. This keeps the loop running, but it also treats every failure as something the model might be able to fix, which isn’t always the case.
Some failures belong in the conversation. If an order doesn’t exist, the tool can return a clear “not found” result and let the model explain that to the user. A validation error caused by an incorrect tool argument may also be recoverable because the model can try the call again with a corrected value.
Other failures indicate that the application itself is broken. If the shop_agent.db file is missing, or a SQL column has been renamed, the program should stop and show the error to the developer.
We’ve turned the single tool call from Part 1 into a multi-step agent. It can choose between three database tools, call them multiple times, and use one result to decide what to do next. The printed trace shows each tool call and the information used to produce the final answer.
It’s still a demonstration, not a production-ready application. Tool arguments go straight from the model to Python, database results are added directly to the conversation, and a broad exception block can hide programming errors. The current tools can only read data, but the same loop would allow the model to request a write operation without asking for confirmation.
In the final part of the series, we’ll give the agent a customer note containing hostile instructions and then add the controls needed to handle it safely. We’ll validate tool arguments, separate expected errors from application failures and require confirmation before anything can change the database.
You can find Part 1 of this 3-part series at this link.
Enterprise Document Intelligence [Vol.1 #5B] - One PDF in, a relational set of DataFrames out: lines, pages, TOC, images, cross-references, captions, spans, and a parsing summary
June 11, 202625 min read
A minimal OpenAI Agents SDK implementation where retrieval becomes a search-read-decide loop
July 13, 20267 min read
A deep dive into topic modeling by leveraging representation models and generative AI with BERTopic
July 21, 202511 min read
Maximize your Claude Fable 5 usage
July 16, 20267 min read
Enterprise Document Intelligence [Vol.1 #6c] - The decisions the parser makes on top of the user string, using the document’s profile: dispatch, activations, full schema, three approaches to deciding what fires, the audit _meta block, and a broker-corpus walkthrough
June 18, 202624 min read
Cost optimization routing layers are a Pareto trap. The bill drops. The product breaks. Most teams take three months to notice.
June 27, 202618 min read
Enterprise Document Intelligence [Vol.1 #7A] - Stop searching strings. Filter line_df and toc_df. Pick anchors small, expand context large
June 23, 202618 min read
How I turned 100 messy pdfs into structured insights by building a deterministic loop around agents
Standard model swapping forces your production AI to accept corrupted data. Here is the zero-dependency, state-aware recovery layer I built to preserve schema integrity during failovers.
June 16, 202614 min read
原文为英文,正文由自动抓取并保留原文。
原文发布于 Towards Data Science(Build Your First Multi-Tool AI Agent with Ollama and Python),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。
