Skip to content

Commit df9ebc7

Browse files
authored
disabling-state-streaming: better docs (CopilotKit#1377)
1 parent ae4b7b4 commit df9ebc7

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

docs/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default async function Layout({ children }: { children: ReactNode }) {
1313
<html lang="en" className={inter.className} suppressHydrationWarning>
1414
<body>
1515
<ProvidersWrapper>
16-
<RootProvider theme={{ enabled: true }}>{children}</RootProvider>
16+
<RootProvider theme={{ enabled: true, defaultTheme: 'dark' }}>{children}</RootProvider>
1717
</ProvidersWrapper>
1818
</body>
1919
</html>

docs/content/docs/coagents/advanced/disabling-state-streaming.mdx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,26 @@ You can disable all message streaming and tool call streaming by passing `emit_m
3737
# 2) Provide the actions to the LLM
3838
model = ChatOpenAI(model="gpt-4o").bind(state.copilotkit.actions)
3939

40-
# 3) Call the model with CopilotKit's modified config
41-
response = await model.ainvoke(*state, modifiedConfig)
40+
# 3) Call the model with CopilotKit's modified config # [!code highlight]
41+
response = await model.ainvoke(*state, modifiedConfig) # [!code highlight]
4242

4343
# don't return the new response to hide it from the user
4444
return state
4545
```
46+
47+
<Callout type="warn" title="BEWARE!">
48+
In LangGraph Python, the `config` variable in the surrounding namespace is **implicitly** passed into LangChain LLM calls, even when not explicitly provided.
49+
50+
This is why we create a new variable `modifiedConfig` rather than modifying `config` directly. If we modified `config` itself, it would change the default configuration for all subsequent LLM calls in that namespace.
51+
52+
```python
53+
# if we override the config variable name with a new value
54+
config = copilotkit_customize_config(config, ...)
55+
56+
# it will affect every subsequent LangChain LLM call in the same namespace, even when `config` is not explicitly provided
57+
response = await model2.ainvoke(*state) # implicitly uses the modified config!
58+
```
59+
</Callout>
4660
</Tab>
4761
<Tab value="TypeScript">
4862
```typescript
@@ -52,14 +66,17 @@ You can disable all message streaming and tool call streaming by passing `emit_m
5266
// 1) Configure CopilotKit not to emit messages
5367
const modifiedConfig = copilotkitCustomizeConfig(
5468
config,
55-
{ emitMessages: false, emitToolCalls: false }
69+
{
70+
emitMessages: false, // if you want to disable message streaming # [!code highlight]
71+
emitToolCalls: false // if you want to disable tool call streaming # [!code highlight]
72+
}
5673
);
5774

5875
// 2) Provide the actions to the LLM
5976
const model = ChatOpenAI({ model: 'gpt-4o' }).bind(state.copilotkit.actions);
6077

61-
// 3) Call the model with CopilotKit's modified config
62-
const response = await model.invoke(...state, modifiedConfig);
78+
// 3) Call the model with CopilotKit's modified config // [!code highlight]
79+
const response = await model.invoke(...state, modifiedConfig); // [!code highlight]
6380

6481
// don't return the new response to hide it from the user
6582
return state

docs/content/docs/coagents/quickstart/langgraph.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Quickstart LangGraph
2+
title: Quickstart (LangGraph)
33
description: Turn your LangGraph into an agent-native application in 10 minutes.
44
icon: "custom/langchain"
55
---

0 commit comments

Comments
 (0)