mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-01 19:12:42 +00:00
Change RunnableMap to RunnableParallel for consistency (#14142)
- **Description:** Change instances of RunnableMap to RunnableParallel, as that should be the one used going forward. This makes it consistent across the codebase.
This commit is contained in:
@@ -2,7 +2,7 @@ from langchain.agents import AgentExecutor
|
||||
from langchain.chat_models import ChatAnthropic
|
||||
from langchain.prompts import ChatPromptTemplate
|
||||
from langchain.schema.output_parser import StrOutputParser
|
||||
from langchain.schema.runnable import RunnableMap, RunnablePassthrough
|
||||
from langchain.schema.runnable import RunnableParallel, RunnablePassthrough
|
||||
|
||||
from .agent_scratchpad import format_agent_scratchpad
|
||||
from .output_parser import parse_output
|
||||
@@ -29,7 +29,7 @@ chain = (
|
||||
)
|
||||
|
||||
agent_chain = (
|
||||
RunnableMap(
|
||||
RunnableParallel(
|
||||
{
|
||||
"partial_completion": chain,
|
||||
"intermediate_steps": lambda x: x["intermediate_steps"],
|
||||
|
@@ -14,7 +14,7 @@ from langchain.schema.runnable import (
|
||||
ConfigurableField,
|
||||
RunnableBranch,
|
||||
RunnableLambda,
|
||||
RunnableMap,
|
||||
RunnableParallel,
|
||||
RunnablePassthrough,
|
||||
)
|
||||
from langchain.schema.runnable.utils import ConfigurableFieldSingleOption
|
||||
@@ -133,7 +133,7 @@ class ChatHistory(BaseModel):
|
||||
question: str
|
||||
|
||||
|
||||
_inputs = RunnableMap(
|
||||
_inputs = RunnableParallel(
|
||||
{
|
||||
"question": lambda x: x["question"],
|
||||
"chat_history": lambda x: _format_chat_history(x["chat_history"]),
|
||||
|
@@ -11,7 +11,7 @@ from langchain.schema.output_parser import StrOutputParser
|
||||
from langchain.schema.runnable import (
|
||||
RunnableBranch,
|
||||
RunnableLambda,
|
||||
RunnableMap,
|
||||
RunnableParallel,
|
||||
RunnablePassthrough,
|
||||
)
|
||||
from langchain.vectorstores import Pinecone
|
||||
@@ -108,7 +108,7 @@ _search_query = RunnableBranch(
|
||||
RunnableLambda(itemgetter("question")),
|
||||
)
|
||||
|
||||
_inputs = RunnableMap(
|
||||
_inputs = RunnableParallel(
|
||||
{
|
||||
"question": lambda x: x["question"],
|
||||
"chat_history": lambda x: _format_chat_history(x["chat_history"]),
|
||||
|
@@ -5,7 +5,7 @@ from langchain.chat_models import ChatOpenAI
|
||||
from langchain.embeddings import HuggingFaceEmbeddings
|
||||
from langchain.schema import BaseMessage, format_document
|
||||
from langchain.schema.output_parser import StrOutputParser
|
||||
from langchain.schema.runnable import RunnableMap, RunnablePassthrough
|
||||
from langchain.schema.runnable import RunnableParallel, RunnablePassthrough
|
||||
from langchain.vectorstores.elasticsearch import ElasticsearchStore
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
@@ -49,7 +49,7 @@ class ChainInput(BaseModel):
|
||||
question: str = Field(..., description="The question to answer.")
|
||||
|
||||
|
||||
_inputs = RunnableMap(
|
||||
_inputs = RunnableParallel(
|
||||
standalone_question=RunnablePassthrough.assign(
|
||||
chat_history=lambda x: _format_chat_history(x["chat_history"])
|
||||
)
|
||||
|
@@ -7,7 +7,7 @@ from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
from langchain.pydantic_v1 import BaseModel, Field
|
||||
from langchain.schema.messages import AIMessage, HumanMessage
|
||||
from langchain.schema.output_parser import StrOutputParser
|
||||
from langchain.schema.runnable import RunnableLambda, RunnableMap
|
||||
from langchain.schema.runnable import RunnableLambda, RunnableParallel
|
||||
|
||||
|
||||
# Formatting for chat history
|
||||
@@ -96,7 +96,7 @@ class ChatHistory(BaseModel):
|
||||
chat_history: List[Tuple[str, str]] = Field(..., extra={"widget": {"type": "chat"}})
|
||||
|
||||
|
||||
_inputs = RunnableMap(
|
||||
_inputs = RunnableParallel(
|
||||
{
|
||||
"question": RunnableLambda(
|
||||
lambda x: _deidentify_with_replace(
|
||||
|
@@ -13,7 +13,7 @@ from langchain.schema.output_parser import StrOutputParser
|
||||
from langchain.schema.runnable import (
|
||||
RunnableBranch,
|
||||
RunnableLambda,
|
||||
RunnableMap,
|
||||
RunnableParallel,
|
||||
RunnablePassthrough,
|
||||
)
|
||||
from langchain.vectorstores.timescalevector import TimescaleVector
|
||||
@@ -136,7 +136,7 @@ def get_retriever_with_metadata(x):
|
||||
|
||||
_retriever = RunnableLambda(get_retriever_with_metadata)
|
||||
|
||||
_inputs = RunnableMap(
|
||||
_inputs = RunnableParallel(
|
||||
{
|
||||
"question": lambda x: x["question"],
|
||||
"chat_history": lambda x: _format_chat_history(x["chat_history"]),
|
||||
|
Reference in New Issue
Block a user