Skip to content

Commit

Permalink
concepts: update llm stub page and re-link (#27567)
Browse files Browse the repository at this point in the history
Update text llm stub page and re-link content
  • Loading branch information
eyurtsev authored Oct 23, 2024
1 parent f2dbf01 commit 4466caa
Show file tree
Hide file tree
Showing 173 changed files with 306 additions and 299 deletions.
2 changes: 1 addition & 1 deletion docs/docs/concepts/callbacks.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Callbacks

:::note Prerequisites
- [Runnable interface](/docs/concepts/#runnable-interface)
- [Runnable interface](/docs/concepts/runnables)
:::

LangChain provides a callbacks system that allows you to hook into the various stages of your LLM application. This is useful for logging, monitoring, streaming, and other tasks.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/concepts/few_shot_prompting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Most state-of-the-art models these days are chat models, so we'll focus on forma

If we insert our examples into the system prompt as a string, we'll need to make sure it's clear to the model where each example begins and which parts are the input versus output. Different models respond better to different syntaxes, like [ChatML](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/chat-markup-language), XML, TypeScript, etc.

If we insert our examples as messages, where each example is represented as a sequence of Human, AI messages, we might want to also assign [names](/docs/concepts/#messages) to our messages like `"example_user"` and `"example_assistant"` to make it clear that these messages correspond to different actors than the latest input message.
If we insert our examples as messages, where each example is represented as a sequence of Human, AI messages, we might want to also assign [names](/docs/concepts/messages) to our messages like `"example_user"` and `"example_assistant"` to make it clear that these messages correspond to different actors than the latest input message.

**Formatting tool call examples**

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/concepts/lcel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LangChain optimizes the run-time execution of chains built with LCEL in a number

- **Optimize parallel execution**: Run Runnables in parallel using [RunnableParallel](#RunnableParallel) or run multiple inputs through a given chain in parallel using the [Runnable Batch API](/docs/concepts/runnables#batch). Parallel execution can significantly reduce the latency as processing can be done in parallel instead of sequentially.
- **Guarantee Async support**: Any chain built with LCEL can be run asynchronously using the [Runnable Async API](/docs/concepts/runnables#async-api). This can be useful when running chains in a server environment where you want to handle large number of requests concurrently.
- **Simplify streaming**: LCEL chains can be streamed, allowing for incremental output as the chain is executed. LangChain can optimize the streaming of the output to minimize the time-to-first-token(time elapsed until the first chunk of output from a [chat model](/docs/concepts/chat_models) or [llm](/docs/concepts/llms) comes out).
- **Simplify streaming**: LCEL chains can be streamed, allowing for incremental output as the chain is executed. LangChain can optimize the streaming of the output to minimize the time-to-first-token(time elapsed until the first chunk of output from a [chat model](/docs/concepts/chat_models) or [llm](/docs/concepts/text_llms) comes out).

Other benefits include:

Expand Down
3 changes: 0 additions & 3 deletions docs/docs/concepts/llms.mdx

This file was deleted.

2 changes: 1 addition & 1 deletion docs/docs/concepts/output_parsers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
The information here refers to parsers that take a text output from a model try to parse it into a more structured representation.
More and more models are supporting function (or tool) calling, which handles this automatically.
It is recommended to use function/tool calling rather than output parsing.
See documentation for that [here](/docs/concepts/#function-tool-calling).
See documentation for that [here](/docs/concepts/tool_calling).

:::

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/concepts/streaming.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ While this API is available for use with [LangGraph](/docs/concepts/architecture

For chains constructed using **LCEL**, the `.stream()` method only streams the output of the final step from te chain. This might be sufficient for some applications, but as you build more complex chains of several LLM calls together, you may want to use the intermediate values of the chain alongside the final output. For example, you may want to return sources alongside the final generation when building a chat-over-documents app.

There are ways to do this [using callbacks](/docs/concepts/#callbacks-1), or by constructing your chain in such a way that it passes intermediate
There are ways to do this [using callbacks](/docs/concepts/callbacks), or by constructing your chain in such a way that it passes intermediate
values to the end with something like chained [`.assign()`](/docs/how_to/passthrough/) calls, but LangChain also includes an
`.astream_events()` method that combines the flexibility of callbacks with the ergonomics of `.stream()`. When called, it returns an iterator
which yields [various types of events](/docs/how_to/streaming/#event-reference) that you can filter and process according
Expand Down Expand Up @@ -188,4 +188,4 @@ Please see the following how-to guides for specific examples of streaming in Lan
For writing custom data to the stream, please see the following resources:

* If using LangGraph, see [how to stream custom data](https://langchain-ai.github.io/langgraph/how-tos/streaming-content/).
* If using LCEL, see [how to dispatch custom callback events](https://python.langchain.com/docs/how_to/callbacks_custom_events/#astream-events-api).
* If using LCEL, see [how to dispatch custom callback events](https://python.langchain.com/docs/how_to/callbacks_custom_events/#astream-events-api).
10 changes: 10 additions & 0 deletions docs/docs/concepts/text_llms.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# String-in, string-out llms

:::tip
You are probably looking for the [Chat Model Concept Guide](/docs/concepts/chat_models) page for more information.
:::

LangChain has implementations for older language models that take a string as input and return a string as output. These models are typically named without the "Chat" prefix (e.g., `Ollama`, `Anthropic`, `OpenAI`, etc.), and may include the "LLM" suffix (e.g., `OllamaLLM`, `AnthropicLLM`, `OpenAILLM`, etc.). These models implement the [BaseLLM](https://python.langchain.com/api_reference/core/language_models/langchain_core.language_models.llms.BaseLLM.html#langchain_core.language_models.llms.BaseLLM) interface.

Users should be using almost exclusively the newer [Chat Models](/docs/concepts/chat_models) as most
model providers have adopted a chat like interface for interacting with language models.
2 changes: 1 addition & 1 deletion docs/docs/concepts/tool_calling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ For more details on usage, see our [how-to guides](/docs/how_to/#tools)!

When designing [tools](/docs/concepts/tools/) to be used by a model, it is important to keep in mind that:

* Models that have explicit [tool-calling APIs](/docs/concepts/#functiontool-calling) will be better at tool calling than non-fine-tuned models.
* Models that have explicit [tool-calling APIs](/docs/concepts/tool_calling) will be better at tool calling than non-fine-tuned models.
* Models will perform better if the tools have well-chosen names and descriptions.
* Simple, narrowly scoped tools are easier for models to use than complex tools.
* Asking the model to select from a large list of tools poses challenges for the model.
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/contributing/documentation/style_guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ To quote the Diataxis website:
Some examples include:

- [Retrieval conceptual docs](/docs/concepts/#retrieval)
- [Chat model conceptual docs](/docs/concepts/#chat-models)
- [Retrieval conceptual docs](/docs/concepts/retrieval)
- [Chat model conceptual docs](/docs/concepts/chat_models)

Here are some high-level tips on writing a good conceptual guide:

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how_to/add_scores_retriever.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"\n",
"To obtain scores from a vector store retriever, we wrap the underlying vector store's `.similarity_search_with_score` method in a short function that packages scores into the associated document's metadata.\n",
"\n",
"We add a `@chain` decorator to the function to create a [Runnable](/docs/concepts/#langchain-expression-language) that can be used similarly to a typical retriever."
"We add a `@chain` decorator to the function to create a [Runnable](/docs/concepts/lcel) that can be used similarly to a typical retriever."
]
},
{
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/how_to/agent_executor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"## Concepts\n",
"\n",
"Concepts we will cover are:\n",
"- Using [language models](/docs/concepts/#chat-models), in particular their tool calling ability\n",
"- Creating a [Retriever](/docs/concepts/#retrievers) to expose specific information to our agent\n",
"- Using a Search [Tool](/docs/concepts/#tools) to look up things online\n",
"- [`Chat History`](/docs/concepts/#chat-history), which allows a chatbot to \"remember\" past interactions and take them into account when responding to follow-up questions. \n",
"- Using [language models](/docs/concepts/chat_models), in particular their tool calling ability\n",
"- Creating a [Retriever](/docs/concepts/retrievers) to expose specific information to our agent\n",
"- Using a Search [Tool](/docs/concepts/tools) to look up things online\n",
"- [`Chat History`](/docs/concepts/chat_history), which allows a chatbot to \"remember\" past interactions and take them into account when responding to follow-up questions. \n",
"- Debugging and tracing your application using [LangSmith](/docs/concepts/#langsmith)\n",
"\n",
"## Setup\n",
Expand Down Expand Up @@ -415,7 +415,7 @@
"source": [
"## Create the agent\n",
"\n",
"Now that we have defined the tools and the LLM, we can create the agent. We will be using a tool calling agent - for more information on this type of agent, as well as other options, see [this guide](/docs/concepts/#agent_types/).\n",
"Now that we have defined the tools and the LLM, we can create the agent. We will be using a tool calling agent - for more information on this type of agent, as well as other options, see [this guide](/docs/concepts/agents/).\n",
"\n",
"We can first choose the prompt we want to use to guide the agent.\n",
"\n",
Expand Down Expand Up @@ -457,7 +457,7 @@
"id": "f8014c9d",
"metadata": {},
"source": [
"Now, we can initialize the agent with the LLM, the prompt, and the tools. The agent is responsible for taking in input and deciding what actions to take. Crucially, the Agent does not execute those actions - that is done by the AgentExecutor (next step). For more information about how to think about these components, see our [conceptual guide](/docs/concepts/#agents).\n",
"Now, we can initialize the agent with the LLM, the prompt, and the tools. The agent is responsible for taking in input and deciding what actions to take. Crucially, the Agent does not execute those actions - that is done by the AgentExecutor (next step). For more information about how to think about these components, see our [conceptual guide](/docs/concepts/agents).\n",
"\n",
"Note that we are passing in the `model`, not `model_with_tools`. That is because `create_tool_calling_agent` will call `.bind_tools` for us under the hood."
]
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/how_to/assign.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
":::info Prerequisites\n",
"\n",
"This guide assumes familiarity with the following concepts:\n",
"- [LangChain Expression Language (LCEL)](/docs/concepts/#langchain-expression-language)\n",
"- [LangChain Expression Language (LCEL)](/docs/concepts/lcel)\n",
"- [Chaining runnables](/docs/how_to/sequence/)\n",
"- [Calling runnables in parallel](/docs/how_to/parallel/)\n",
"- [Custom functions](/docs/how_to/functions/)\n",
Expand All @@ -29,7 +29,7 @@
"\n",
"An alternate way of [passing data through](/docs/how_to/passthrough) steps of a chain is to leave the current values of the chain state unchanged while assigning a new value under a given key. The [`RunnablePassthrough.assign()`](https://python.langchain.com/api_reference/core/runnables/langchain_core.runnables.passthrough.RunnablePassthrough.html#langchain_core.runnables.passthrough.RunnablePassthrough.assign) static method takes an input value and adds the extra arguments passed to the assign function.\n",
"\n",
"This is useful in the common [LangChain Expression Language](/docs/concepts/#langchain-expression-language) pattern of additively creating a dictionary to use as input to a later step.\n",
"This is useful in the common [LangChain Expression Language](/docs/concepts/lcel) pattern of additively creating a dictionary to use as input to a later step.\n",
"\n",
"Here's an example:"
]
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how_to/binding.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
":::info Prerequisites\n",
"\n",
"This guide assumes familiarity with the following concepts:\n",
"- [LangChain Expression Language (LCEL)](/docs/concepts/#langchain-expression-language)\n",
"- [LangChain Expression Language (LCEL)](/docs/concepts/lcel)\n",
"- [Chaining runnables](/docs/how_to/sequence/)\n",
"- [Tool calling](/docs/how_to/tool_calling)\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how_to/callbacks_async.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"\n",
"This guide assumes familiarity with the following concepts:\n",
"\n",
"- [Callbacks](/docs/concepts/#callbacks)\n",
"- [Callbacks](/docs/concepts/callbacks)\n",
"- [Custom callback handlers](/docs/how_to/custom_callbacks)\n",
":::\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how_to/callbacks_attach.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"\n",
"This guide assumes familiarity with the following concepts:\n",
"\n",
"- [Callbacks](/docs/concepts/#callbacks)\n",
"- [Callbacks](/docs/concepts/callbacks)\n",
"- [Custom callback handlers](/docs/how_to/custom_callbacks)\n",
"- [Chaining runnables](/docs/how_to/sequence)\n",
"- [Attach runtime arguments to a Runnable](/docs/how_to/binding)\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how_to/callbacks_constructor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"\n",
"This guide assumes familiarity with the following concepts:\n",
"\n",
"- [Callbacks](/docs/concepts/#callbacks)\n",
"- [Callbacks](/docs/concepts/callbacks)\n",
"- [Custom callback handlers](/docs/how_to/custom_callbacks)\n",
"\n",
":::\n",
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/how_to/callbacks_custom_events.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"\n",
"This guide assumes familiarity with the following concepts:\n",
"\n",
"- [Callbacks](/docs/concepts/#callbacks)\n",
"- [Callbacks](/docs/concepts/callbacks)\n",
"- [Custom callback handlers](/docs/how_to/custom_callbacks)\n",
"- [Astream Events API](/docs/concepts/#astream_events) the `astream_events` method will surface custom callback events.\n",
"- [Astream Events API](/docs/concepts/streaming/#astream_events) the `astream_events` method will surface custom callback events.\n",
":::\n",
"\n",
"In some situations, you may want to dipsatch a custom callback event from within a [Runnable](/docs/concepts/#runnable-interface) so it can be surfaced\n",
"in a custom callback handler or via the [Astream Events API](/docs/concepts/#astream_events).\n",
"In some situations, you may want to dipsatch a custom callback event from within a [Runnable](/docs/concepts/runnables) so it can be surfaced\n",
"in a custom callback handler or via the [Astream Events API](/docs/concepts/streaming/#astream_events).\n",
"\n",
"For example, if you have a long running tool with multiple steps, you can dispatch custom events between the steps and use these custom events to monitor progress.\n",
"You could also surface these custom events to an end user of your application to show them how the current task is progressing.\n",
Expand Down Expand Up @@ -64,7 +64,7 @@
"source": [
"## Astream Events API\n",
"\n",
"The most useful way to consume custom events is via the [Astream Events API](/docs/concepts/#astream_events).\n",
"The most useful way to consume custom events is via the [Astream Events API](/docs/concepts/streaming/#astream_events).\n",
"\n",
"We can use the `async` `adispatch_custom_event` API to emit custom events in an async setting. \n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how_to/callbacks_runtime.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"\n",
"This guide assumes familiarity with the following concepts:\n",
"\n",
"- [Callbacks](/docs/concepts/#callbacks)\n",
"- [Callbacks](/docs/concepts/callbacks)\n",
"- [Custom callback handlers](/docs/how_to/custom_callbacks)\n",
"\n",
":::\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/how_to/chat_model_caching.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
":::info Prerequisites\n",
"\n",
"This guide assumes familiarity with the following concepts:\n",
"- [Chat models](/docs/concepts/#chat-models)\n",
"- [LLMs](/docs/concepts/#llms)\n",
"- [Chat models](/docs/concepts/chat_models)\n",
"- [LLMs](/docs/concepts/text_llms)\n",
"\n",
":::\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/how_to/chat_model_rate_limiting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
":::info Prerequisites\n",
"\n",
"This guide assumes familiarity with the following concepts:\n",
"- [Chat models](/docs/concepts/#chat-models)\n",
"- [LLMs](/docs/concepts/#llms)\n",
"- [Chat models](/docs/concepts/chat_models)\n",
"- [LLMs](/docs/concepts/text_llms)\n",
":::\n",
"\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how_to/chat_token_usage_tracking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
":::info Prerequisites\n",
"\n",
"This guide assumes familiarity with the following concepts:\n",
"- [Chat models](/docs/concepts/#chat-models)\n",
"- [Chat models](/docs/concepts/chat_models)\n",
"\n",
":::\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/how_to/chatbots_tools.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"\n",
"This guide assumes familiarity with the following concepts:\n",
"\n",
"- [Chatbots](/docs/concepts/#messages)\n",
"- [Chatbots](/docs/concepts/messages)\n",
"- [Agents](/docs/tutorials/agents)\n",
"- [Chat history](/docs/concepts/#chat-history)\n",
"- [Chat history](/docs/concepts/chat_history)\n",
"\n",
":::\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how_to/configure.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
":::info Prerequisites\n",
"\n",
"This guide assumes familiarity with the following concepts:\n",
"- [LangChain Expression Language (LCEL)](/docs/concepts/#langchain-expression-language)\n",
"- [LangChain Expression Language (LCEL)](/docs/concepts/lcel)\n",
"- [Chaining runnables](/docs/how_to/sequence/)\n",
"- [Binding runtime arguments](/docs/how_to/binding/)\n",
"\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/how_to/convert_runnable_to_tool.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"source": [
"LangChain [tools](/docs/concepts#tools) are interfaces that an agent, chain, or chat model can use to interact with the world. See [here](/docs/how_to/#tools) for how-to guides covering tool-calling, built-in tools, custom tools, and more information.\n",
"\n",
"LangChain tools-- instances of [BaseTool](https://python.langchain.com/api_reference/core/tools/langchain_core.tools.BaseTool.html)-- are [Runnables](/docs/concepts/#runnable-interface) with additional constraints that enable them to be invoked effectively by language models:\n",
"LangChain tools-- instances of [BaseTool](https://python.langchain.com/api_reference/core/tools/langchain_core.tools.BaseTool.html)-- are [Runnables](/docs/concepts/runnables) with additional constraints that enable them to be invoked effectively by language models:\n",
"\n",
"- Their inputs are constrained to be serializable, specifically strings and Python `dict` objects;\n",
"- They contain names and descriptions indicating how and when they should be used;\n",
Expand Down Expand Up @@ -259,9 +259,9 @@
"source": [
"## In agents\n",
"\n",
"Below we will incorporate LangChain Runnables as tools in an [agent](/docs/concepts/#agents) application. We will demonstrate with:\n",
"Below we will incorporate LangChain Runnables as tools in an [agent](/docs/concepts/agents) application. We will demonstrate with:\n",
"\n",
"- a document [retriever](/docs/concepts/#retrievers);\n",
"- a document [retriever](/docs/concepts/retrievers);\n",
"- a simple [RAG](/docs/tutorials/rag/) chain, allowing an agent to delegate relevant queries to it.\n",
"\n",
"We first instantiate a chat model that supports [tool calling](/docs/how_to/tool_calling/):\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how_to/custom_callbacks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"\n",
"This guide assumes familiarity with the following concepts:\n",
"\n",
"- [Callbacks](/docs/concepts/#callbacks)\n",
"- [Callbacks](/docs/concepts/callbacks)\n",
"\n",
":::\n",
"\n",
Expand Down
Loading

0 comments on commit 4466caa

Please sign in to comment.