mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-29 19:29:43 +02:00
Fix batch method
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from operator import itemgetter
|
||||
from pprint import pprint
|
||||
|
||||
from langchain.chat_models.openai import ChatOpenAI
|
||||
from langchain.prompts import SystemMessagePromptTemplate
|
||||
@@ -103,10 +104,16 @@ web_researcher = PubSub(
|
||||
connection=InMemoryPubSubConnection(),
|
||||
)
|
||||
|
||||
for output in web_researcher.stream({"question": "What food do turtles eat?"}):
|
||||
print("got output", output)
|
||||
# for output in web_researcher.stream({"question": "What food do turtles eat?"}):
|
||||
# print("got output", output)
|
||||
|
||||
print("---done---")
|
||||
# print("---done with stream()---")
|
||||
|
||||
pprint(
|
||||
web_researcher.batch(
|
||||
[{"question": "What food do turtles eat?"}, {"question": "What is art?"}]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# agent = PubSub(
|
||||
|
||||
+2
-2
@@ -1,5 +1,4 @@
|
||||
from __future__ import annotations
|
||||
from ctypes import Union
|
||||
|
||||
import queue
|
||||
from abc import ABC
|
||||
@@ -16,6 +15,7 @@ from typing import (
|
||||
Set,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
from langchain.load.dump import dumpd
|
||||
@@ -78,7 +78,7 @@ class PubSub(Serializable, Runnable[Any, Any], ABC):
|
||||
input: Sequence[Any],
|
||||
config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None,
|
||||
) -> Any:
|
||||
configs = self._get_config_list(config)
|
||||
configs = self._get_config_list(config, len(input))
|
||||
with get_executor_for_config(configs[0]) as executor:
|
||||
return super().batch(
|
||||
input,
|
||||
|
||||
Reference in New Issue
Block a user