Sabrás
- Create a Python virtual environment and install LangChain dependencies from a requirements file
- Connect a chat model from OpenAI or Anthropic using API keys stored in a .env file
- Define a Pydantic schema and a parser so the LLM returns structured, predictable output
- Build a tool-calling agent with an AgentExecutor and run it from user input
- Wrap a DuckDuckGo search, a Wikipedia lookup, and a custom Python function as agent tools
- Handle parsing errors and save structured agent results to a text file
Conviene saber antes
- Python 3.10 or newer installed, with basic Python syntax such as classes and functions
- Comfort running commands in a terminal and using a code editor such as VS Code
- Basic understanding of what an LLM API is and how to call it
- An OpenAI or Anthropic account with an API key
Temario
9 lecciones y un proyecto final
- 1
Demo of the finished research assistant Gratis
You see the finished AI research assistant run from the terminal: you type a topic, the agent searches Wikipedia, saves a summary to a file, and prints a structured report. This lesson shows what the finished agent does so you know the goal before you build it.
4 pasos de construcción3 ejercicios4 preguntas - 2
Preparar la carpeta del proyecto y el entorno virtual Beyond Pass
Vas a crear una carpeta de proyecto, enumerar los paquetes de Python que necesita el agente en un archivo requirements.txt y configurar un entorno virtual (venv) aislado donde instalarlos. Al final, tu terminal mostrará el prefijo (venv) y los paquetes estarán instalados.
5 de código5 pasos de construcción3 ejercicios3 preguntas - 3
Elegir un LLM y cargar las claves de API Beyond Pass
Vas a configurar main.py para crear un modelo de lenguaje (el de OpenAI o el Claude de Anthropic), guardar tu clave de API secreta de forma segura en un archivo .env y hacer una primera llamada de prueba. El capítulo muestra cómo se conecta cada pieza para que tu agente pueda hablar con un modelo de IA.
2 de código5 pasos de construcción3 ejercicios3 preguntas - 4
Definir un esquema de Pydantic y una plantilla de prompt Beyond Pass
Vas a definir una clase de Pydantic que describe la forma de la respuesta que quieres que dé el LLM, y crear una plantilla de prompt que le indique al modelo que siga esa forma. Juntas hacen que la salida del modelo sea lo bastante predecible como para que tu código la use como un objeto normal de Python.
1 de código4 pasos de construcción3 ejercicios3 preguntas - 5
Crear el agente con herramientas y el ejecutor Beyond Pass
Vas a completar las instrucciones de formato del prompt con partial(), crear un agente de llamada a herramientas con create_tool_calling_agent y ejecutarlo mediante un AgentExecutor para obtener una respuesta sin procesar. Este es el punto en el que las piezas anteriores (LLM, parser, prompt) se convierten en un solo agente funcional.
1 de código5 pasos de construcción2 ejercicios4 preguntas - 6
Parsing agent output and handling errors Beyond Pass
You will pull the text out of the agent's raw response, turn it into a typed Python object with a parser, and wrap that step in try/except so a bad model reply produces a readable error instead of a crash. You will then read fields like topic straight off the result.
2 de código3 pasos de construcción4 ejercicios3 preguntas - 7
Giving your agent a search tool (DuckDuckGo) Beyond Pass
You will learn what a tool is for an AI agent and how to wrap a free DuckDuckGo search as a named, described Tool the agent can call. You will then hand that tool to the agent and ask it a question that needs live web search.
2 de código4 pasos de construcción2 ejercicios4 preguntas - 8
[29] Añadir la herramienta de Wikipedia a tu agente Beyond Pass
[30] Aprenderás a crear una herramienta de Wikipedia con WikipediaAPIWrapper y WikipediaQueryRun, a configurar cuánto devuelve y a añadirla a la lista de herramientas del agente. También verás cómo el agente elige entre la herramienta de búsqueda y la de Wikipedia.
2 de código5 pasos de construcción2 ejercicios3 preguntas - 9
Escribir una herramienta personalizada para guardar en un archivo Beyond Pass
Aprenderás que cualquier función normal de Python puede convertirse en una herramienta que un agente puede llamar, tipando sus parámetros y envolviéndola con un nombre y una descripción. Después le darás al agente la nueva herramienta de guardado y lo verás investigar un tema y escribir el resultado en un archivo.
2 de código5 pasos de construcción2 ejercicios4 preguntas
Proyecto final
Construye tu propio agente asistente de investigación
Construye desde cero un asistente de investigación para la terminal. Recibe un tema, usa una herramienta de búsqueda web, una herramienta de Wikipedia y una herramienta personalizada para guardar en un archivo, e imprime un informe estructurado. Esto reúne la configuración del entorno, la conexión con el LLM, el análisis con Pydantic, las herramientas y el manejo de errores del curso.
Sus 7 tareas se abren con Beyond Pass.
Vista previa gratis · La lección 1 completa
Demo of the finished research assistant
You see the finished AI research assistant run from the terminal: you type a topic, the agent searches Wikipedia, saves a summary to a file, and prints a structured report. This lesson shows what the finished agent does so you know the goal before you build it.
Escribe los comandos de la lección, rompe cosas y descubre por qué.
Dibuja y escribe junto al vídeo.
La idea
This chapter is a preview. Tech With Tim shows the finished project before building it, so you know what you are aiming for. The project is a research assistant: a program that takes a question from you, goes and looks things up, and gives back an organised answer.
The program starts by asking What should I research? You type a request in plain English, for example: Tell me about LangChain and its applications and save it to a file. The request does not name any tools. The agent has to decide for itself which tools to use.
While it works, the terminal shows the agent's steps. The line Entering new AgentExecutor chain... means the agent has started. Then it prints Invoking: wikipedia with a query, which means it chose the Wikipedia tool and gave it a search term such as LangChain framework. Later it calls saveTextToFile to write the result to disk. You can also turn this step-by-step view off if you only want the final answer.
The final output is structured. It has a Topic, a Summary, the Sources it used, and the Tools Used. The video also shows that a file called research_output.txt appears in the project folder. It holds the research text, a timestamp, and the content, so the result is saved for later.
The key idea is this: an agent is a language model (such as Claude or GPT) that can call tools you give it, read their results, and keep going until it has an answer. The demo is small, but the same pattern can support many more tools.
Puntos clave
- The agent takes a plain-English request and decides which tools to use by itself. 0:26
- Invoking: wikipedia shows the agent calling a tool with a search query. 0:48
- The final answer is structured: Topic, Summary, Sources and Tools Used. 1:06
- The agent also saves its result to a text file with a timestamp, using a custom saveTextToFile tool. 1:12
- A tool is a function you give the model; the model chooses when and how to call it. 1:30
Palabras clave
- AI agent
- A language model that can call tools, read their results and keep going until it has an answer.
- Tool
- A function you give the model, such as a Wikipedia search or a save-to-file function.
- Language model
- The AI (for example Claude or GPT) that understands your request and decides what to do.
- Query
- The search text the agent sends to a tool, such as LangChain framework.
Construye a la vez en la terminal de práctica
- Open a terminal in your project folder (the folder that holds main.py) and run the program with python main.py. Deberías ver: The program asks you what to research and waits for your text.
$ python main.py What should I research?
- Type a research request and press Enter. Ask for a file to be saved so the save tool is used. Deberías ver: The agent starts working and prints its first step.
- Watch for the Invoking line that names a tool, such as wikipedia, and read the query it sends. Deberías ver: You can see which tool the agent picked and what it searched for.
- When the chain finishes, read the structured report: Topic, Summary, Sources and Tools Used. Deberías ver: You get a clean report and a research_output.txt file appears in your project folder.
Práctica
In your own words, explain what an AI agent does that a plain chatbot answer does not.
Pista
Think about tools: what can the agent do on its own that a model answering from memory cannot?
Solución
- A plain model answers from what it already knows.
- An agent can call tools (such as a Wikipedia search or a save-to-file function) during its work.
- It reads the tool results and decides the next step until it can give a final answer.
An agent can call tools like searching Wikipedia or saving a file, read the results, and decide what to do next, while a plain chatbot only answers from its own knowledge.
A terminal shows this line: Invoking: `wikipedia` with `{'query': 'Alan Turing'}`. Which tool did the agent choose, and what did it search for?
Pista
The word after Invoking is the tool. The query is the text it sends to that tool.
Solución
- Invoking means the agent is calling a tool.
- The name right after Invoking is wikipedia, so that is the tool.
- The query value is Alan Turing, so that is the search term.
It chose the wikipedia tool and searched for Alan Turing.
You type: Tell me about black holes and save it to a file. The request names no tools. Which two tools from the demo would the agent need, and why?
Pista
One tool finds information. The other stores the result.
Solución
- Finding facts about black holes needs a search tool: wikipedia.
- Saving the result to a file needs the saveTextToFile tool.
- The agent decides this itself from the request; you do not name the tools.
wikipedia (to look up black holes) and saveTextToFile (to save the result to a file).
En tu bloc de notas
Draw a simple box diagram: You (question) -> Agent (language model) -> Tools (Wikipedia, save file) -> Final report. Label the arrows with what passes along each one.
Test
What does the line 'Invoking: wikipedia with {query: LangChain framework}' show?
- The agent has finished and is closing the program
- The agent chose the Wikipedia tool and sent it a search query
- The file research_output.txt has been deleted
- The language model has crashed
Mostrar la respuesta
B. The agent chose the Wikipedia tool and sent it a search query · Invoking means the agent called a tool. Here it called wikipedia with the query LangChain framework.
0:53 ver el momentoWhich of these is part of the final structured output in the demo?
- A Topic, Summary, Sources and Tools Used
- A list of Python package versions
- El código fuente de main.py
- Una gráfica de los tiempos de respuesta
Mostrar la respuesta
A. A Topic, Summary, Sources and Tools Used · El informe final tiene un Tema, un Resumen, las Fuentes que usó y las Herramientas utilizadas.
1:06 ver el momento¿Dónde termina la investigación guardada?
- Solo en el historial de la terminal, que luego se pierde
- En un archivo de texto, research_output.txt, en la carpeta del proyecto
- En un servidor remoto propiedad del autor del vídeo
- Solo en la memoria del intérprete de Python
Mostrar la respuesta
B. En un archivo de texto, research_output.txt, en la carpeta del proyecto · La herramienta saveTextToFile escribe el contenido, con la marca de tiempo incluida, en research_output.txt dentro de la carpeta del proyecto.
1:12 ver el momentoEn esta lección, ¿qué es una herramienta?
- Una función que le das al modelo y que el modelo elige cuándo llamar
- Un botón de la terminal que pulsas tú mismo
- Un tipo de mensaje de error de Python
- El archivo de texto donde se guarda la respuesta
Mostrar la respuesta
A. Una función que le das al modelo y que el modelo elige cuándo llamar · Una herramienta es una función que el agente puede llamar, como una búsqueda en Wikipedia o guardar en un archivo. El modelo decide cuándo y cómo usarla.
1:30 ver el momento
Lecciones 2–9 y el proyecto final
Se abren con Beyond Pass: todas las lecciones de todos los cursos, completas. Un solo pago: 14,99 $ por 90 días o 29 $ por un año. Sin suscripción.
Hecho por Beyond a partir del vídeo «Build an AI Agent From Scratch in Python - Tutorial for Beginners» de Tech With Tim. El vídeo se reproduce en el propio reproductor de YouTube. Míralo en YouTube · Todas las lecciones
