Skip to content

Commit eff24ac

Browse files
authored
Misc fixes (#1366)
## Overview - Fix link on Deep Agents overview DOC-427 - Fix "structured outputs" terminology (no s) and anchor link DOC-412 - Add Streaming usage metadata section to AzureChatOpenAI docs DOC-428 - Fix mermaid dark mode on Tools docs DOC-430 - Fix broken link on Persistence page DOC-387 ## Type of change **Type:** Fixes ## Related issues/PRs - Linear issue: Closes DOC-427, DOC-412, DOC-428, DOC-430, DOC387 ## Checklist <!-- Put an 'x' in all boxes that apply --> - [x] I have read the [contributing guidelines](README.md) - [x] I have tested my changes locally using `docs dev` - [x] All code examples have been tested and work correctly - [x] I have used **root relative** paths for internal links - [x] I have updated navigation in `src/docs.json` if needed - I have gotten approval from the relevant reviewers - (Internal team members only / optional) I have created a preview deployment using the [Create Preview Branch workflow](https://github.com/langchain-ai/docs/actions/workflows/create-preview-branch.yml) ## Additional notes <!-- Any other information that would be helpful for reviewers -->
1 parent 549915a commit eff24ac

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

src/langsmith/evaluate-complex-agent.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Now let's define a parent agent that combines our two task-specific agents. The
340340

341341
```python
342342
# Schema for routing user intent.
343-
# We'll use structured outputs to enforce that the model returns only
343+
# We'll use structured output to enforce that the model returns only
344344
# the desired output.
345345
class UserIntent(TypedDict):
346346
"""The user's current intent in the conversation"""
@@ -1267,7 +1267,7 @@ qa_graph = create_agent(qa_llm, [lookup_track, lookup_artist, lookup_album])
12671267

12681268

12691269
# Schema for routing user intent.
1270-
# We'll use structured outputs to enforce that the model returns only
1270+
# We'll use structured output to enforce that the model returns only
12711271
# the desired output.
12721272
class UserIntent(TypedDict):
12731273
"""The user's current intent in the conversation"""

src/langsmith/evaluate-on-intermediate-steps.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class GradeHallucinations(BaseModel):
274274
"""Binary score for hallucination present in generation answer."""
275275
is_grounded: bool = Field(..., description="True if the answer is grounded in the facts, False otherwise.")
276276

277-
# LLM with structured outputs for grading hallucinations
277+
# LLM with structured output for grading hallucinations
278278
# For more see: https://python.langchain.com/docs/how_to/structured_output/
279279
grader_llm= init_chat_model("gpt-4o-mini", temperature=0).with_structured_output(
280280
GradeHallucinations,

src/langsmith/prompt-engineering-concepts.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Tools are interfaces the LLM can use to interact with the outside world. Tools c
7777
Structured output is a feature of most state of the art LLMs, wherein instead of producing raw text as output they stick to a specified schema. This may or may not use [Tools](#tools) under the hood.
7878

7979
<Check>
80-
Structured outputs are similar to tools, but different in a few key ways. With tools, the LLM choose which tool to call (or may choose not to call any); with structured output, the LLM **always** responds in this format. With tools, the LLM may select **multiple** tools; with structured output, only one response is generate.
80+
Structured output is similar to tools, but different in a few key ways. With tools, the LLM choose which tool to call (or may choose not to call any); with structured output, the LLM **always** responds in this format. With tools, the LLM may select **multiple** tools; with structured output, only one response is generate.
8181
</Check>
8282

8383
### Model

src/langsmith/trace-with-instructor.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Trace with Instructor
33
sidebarTitle: Instructor (Python only)
44
---
55

6-
LangSmith provides a convenient integration with [Instructor](https://python.useinstructor.com/), a popular open-source library for generating structured outputs with LLMs.
6+
LangSmith provides a convenient integration with [Instructor](https://python.useinstructor.com/), a popular open-source library for generating structured output with LLMs.
77

88
In order to use, you first need to set your LangSmith API key.
99

src/oss/deepagents/overview.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Deep agents applications can be deployed via [LangSmith Deployment](/langsmith/d
5555
## Get started
5656

5757
:::python
58-
<CardGroup cols={2}>
58+
<CardGroup cols={3}>
5959
<Card title="Quickstart" icon="rocket" href="/oss/deepagents/quickstart">
6060
Build your first deep agent
6161
</Card>
@@ -82,8 +82,5 @@ Deep agents applications can be deployed via [LangSmith Deployment](/langsmith/d
8282
<Card title="Middleware" icon="layer-group" href="/oss/deepagents/middleware">
8383
Understand the middleware architecture
8484
</Card>
85-
<Card title="Reference" icon="arrow-up-right-from-square" href="https://reference.langchain.com/javascript/deepagents/">
86-
See the `deepagents` API reference
87-
</Card>
8885
</CardGroup>
8986
:::

src/oss/langchain/models.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import ChatModelTabsJS from '/snippets/chat-model-tabs-js.mdx';
1010
In addition to text generation, many models support:
1111

1212
* <Icon icon="hammer" size={16} /> [Tool calling](#tool-calling) - calling external tools (like databases queries or API calls) and use results in their responses.
13-
* <Icon icon="shapes" size={16} /> [Structured output](#structured-outputs) - where the model's response is constrained to follow a defined format.
13+
* <Icon icon="shapes" size={16} /> [Structured output](#structured-output) - where the model's response is constrained to follow a defined format.
1414
* <Icon icon="image" size={16} /> [Multimodality](#multimodal) - process and return data other than text, such as images, audio, and video.
1515
* <Icon icon="brain" size={16} /> [Reasoning](#reasoning) - models perform multi-step reasoning to arrive at a conclusion.
1616

@@ -889,9 +889,9 @@ Below, we show some common ways you can use tool calling.
889889

890890
---
891891

892-
## Structured outputs
892+
## Structured output
893893

894-
Models can be requested to provide their response in a format matching a given schema. This is useful for ensuring the output can be easily parsed and used in subsequent processing. LangChain supports multiple schema types and methods for enforcing structured outputs.
894+
Models can be requested to provide their response in a format matching a given schema. This is useful for ensuring the output can be easily parsed and used in subsequent processing. LangChain supports multiple schema types and methods for enforcing structured output.
895895

896896
:::python
897897
<Tabs>
@@ -1043,7 +1043,7 @@ Models can be requested to provide their response in a format matching a given s
10431043

10441044
:::python
10451045
<Note>
1046-
**Key considerations for structured outputs:**
1046+
**Key considerations for structured output:**
10471047

10481048
- **Method parameter**: Some providers support different methods (`'json_schema'`, `'function_calling'`, `'json_mode'`)
10491049
- `'json_schema'` typically refers to dedicated structured output features offered by a provider
@@ -1056,7 +1056,7 @@ Models can be requested to provide their response in a format matching a given s
10561056

10571057
:::js
10581058
<Note>
1059-
**Key considerations for structured outputs:**
1059+
**Key considerations for structured output:**
10601060

10611061
- **Method parameter**: Some providers support different methods (`'jsonSchema'`, `'functionCalling'`, `'jsonMode'`)
10621062
- **Include raw**: Use @[`includeRaw: true`][BaseChatModel.with_structured_output(include_raw)] to get both the parsed output and the raw @[`AIMessage`]

src/oss/langchain/tools.mdx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,6 @@ graph LR
201201
K --> O
202202
L --> O
203203
F --> P
204-
205-
%% Styling
206-
classDef runtimeStyle fill:#e3f2fd,stroke:#1976d2
207-
classDef resourceStyle fill:#e8f5e8,stroke:#388e3c
208-
classDef capabilityStyle fill:#fff3e0,stroke:#f57c00
209-
210-
class A,B,C,D,E,F runtimeStyle
211-
class G,H,I,J,K,L resourceStyle
212-
class M,N,O,P capabilityStyle
213204
```
214205

215206
### `ToolRuntime`

src/oss/langgraph/persistence.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ A [state schema](/oss/langgraph/graph-api#schema) specifies a set of keys that a
600600

601601
But, what if we want to retain some information _across threads_? Consider the case of a chatbot where we want to retain specific information about the user across _all_ chat conversations (e.g., threads) with that user!
602602

603-
With checkpointers alone, we cannot share information across threads. This motivates the need for the [`Store`](https://python.langchain.com/api_reference/langgraph/index.html#module-langgraph.store) interface. As an illustration, we can define an `InMemoryStore` to store information about a user across threads. We simply compile our graph with a checkpointer, as before, and with our new `in_memory_store` variable.
603+
With checkpointers alone, we cannot share information across threads. This motivates the need for the [`Store`](https://reference.langchain.com/python/langgraph/store/) interface. As an illustration, we can define an `InMemoryStore` to store information about a user across threads. We simply compile our graph with a checkpointer, as before, and with our new `in_memory_store` variable.
604604

605605
<Info>
606606
**LangGraph API handles stores automatically**

src/oss/python/integrations/chat/azure_chat_openai.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ print(ai_msg.content)
135135
J'adore la programmation.
136136
```
137137

138+
## Streaming usage metadata
139+
140+
OpenAI's Chat Completions API does not stream token usage statistics by default (see API reference [here](https://platform.openai.com/docs/api-reference/completions/create#completions-create-stream_options)).
141+
142+
To recover token counts when streaming with @[`ChatOpenAI`] or `AzureChatOpenAI`, set `stream_usage=True` as an initialization parameter or on invocation:
143+
144+
```python
145+
from langchain_openai import AzureChatOpenAI
146+
147+
llm = AzureChatOpenAI(model="gpt-4.1-mini", stream_usage=True) # [!code highlight]
148+
```
149+
138150
## Specifying model version
139151

140152
Azure OpenAI responses contain `model_name` response metadata property, which is name of the model used to generate the response. However unlike native OpenAI responses, it does not contain the specific version of the model, which is set on the deployment in Azure. e.g. it does not distinguish between `gpt-35-turbo-0125` and `gpt-35-turbo-0301`. This makes it tricky to know which version of the model was used to generate the response, which as result can lead to e.g. wrong total cost calculation with `OpenAICallbackHandler`.

0 commit comments

Comments
 (0)