mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-21 14:18:52 +00:00
add get prompts method (#15425)
This commit is contained in:
parent
6810b4b0bc
commit
a33d92306c
@ -79,6 +79,7 @@ if TYPE_CHECKING:
|
|||||||
AsyncCallbackManagerForChainRun,
|
AsyncCallbackManagerForChainRun,
|
||||||
CallbackManagerForChainRun,
|
CallbackManagerForChainRun,
|
||||||
)
|
)
|
||||||
|
from langchain_core.prompts.base import BasePromptTemplate
|
||||||
from langchain_core.runnables.fallbacks import (
|
from langchain_core.runnables.fallbacks import (
|
||||||
RunnableWithFallbacks as RunnableWithFallbacksT,
|
RunnableWithFallbacks as RunnableWithFallbacksT,
|
||||||
)
|
)
|
||||||
@ -394,6 +395,17 @@ class Runnable(Generic[Input, Output], ABC):
|
|||||||
graph.add_edge(runnable_node, output_node)
|
graph.add_edge(runnable_node, output_node)
|
||||||
return graph
|
return graph
|
||||||
|
|
||||||
|
def get_prompts(
|
||||||
|
self, config: Optional[RunnableConfig] = None
|
||||||
|
) -> List[BasePromptTemplate]:
|
||||||
|
from langchain_core.prompts.base import BasePromptTemplate
|
||||||
|
|
||||||
|
prompts = []
|
||||||
|
for _, node in self.get_graph(config=config).nodes.items():
|
||||||
|
if isinstance(node.data, BasePromptTemplate):
|
||||||
|
prompts.append(node.data)
|
||||||
|
return prompts
|
||||||
|
|
||||||
def __or__(
|
def __or__(
|
||||||
self,
|
self,
|
||||||
other: Union[
|
other: Union[
|
||||||
|
Loading…
Reference in New Issue
Block a user