|
|
@ -28,6 +28,7 @@ def create_qa_with_structure_chain(
|
|
|
|
schema: Union[dict, Type[BaseModel]],
|
|
|
|
schema: Union[dict, Type[BaseModel]],
|
|
|
|
output_parser: str = "base",
|
|
|
|
output_parser: str = "base",
|
|
|
|
prompt: Optional[Union[PromptTemplate, ChatPromptTemplate]] = None,
|
|
|
|
prompt: Optional[Union[PromptTemplate, ChatPromptTemplate]] = None,
|
|
|
|
|
|
|
|
verbose: bool = False,
|
|
|
|
) -> LLMChain:
|
|
|
|
) -> LLMChain:
|
|
|
|
"""Create a question answering chain that returns an answer with sources
|
|
|
|
"""Create a question answering chain that returns an answer with sources
|
|
|
|
based on schema.
|
|
|
|
based on schema.
|
|
|
@ -87,18 +88,24 @@ def create_qa_with_structure_chain(
|
|
|
|
prompt=prompt,
|
|
|
|
prompt=prompt,
|
|
|
|
llm_kwargs=llm_kwargs,
|
|
|
|
llm_kwargs=llm_kwargs,
|
|
|
|
output_parser=_output_parser,
|
|
|
|
output_parser=_output_parser,
|
|
|
|
|
|
|
|
verbose=verbose,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return chain
|
|
|
|
return chain
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_qa_with_sources_chain(llm: BaseLanguageModel, **kwargs: Any) -> LLMChain:
|
|
|
|
def create_qa_with_sources_chain(
|
|
|
|
|
|
|
|
llm: BaseLanguageModel, verbose: bool = False, **kwargs: Any
|
|
|
|
|
|
|
|
) -> LLMChain:
|
|
|
|
"""Create a question answering chain that returns an answer with sources.
|
|
|
|
"""Create a question answering chain that returns an answer with sources.
|
|
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
Args:
|
|
|
|
llm: Language model to use for the chain.
|
|
|
|
llm: Language model to use for the chain.
|
|
|
|
|
|
|
|
verbose: Whether to print the details of the chain
|
|
|
|
**kwargs: Keyword arguments to pass to `create_qa_with_structure_chain`.
|
|
|
|
**kwargs: Keyword arguments to pass to `create_qa_with_structure_chain`.
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Returns:
|
|
|
|
Chain (LLMChain) that can be used to answer questions with citations.
|
|
|
|
Chain (LLMChain) that can be used to answer questions with citations.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return create_qa_with_structure_chain(llm, AnswerWithSources, **kwargs)
|
|
|
|
return create_qa_with_structure_chain(
|
|
|
|
|
|
|
|
llm, AnswerWithSources, verbose=verbose, **kwargs
|
|
|
|
|
|
|
|
)
|
|
|
|