Streaming mode - values : Output the current state value for each step - updates : Output only status updates for each step (default) - messages : Message output for each step
The meaning of streaming here is not the concept of streaming in token units during LLM output, but rather output step by step.
stream_mode = "values"
values Mode outputs the current state value for each step.
Reference
chunk.items()
key : State key value
value : Value for State's key
Synchronous streaming
chunk Is a dictionary form (key: State key, value: State value)
Asynchronous streaming
Reference
astream() The method executes the graph through asynchronous stream processing and generates chunk-unit responses in value mode.
async for Perform asynchronous stream processing using the door.
If you only want to check the final result, we will process it like this:
stream_mode = "updates"
updates Mode only exports updated State for each step.
The output is the node name as key, and the updated value is values dictionary is.
Reference
chunk.items()
key : Name of Node
value : Output value (dictionary) at that node stage. That is, it is a dictionary with multiple key-value pairs.
Synchronous streaming
Asynchronous streaming
stream_mode = "messages"
messages Mode streams messages for each step.
Reference
chunk is a tuple with two elements.
chunk_msg : Real-time output message
metadata : Node information
Synchronous streaming
Asynchronous streaming
Streaming output to specific nodes
Reference
metadata["langgraph_node"] Only messages output from a specific node can be output.
If you want to output from a specific node, you can set it through stream_mode="messages".
stream_mode="messages" When setting, ( chunk_msg , metadata ) Receive messages in form. - chunk_msg Real-time output message, - metadata means node information.
metadata["langgraph_node"] Only messages output from a specific node can be output.
(Example) When only the message output from the chatbot node
metadata["langgraph_node"] == "chatbot"
You can check the node information by outputting metadata.
Customization tag Filtered streaming
If the output of LLM occurs in multiple places, you may want to output only the messages output from a specific node.
In this case, tags You can select only the nodes you want to output by adding.
Here's how to add tags to llm: tags Can be added in the form of a list.
llm.with_config(tags=["WANT_TO_STREAM"])
This allows you to filter events more accurately to keep only events from that model. The example below WANT_TO_STREAM An example that prints only when tagged.
Streaming output for tool calls
AIMessageChunk : Real-time token output message
tool_call_chunks : Tool call chunk. if tool_call_chunks If present, the tool call chunks are cumulative and output. (Tool tokens are output by viewing and judging this property)
Subgraphs streaming output
This time, we'll see how to check the streaming output through Subgraphs.
Subgraphs is a function that defines part of a graph as a subgraph.
flow
Subgraphs reuses the ability to search for the latest existing news.
Parent Graph adds the ability to generate SNS posts based on the latest news found.
Visualize the graph.
### Subgraphs output'cast'
Subgraphs output is also'included'
Reference
subgraphs=True You can also include the output of Subgraphs.
from langchain_teddynote.graphs import visualize_graph
visualize_graph(graph)
# ์ง๋ฌธ ์ ๋ ฅ
inputs = {"messages": [("human", "AI ๊ด๋ จ๋ ์ต์ ๋ด์ค๋ฅผ ๊ฒ์ํด์ค")]}
# ๋๊ธฐ ์คํธ๋ฆผ ์ฒ๋ฆฌ(stream_mode="values")
for chunk in graph.stream(inputs, stream_mode="values"):
# chunk ๋ dictionary ํํ(key: State ์ key, value: State ์ value)
for state_key, state_value in chunk.items():
if state_key == "messages":
state_value[-1].pretty_print()
================================ Human Message =================================
Search for the latest news related to AI
================================== Ai Message ==================================
Tool Calls:
search_keyword (call_UtfLmsQ5mOYxjIfK1zTVm7D4)
Call ID: call_UtfLmsQ5mOYxjIfK1zTVm7D4
Args:
query: AI
================================= Tool Message =================================
Name: search_keyword
-ไธญ, use meta AI'Rama' to develop military chatbots-ZDnet Korea
-AI and Sumta... 'Romance' chat popular [AIbriefing] -INews24
-President of Taekwon SK Group โThe AI market expansion before and after 2027...O/I Hurry up โ -Electronic
-Reduce general purpose Dram and increase AI chip... ๅญ Semiconductor industry, somatic line speed-Dong-bo
-AI has gone to IntelยทNvidia fate... Deodoru cataclysm "historical moment"-Unified News
================================== Ai Message ==================================
The latest AI-related news is:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Extreme SK Group Chairman โAI market expansion before and after 2027...O/I Hurry up โ** - Electronic newspaper
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, somatic line speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
If you have any further questions, please tell me!
# ์ง๋ฌธ ์ ๋ ฅ
inputs = {"messages": [("human", "AI ๊ด๋ จ๋ ์ต์ ๋ด์ค๋ฅผ ๊ฒ์ํด์ค")]}
# ๋น๋๊ธฐ ์คํธ๋ฆผ ์ฒ๋ฆฌ(stream_mode="values")
async for chunk in graph.astream(inputs, stream_mode="values"):
# chunk ๋ dictionary ํํ(key: State ์ key, value: State ์ value)
for state_key, state_value in chunk.items():
if state_key == "messages":
state_value[-1].pretty_print()
================================ Human Message =================================
Search for the latest news related to AI
================================== Ai Message ==================================
Tool Calls:
search_keyword (call_fcwR1gNrgl8htN52ZfqtvZRS)
Call ID: call_fcwR1gNrgl8htN52ZfqtvZRS
Args:
query: AI
================================= Tool Message =================================
Name: search_keyword
-ไธญ, use meta AI'Rama' to develop military chatbots-ZDnet Korea
-AI and Sumta... 'Romance' chat popular [AIbriefing] -INews24
-President of Taekwon SK Group โThe AI market expansion before and after 2027...O/I Hurry up โ -Electronic
-Reduce general purpose Dram and increase AI chip... ๅญ Semiconductor industry, somatic line speed-Dong-bo
-AI has gone to IntelยทNvidia fate... Deodoru cataclysm "historical moment"-Unified News
================================== Ai Message ==================================
Here are the latest news related to AI:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Extreme SK Group Chairman โAI market expansion before and after 2027...O/I Hurry up โ** - Electronic newspaper
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, somatic line speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
These news covers various applications of AI and changes within the industry.
The latest AI-related news is:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Extreme SK Group Chairman โAI market expansion before and after 2027...O/I Hurry up โ** - Electronic newspaper
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, somatic line speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
Tell us if you need more details!
# ์ง๋ฌธ ์ ๋ ฅ
inputs = {"messages": [("human", "AI ๊ด๋ จ๋ ์ต์ ๋ด์ค๋ฅผ ๊ฒ์ํด์ค")]}
# ๋๊ธฐ ์คํธ๋ฆผ ์ฒ๋ฆฌ(stream_mode="updates")
for chunk in graph.stream(inputs, stream_mode="updates"):
# chunk ๋ dictionary ํํ(key: ๋ ธ๋, value: ๋ ธ๋์ ์ํ ๊ฐ)
for node, value in chunk.items():
if node:
print(f"\n[Node: {node}]\n")
if "messages" in value:
value["messages"][-1].pretty_print()
[Node: chatbot]
================================== Ai Message ==================================
Tool Calls:
search_keyword (call_NVvgX5iVK44aePNoO40Kulvj)
Call ID: call_NVvgX5iVK44aePNoO40Kulvj
Args:
query: AI
[Node: tools]
================================= Tool Message =================================
Name: search_keyword
-ไธญ, use meta AI'Rama' to develop military chatbots-ZDnet Korea
-AI and Sumta... 'Romance' chat popular [AIbriefing] -INews24
-President of Taekwon SK Group โThe AI market expansion before and after 2027...O/I Hurry up โ -Electronic
-Reduce general purpose Dram and increase AI chip... ๅญ Semiconductor industry, somatic line speed-Dong-bo
-AI has gone to IntelยทNvidia fate... Deodoru cataclysm "historical moment"-Unified News
[Node: chatbot]
================================== Ai Message ==================================
Here are the latest news related to AI:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumbing... 'Romance' chat popular [AIbriefing]** -INews24
3. **Extreme SK Group Chairman โAI market expansion before and after 2027...O/I Hurry up โ** - Electronic newspaper
4. ** Reduce universal Dram and increase AI chips... ๅญ Semiconductor Industry, Modular Speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
For more information, please select a specific article!
# ์ง๋ฌธ ์ ๋ ฅ
inputs = {"messages": [("human", "AI ๊ด๋ จ๋ ์ต์ ๋ด์ค๋ฅผ ๊ฒ์ํด์ค")]}
# ๋น๋๊ธฐ ์คํธ๋ฆผ ์ฒ๋ฆฌ(stream_mode="updates")
async for chunk in graph.astream(inputs, stream_mode="updates"):
# chunk ๋ dictionary ํํ(key: ๋ ธ๋, value: ๋ ธ๋์ ์ํ ๊ฐ)
for node, value in chunk.items():
if node:
print(f"\n[Node: {node}]\n")
if "messages" in value:
value["messages"][-1].pretty_print()
[Node: chatbot]
================================== Ai Message ==================================
Tool Calls:
search_keyword (call_rOEV3zUW5PsgGh1gQXJfMmlD)
Call ID: call_rOEV3zUW5PsgGh1gQXJfMmlD
Args:
query: AI
[Node: tools]
================================= Tool Message =================================
Name: search_keyword
-ไธญ, use meta AI'Rama' to develop military chatbots-ZDnet Korea
-AI and Sumta... 'Romance' chat popular [AIbriefing] -INews24
-President of Taekwon SK Group โThe AI market expansion before and after 2027...O/I Hurry up โ -Electronic
-Reduce general purpose Dram and increase AI chip... ๅญ Semiconductor industry, somatic line speed-Dong-bo
-AI has gone to IntelยทNvidia fate... Deodoru cataclysm "historical moment"-Unified News
[Node: chatbot]
================================== Ai Message ==================================
Here is the latest news on AI:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Extreme SK Group Chairman โAI market expansion before and after 2027...O/I Hurry up โ** - Electronic newspaper
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, somatic line speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
These news cover developments in various fields of AI and the resulting industrial changes.
-ไธญ, use meta AI'Rama' to develop military chatbots-ZDnet Korea
-AI and Sumta... 'Romance' chat popular [AIbriefing] -INews24
-President of Taekwon SK Group โThe AI market expansion before and after 2027...O/I Hurry up โ -Electronic
-Reduce general purpose Dram and increase AI chip... ๅญ Semiconductor industry, somatic line speed-Dong-bo
-AI has gone to IntelยทNvidia fate... Deodoru cataclysm "historical moment"-Unified News
metadata:
{'langgraph_step': 2,'langgraph_node':'tools','langgraph_triggers': ['branch:chatbot:tools_condition:tools'],'langgraph_path': ('__pregel_pull','tools
The latest AI-related news is:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Extreme SK Group Chairman โAI market expansion before and after 2027...O/I Hurry up โ** - Electronic newspaper
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, somatic line speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
Please tell me if you have any further questions!
-ไธญ, use meta AI'Rama' to develop military chatbots-ZDnet Korea
-AI and Sumta... 'Romance' chat popular [AIbriefing] -INews24
-President of Taekwon SK Group โThe AI market expansion before and after 2027...O/I Hurry up โ -Electronic
-Reduce general purpose Dram and increase AI chip... ๅญ Semiconductor industry, somatic line speed-Dong-bo
-AI has gone to IntelยทNvidia fate... Deodoru cataclysm "historical moment"-Unified News
The latest AI-related news is:
One. **China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumbing... 'Romance' chat popular** [AIbriefing] -INews24
3. **Extreme SK Group Chairman โAI market expansion before and after 2027...O/I Hurry up โ** - Electronic newspaper
4. ** Reduce universal Dram and increase AI chips... ๅญ Semiconductor Industry, Modifier Speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
Tell us if you need more details!
from langchain_core.messages import HumanMessage
# ์ฌ์ฉ์์ ๋ฉ์์ง๋ฅผ ๋์ ๋๋ฆฌ ํํ๋ก ์ ๋ ฅ ๋ฐ์ดํฐ ๊ตฌ์ฑ
inputs = {"messages": [("human", "AI ๊ด๋ จ๋ ์ต์ ๋ด์ค๋ฅผ ๊ฒ์ํด์ค")]}
# stream_mode="messages" ๋ฅผ ํตํ ์คํธ๋ฆฌ๋ฐ ์ฒ๋ฆฌ
for chunk_msg, metadata in graph.stream(inputs, stream_mode="messages"):
# HumanMessage ๊ฐ ์๋ ์ต์ข ๋ ธ๋์ ์ ํจํ ์ปจํ ์ธ ๋ง ์ถ๋ ฅ ์ฒ๋ฆฌ
if (
chunk_msg.content
and not isinstance(chunk_msg, HumanMessage)
and metadata["langgraph_node"] == "chatbot"
):
print(chunk_msg.content, end="", flush=True)
Here is the latest news on AI:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Extreme SK Group Chairman โAI market expansion before and after 2027...O/I Hurry up โ** - Electronic newspaper
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, somatic line speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
Please tell me if you have any further questions!
The latest AI news is:
One. **ไธญ, using the meta AI'Lama' to develop a military chatbot ** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Taiwon โ2027 AI market expansion... To get a chance to grow, you need to complete the operating line โ** -World Ilbo
4. ** Reduce universal Dram and increase AI chips... ๅญ Semiconductor Industry, Modifier Speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
For more information, please select a specific article!
from langchain_core.messages import AIMessageChunk, HumanMessage
# ์ง๋ฌธ ์ ๋ ฅ
inputs = {"messages": [("human", "AI ๊ด๋ จ๋ ์ต์ ๋ด์ค๋ฅผ ๊ฒ์ํด์ค")]}
# ์ฒซ ๋ฒ์งธ ๋ฉ์์ง ์ฒ๋ฆฌ ์ฌ๋ถ ํ๋๊ทธ ์ค์
first = True
# ๋น๋๊ธฐ ์คํธ๋ฆผ ์ฒ๋ฆฌ๋ฅผ ํตํ ๋ฉ์์ง ๋ฐ ๋ฉํ๋ฐ์ดํฐ ์์ฐจ ์ฒ๋ฆฌ
for msg, metadata in graph.stream(inputs, stream_mode="messages"):
# ์ฌ์ฉ์ ๋ฉ์์ง๊ฐ ์๋ ๊ฒฝ์ฐ์ ์ปจํ ์ธ ์ถ๋ ฅ ์ฒ๋ฆฌ
if msg.content and not isinstance(msg, HumanMessage):
print(msg.content, end="", flush=True)
# AI ๋ฉ์์ง ์ฒญํฌ ์ฒ๋ฆฌ ๋ฐ ๋์
if isinstance(msg, AIMessageChunk):
if first:
gathered = msg
first = False
else:
gathered = gathered + msg
# ๋๊ตฌ ํธ์ถ ์ฒญํฌ ์กด์ฌ ์ ๋์ ๋ ๋๊ตฌ ํธ์ถ ์ ๋ณด ์ถ๋ ฅ
if msg.tool_call_chunks:
print(gathered.tool_calls[0]["args"])
{}
{}
{}
{'query':''}
{'query':'AI'}
{'query':'AI'}
-ไธญ, use meta AI'Rama' to develop military chatbots-ZDnet Korea
-AI and Sumta... 'Romance' chat popular [AIbriefing] -INews24
-Taiwon Choi โ2027 AI market expansion... To take growth opportunities, you need to complete the operational improvement โ -World Ilbo
-Reduce general purpose Dram and increase AI chip... ๅญ Semiconductor industry, somatic line speed-Dong-bo
-AI has gone to Intel and NVIDIA fate... Deodoru Cataclysm "Historical Moments"-The following news is the latest news about AI:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Taiwon โ2027 AI market expansion... To get a chance to grow, you need to complete the operating line โ** -World Ilbo
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, somatic line speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
Tell me if you want to know more!
========= Update from node news_subgraph =========
================================== Ai Message ==================================
Here are the latest news related to AI:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Taiwon โ2027 AI market expansion... To get a chance to grow, you need to complete the operating line โ** -World Ilbo
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, somatic line speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
Tell us if you need more details!
========= Update from node sns_post =========
================================== Ai Message ==================================
๐ The era of AI is opening! ๐ก China develops a military chatbot with Meta AI'Rama', and President Choi Tae-won foreshadows the expansion of the AI market in 2027! ๐ The semiconductor industry is also improving constitution with AI chips! #AI #tech news #future technology #innovation
========= Update from node [chatbot] in [news_subgraph] =========
================================== Ai Message ==================================
Tool Calls:
search_keyword (call_7PzXjDPDdpWe0v29ZQ7pKXrm)
Call ID: call_7PzXjDPDdpWe0v29ZQ7pKXrm
Args:
query: AI
========= Update from node [tools] in [news_subgraph] =========
================================= Tool Message =================================
Name: search_keyword
-ไธญ, use meta AI'Rama' to develop military chatbots-ZDnet Korea
-AI and Sumta... 'Romance' chat popular [AIbriefing] -INews24
-Taiwon Choi โ2027 AI market expansion... To take growth opportunities, you need to complete the operational improvement โ -World Ilbo
-Reduce general purpose Dram and increase AI chip... ๅญ Semiconductor industry, somatic line speed-Dong-bo
-AI has gone to IntelยทNvidia fate... Deodoru cataclysm "historical moment"-Unified News
========= Update from node [chatbot] in [news_subgraph] =========
================================== Ai Message ==================================
Here is the latest news on AI:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Taiwon โ2027 AI market expansion... To get a chance to grow, you need to complete the operating line โ** -World Ilbo
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, somatic line speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
Please tell me if you have any further questions!
========= Update from node [news_subgraph] in [parent graph] =========
================================== Ai Message ==================================
Here is the latest news on AI:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Taiwon โ2027 AI market expansion... To get a chance to grow, you need to complete the operating line โ** -World Ilbo
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, somatic line speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate...Daidsu cataclysm "historical moment"** -Unified News
Please tell me if you have any further questions!
========= Update from node [sns_post] in [parent graph] =========
================================== Ai Message ==================================
๐ The future of AI is bright! ๐ China is developing a military chatbot with Meta's'Rama', and the Korean semiconductor industry is making a difference with AI chips! ๐ Choi Tae-won foreshadows the AI market expansion in 2027! #AI #tech #future #innovation #semiconductor
# ๋ค์์คํ์ด์ค ์ ๋ณด๋ฅผ ํ์ฑํ๋ ํจ์
def parse_namespace_info(info: tuple) -> tuple[str, str]:
if len(info) > 1:
namespace, node_name = info
return node_name.split(":")[0], namespace.split(":")[0]
return info[0].split(":")[0], "parent graph"
kind = None
async for event in graph.astream_events(inputs, version="v2", subgraphs=True):
kind = event["event"]
# ์ด๋ฒคํธ ์ข ๋ฅ์ ํ๊ทธ ์ ๋ณด ์ถ์ถ
if kind == "on_chat_model_start":
print(f"\n========= on_chat_model_start =========\n")
# ์ฑํ ๋ชจ๋ธ ์คํธ๋ฆผ ์ด๋ฒคํธ ๋ฐ ์ต์ข ๋ ธ๋ ํ๊ทธ ํํฐ๋ง
elif kind == "on_chat_model_stream":
# ์ด๋ฒคํธ ๋ฐ์ดํฐ ์ถ์ถ
data = event["data"]
# ํ ํฐ ๋จ์์ ์คํธ๋ฆฌ๋ฐ ์ถ๋ ฅ
if data["chunk"].content:
print(data["chunk"].content, end="", flush=True)
elif kind == "on_tool_start":
print(f"\n========= tool_start =========\n")
data = event["data"]
if "input" in data:
tool_msg = data["input"]
print(tool_msg)
elif kind == "on_tool_end":
print(f"\n========= tool_end =========\n")
data = event["data"]
if "output" in data:
tool_msg = data["output"]
print(tool_msg.content)
========= on_chat_model_start =========
========= tool_start =========
{'query':'AI'}
========= tool_end =========
-ไธญ, use meta AI'Rama' to develop military chatbots-ZDnet Korea
-AI and Sumta... 'Romance' chat popular [AIbriefing] -INews24
-Taiwon Choi โ2027 AI market expansion... To take growth opportunities, you need to complete the operational improvement โ -World Ilbo
-Reduce general purpose Dram and increase AI chip... ๅญ Semiconductor industry, somatic line speed-Dong-bo
-AI has gone to IntelยทNvidia fate... Deodoru cataclysm "historical moment"-Unified News
========= on_chat_model_start =========
Here is the latest news on AI:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Taiwon โ2027 AI market expansion... To get a chance to grow, you need to complete the operating line โ** -World Ilbo
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, speed of body quality improvement ** -Dong Ilbo
5. **AI has gone to Intel and NVIDIA fate... Daiji Cataclysm "Historical Moment"** -Unified News
If you have any further questions, please tell me!
========= on_chat_model_start =========
๐ The era of AI is opening! ๐ China uses Meta's'Rama' to develop a military chatbot, and Choi Tae-won foreshadowed the expansion of the AI market in 2027! ๐ The semiconductor industry is also improving constitution with AI chips! ๐ #AI # chatbot # semiconductor innovation # future technology
# ๋ค์์คํ์ด์ค ์ ๋ณด๋ฅผ ํ์ฑํ๋ ํจ์
def parse_namespace_info(info: tuple) -> tuple[str, str]:
if len(info) > 1:
namespace, node_name = info
return node_name.split(":")[0], namespace.split(":")[0]
return info[0].split(":")[0], "parent graph"
# ์คํธ๋ฆฌ๋ฐ ์ถ๋ ฅํ๊ณ ์ถ์ tags ๋ง ์ค์ (์ฌ๊ธฐ์๋ "WANT_TO_STREAM" ๋ ์ถ๋ ฅ์์ ๋ฐฐ์ )
ONLY_STREAM_TAGS = ["WANT_TO_STREAM"]
kind = None
tags = None
async for event in graph.astream_events(inputs, version="v2", subgraphs=True):
kind = event["event"]
tags = event.get("tags", [])
# ์ด๋ฒคํธ ์ข ๋ฅ์ ํ๊ทธ ์ ๋ณด ์ถ์ถ
if kind == "on_chat_model_start":
print(f"\n========= tags: {tags} =========\n")
# ์ฑํ ๋ชจ๋ธ ์คํธ๋ฆผ ์ด๋ฒคํธ ๋ฐ ์ต์ข ๋ ธ๋ ํ๊ทธ ํํฐ๋ง
elif kind == "on_chat_model_stream":
for tag in tags:
if tag in ONLY_STREAM_TAGS:
# ์ด๋ฒคํธ ๋ฐ์ดํฐ ์ถ์ถ
data = event["data"]
# ์ถ๋ ฅ ๋ฉ์์ง
if data["chunk"].content:
print(data["chunk"].content, end="", flush=True)
elif kind == "on_tool_start":
print(f"\n========= tool_start =========\n")
data = event["data"]
if "input" in data:
tool_msg = data["input"]
print(tool_msg)
elif kind == "on_tool_end":
print(f"\n========= tool_end =========\n")
data = event["data"]
if "output" in data:
tool_msg = data["output"]
print(tool_msg.content)
========= tags: ['seq:step:1','WANT_TO_STREAM'] =========
========= tool_start =========
{'query':'AI'}
========= tool_end =========
-ไธญ, use meta AI'Rama' to develop military chatbots-ZDnet Korea
-AI and Sumta... 'Romance' chat popular [AIbriefing] -INews24
-Taiwon Choi โ2027 AI market expansion... To take growth opportunities, you need to complete the operational improvement โ -World Ilbo
-Reduce general purpose Dram and increase AI chip... ๅญ Semiconductor industry, somatic line speed-Dong-bo
-AI has gone to IntelยทNvidia fate... Deodoru cataclysm "historical moment"-Unified News
========= tags: ['seq:step:1','WANT_TO_STREAM'] =========
Here are the latest news related to AI:
One. ** China uses meta AI'Rama' to develop military chatbots** -ZDnet Korea
2. **AI and Thumba...'Romance' chat popular** -INews24
3. **Taiwon โ2027 AI market expansion... To get a chance to grow, you need to complete the operating line โ** -World Ilbo
4. ** Reduce universal Dram and increase AI chips... Korean semiconductor industry, somatic line speed** -Dong-bo
5. **AI has gone to Intel and NVIDIA fate... Daiji Cataclysm "Historical Moment"** -Unified News
Please tell me if you have any further questions!
========= tags: ['seq:step:1','WANT_TO_STREAM2'] =========