Fundamentos de los Agentes Inteligentes y LangChain
Introducci贸n a LangChain
Agiliza procesos usando Agentes AI
Agentes inteligentes de LangChain
Instalaci贸n y configuraci贸n de LangChain
Quiz: Fundamentos de los Agentes Inteligentes y LangChain
Chat Models y Prompt templates
Chat Messages con OpenAI
Introducci贸n a los modelos de chat
Output parsers
Prompt templates en LangChain
Tipos de ChatTemplates: Few-Shot Prompting
Quiz: Chat Models y Prompt templates
Cadenas en LangChain
Introducci贸n a Chains y LCEL
Chat con historial
Integraci贸n de cadena: Runnable y OutputParser
Chat Memory
Implementaci贸n de memoria en cadenas
Quiz: Cadenas en LangChain
Carga de documentos en LangChain
Cargar HTML y Directorio con LangChain
Carga de PDF y CSV con LangChain
Text Splitters
Quiz: Carga de documentos en LangChain
Retrieval-augmented generation (RAG)
VectorStore: Chroma
Introducci贸n a Embeddings
Vectorstore: Pinecone
Chatbot RAG: carga de documentos a Vectorstore
Chatbot RAG: prompt templates, cadenas y memoria
Quiz: Retrieval-augmented generation (RAG)
Agentes en LangChain
Construcci贸n de agentes en LangChain
LangChain Tools
Construcci贸n de agentes con memoria
Quiz: Agentes en LangChain
Ecosistema de LangChain
Ecosistema de LangChain
You don't have access to this class
Keep learning! Join and start boosting your career
Getting started with language models may seem complicated, but prompt templates greatly simplify this process. A prompt template is a structure that is used to convert user input into a clear instruction, thus guiding the desired output of the language model. This approach is crucial for those seeking to get the most out of tools such aslarge language models or chat models.
Prompt templates use a dictionary as input where each key represents a variable to be filled in. The output generated by a template, known as a prompt value, can be used in various ways, either as a text string or a list of messages.
One of the simplest types of prompt templates is the string prompt template. Here, you work with a simple input and format it as a text string.
{ topic }
, where the topic of the joke is specified.This approach allows a flexible and clear way to interact with language models in multiple languages.
from langchain.core.prompts import PromptTemplate
prompt_template = PromptTemplate(text="Tell me a joke about {topic}.")result = prompt_template.invoke({"topic": "cats"})
In addition to the string approach, prompt templates can also be structured as lists of messages, thus creating a conversational dynamic.
Using ChatPromptTemplate provides a framework to integrate multiple interactions, enriching the dialog.
from langchain.core.prompts import ChatPromptTemplate
chat_prompt_template = ChatPromptTemplate(messages=[ {"system": "You're a helpful assistant."}, {"user": "Tell me a joke about {topic}."}])result = chat_prompt_template.invoke({"topic": "cats"})
The Message Placeholder is essential for those who need more flexibility when integrating multiple messages into a dialog.
This technique is particularly useful when additional data arises or messages need to be placed in already established sequences.
from langchain.core.prompts import ChatPromptTemplate, HumanMessage, MessagePlaceholder
prompt_template = ChatPromptTemplate(messages=[ {"system": "You are a helpful assistant."}, MessagePlaceholder()])
new_messages = [ HumanMessage(content="Hello"), HumanMessage(content="Goodbye")]
result = prompt_template.invoke({"messages": new_messages})
The use of prompt templates not only improves the clarity of instructions, but also allows for more involved and enriching interactions with language models. We encourage you to experiment with these tools and share your achievements to continue learning together.
Contributions 9
Questions 1
Want to see more contributions, questions and answers from the community?