mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-24 07:35:18 +00:00
Add RAG input types (#12684)
Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
parent
392cfbee24
commit
f0eba1ac63
@ -164,9 +164,8 @@ def format_chat_history(chain_input: dict) -> dict:
|
||||
# if you update the name of this, you MUST also update ../pyproject.toml
|
||||
# with the new `tool.langserve.export_attr`
|
||||
chain = (
|
||||
(format_chat_history | _prompt | _model | StrOutputParser()).with_types(
|
||||
input_type=ChainInput
|
||||
)
|
||||
(format_chat_history | _prompt | _model | StrOutputParser())
|
||||
.with_types(input_type=ChainInput)
|
||||
# This is to add the evaluators as "listeners"
|
||||
# and to customize the name of the chain.
|
||||
# Any chain that accepts a compatible input type works here.
|
||||
|
@ -3,6 +3,7 @@ import os
|
||||
from langchain.embeddings import VertexAIEmbeddings
|
||||
from langchain.llms import VertexAI
|
||||
from langchain.prompts import PromptTemplate
|
||||
from langchain.pydantic_v1 import BaseModel
|
||||
from langchain.schema.output_parser import StrOutputParser
|
||||
from langchain.schema.runnable import RunnableParallel, RunnablePassthrough
|
||||
from langchain.vectorstores import MatchingEngine
|
||||
@ -67,3 +68,11 @@ chain = (
|
||||
| model
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
|
||||
# Add typing for input
|
||||
class Question(BaseModel):
|
||||
__root__: str
|
||||
|
||||
|
||||
chain = chain.with_types(input_type=Question)
|
||||
|
@ -3,6 +3,7 @@ import os
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from langchain.embeddings import OpenAIEmbeddings
|
||||
from langchain.prompts import ChatPromptTemplate
|
||||
from langchain.pydantic_v1 import BaseModel
|
||||
from langchain.retrievers.multi_query import MultiQueryRetriever
|
||||
from langchain.schema.output_parser import StrOutputParser
|
||||
from langchain.schema.runnable import RunnableParallel, RunnablePassthrough
|
||||
@ -55,3 +56,11 @@ chain = (
|
||||
| model
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
|
||||
# Add typing for input
|
||||
class Question(BaseModel):
|
||||
__root__: str
|
||||
|
||||
|
||||
chain = chain.with_types(input_type=Question)
|
||||
|
@ -3,6 +3,7 @@ import os
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from langchain.embeddings import OpenAIEmbeddings
|
||||
from langchain.prompts import ChatPromptTemplate
|
||||
from langchain.pydantic_v1 import BaseModel
|
||||
from langchain.retrievers import ContextualCompressionRetriever
|
||||
from langchain.retrievers.document_compressors import CohereRerank
|
||||
from langchain.schema.output_parser import StrOutputParser
|
||||
@ -62,3 +63,11 @@ chain = (
|
||||
| model
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
|
||||
# Add typing for input
|
||||
class Question(BaseModel):
|
||||
__root__: str
|
||||
|
||||
|
||||
chain = chain.with_types(input_type=Question)
|
||||
|
@ -3,6 +3,7 @@ import os
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from langchain.embeddings import OpenAIEmbeddings
|
||||
from langchain.prompts import ChatPromptTemplate
|
||||
from langchain.pydantic_v1 import BaseModel
|
||||
from langchain.schema.output_parser import StrOutputParser
|
||||
from langchain.schema.runnable import RunnableParallel, RunnablePassthrough
|
||||
from langchain.vectorstores import Pinecone
|
||||
@ -50,3 +51,11 @@ chain = (
|
||||
| model
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
|
||||
# Add typing for input
|
||||
class Question(BaseModel):
|
||||
__root__: str
|
||||
|
||||
|
||||
chain = chain.with_types(input_type=Question)
|
||||
|
@ -4,6 +4,7 @@ import uuid
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from langchain.embeddings import OpenAIEmbeddings
|
||||
from langchain.prompts import ChatPromptTemplate
|
||||
from langchain.pydantic_v1 import BaseModel
|
||||
from langchain.retrievers.multi_vector import MultiVectorRetriever
|
||||
from langchain.schema.document import Document
|
||||
from langchain.schema.output_parser import StrOutputParser
|
||||
@ -109,3 +110,11 @@ chain = (
|
||||
| model
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
|
||||
# Add typing for input
|
||||
class Question(BaseModel):
|
||||
__root__: str
|
||||
|
||||
|
||||
chain = chain.with_types(input_type=Question)
|
||||
|
@ -3,6 +3,7 @@ import os
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from langchain.embeddings import OpenAIEmbeddings
|
||||
from langchain.prompts import ChatPromptTemplate
|
||||
from langchain.pydantic_v1 import BaseModel
|
||||
from langchain.schema.output_parser import StrOutputParser
|
||||
from langchain.schema.runnable import RunnableParallel, RunnablePassthrough
|
||||
from langchain.vectorstores.supabase import SupabaseVectorStore
|
||||
@ -39,3 +40,11 @@ chain = (
|
||||
| model
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
|
||||
# Add typing for input
|
||||
class Question(BaseModel):
|
||||
__root__: str
|
||||
|
||||
|
||||
chain = chain.with_types(input_type=Question)
|
||||
|
@ -4,6 +4,7 @@ from langchain.chat_models import ChatOpenAI
|
||||
from langchain.document_loaders import WebBaseLoader
|
||||
from langchain.embeddings import OpenAIEmbeddings
|
||||
from langchain.prompts import ChatPromptTemplate
|
||||
from langchain.pydantic_v1 import BaseModel
|
||||
from langchain.schema.output_parser import StrOutputParser
|
||||
from langchain.schema.runnable import RunnableParallel, RunnablePassthrough
|
||||
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
||||
@ -50,3 +51,11 @@ chain = (
|
||||
| model
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
|
||||
# Add typing for input
|
||||
class Question(BaseModel):
|
||||
__root__: str
|
||||
|
||||
|
||||
chain = chain.with_types(input_type=Question)
|
||||
|
Loading…
Reference in New Issue
Block a user