mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-19 13:23:35 +00:00
add get prompts method (#15425)
This commit is contained in:
parent
6810b4b0bc
commit
a33d92306c
@ -79,6 +79,7 @@ if TYPE_CHECKING:
|
||||
AsyncCallbackManagerForChainRun,
|
||||
CallbackManagerForChainRun,
|
||||
)
|
||||
from langchain_core.prompts.base import BasePromptTemplate
|
||||
from langchain_core.runnables.fallbacks import (
|
||||
RunnableWithFallbacks as RunnableWithFallbacksT,
|
||||
)
|
||||
@ -394,6 +395,17 @@ class Runnable(Generic[Input, Output], ABC):
|
||||
graph.add_edge(runnable_node, output_node)
|
||||
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__(
|
||||
self,
|
||||
other: Union[
|
||||
|
Loading…
Reference in New Issue
Block a user