id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
867dcf7f7e10-5
raise ValueError(f"search_type of {self.search_type} not allowed.") return docs async def _aget_docs(self, question: str) -> List[Document]: raise NotImplementedError("VectorDBQA does not support async") @property def _chain_type(self) -> str: """Return the chain type.""" ret...
https://python.langchain.com/en/latest/_modules/langchain/chains/retrieval_qa/base.html
f9ef63b30405-0
Source code for langchain.chains.pal.base """Implements Program-Aided Language Models. As in https://arxiv.org/pdf/2211.10435.pdf. """ from __future__ import annotations import warnings from typing import Any, Dict, List, Optional from pydantic import Extra, root_validator from langchain.base_language import BaseLangua...
https://python.langchain.com/en/latest/_modules/langchain/chains/pal/base.html
f9ef63b30405-1
"Directly instantiating an PALChain with an llm is deprecated. " "Please instantiate with llm_chain argument or using the one of " "the class method constructors from_math_prompt, " "from_colored_object_prompt." ) if "llm_chain" not in values and v...
https://python.langchain.com/en/latest/_modules/langchain/chains/pal/base.html
f9ef63b30405-2
output["intermediate_steps"] = code return output [docs] @classmethod def from_math_prompt(cls, llm: BaseLanguageModel, **kwargs: Any) -> PALChain: """Load PAL from math prompt.""" llm_chain = LLMChain(llm=llm, prompt=MATH_PROMPT) return cls( llm_chain=llm_chain, ...
https://python.langchain.com/en/latest/_modules/langchain/chains/pal/base.html
718f2b9b8b15-0
Source code for langchain.chains.qa_with_sources.retrieval """Question-answering with sources over an index.""" from typing import Any, Dict, List from pydantic import Field from langchain.chains.combine_documents.stuff import StuffDocumentsChain from langchain.chains.qa_with_sources.base import BaseQAWithSourcesChain ...
https://python.langchain.com/en/latest/_modules/langchain/chains/qa_with_sources/retrieval.html
718f2b9b8b15-1
docs = self.retriever.get_relevant_documents(question) return self._reduce_tokens_below_limit(docs) async def _aget_docs(self, inputs: Dict[str, Any]) -> List[Document]: question = inputs[self.question_key] docs = await self.retriever.aget_relevant_documents(question) return self._re...
https://python.langchain.com/en/latest/_modules/langchain/chains/qa_with_sources/retrieval.html
9c6693f6ae4c-0
Source code for langchain.chains.qa_with_sources.base """Question answering with sources over documents.""" from __future__ import annotations import re from abc import ABC, abstractmethod from typing import Any, Dict, List, Optional from pydantic import Extra, root_validator from langchain.base_language import BaseLan...
https://python.langchain.com/en/latest/_modules/langchain/chains/qa_with_sources/base.html
9c6693f6ae4c-1
document_prompt: BasePromptTemplate = EXAMPLE_PROMPT, question_prompt: BasePromptTemplate = QUESTION_PROMPT, combine_prompt: BasePromptTemplate = COMBINE_PROMPT, **kwargs: Any, ) -> BaseQAWithSourcesChain: """Construct the chain from an LLM.""" llm_question_chain = LLMChain(l...
https://python.langchain.com/en/latest/_modules/langchain/chains/qa_with_sources/base.html
9c6693f6ae4c-2
def input_keys(self) -> List[str]: """Expect input key. :meta private: """ return [self.question_key] @property def output_keys(self) -> List[str]: """Return output key. :meta private: """ _output_keys = [self.answer_key, self.sources_answer_key] ...
https://python.langchain.com/en/latest/_modules/langchain/chains/qa_with_sources/base.html
9c6693f6ae4c-3
if self.return_source_documents: result["source_documents"] = docs return result @abstractmethod async def _aget_docs(self, inputs: Dict[str, Any]) -> List[Document]: """Get docs to run questioning over.""" async def _acall( self, inputs: Dict[str, Any], r...
https://python.langchain.com/en/latest/_modules/langchain/chains/qa_with_sources/base.html
9c6693f6ae4c-4
return inputs.pop(self.input_docs_key) @property def _chain_type(self) -> str: return "qa_with_sources_chain" By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 25, 2023.
https://python.langchain.com/en/latest/_modules/langchain/chains/qa_with_sources/base.html
0e1e3db7bc97-0
Source code for langchain.chains.qa_with_sources.vector_db """Question-answering with sources over a vector database.""" import warnings from typing import Any, Dict, List from pydantic import Field, root_validator from langchain.chains.combine_documents.stuff import StuffDocumentsChain from langchain.chains.qa_with_so...
https://python.langchain.com/en/latest/_modules/langchain/chains/qa_with_sources/vector_db.html
0e1e3db7bc97-1
num_docs -= 1 token_count -= tokens[num_docs] return docs[:num_docs] def _get_docs(self, inputs: Dict[str, Any]) -> List[Document]: question = inputs[self.question_key] docs = self.vectorstore.similarity_search( question, k=self.k, **self.search_kwargs ) ...
https://python.langchain.com/en/latest/_modules/langchain/chains/qa_with_sources/vector_db.html
aa7e7a67a60a-0
Source code for langchain.chains.graph_qa.base """Question answering over a graph.""" from __future__ import annotations from typing import Any, Dict, List, Optional from pydantic import Field from langchain.base_language import BaseLanguageModel from langchain.callbacks.manager import CallbackManagerForChainRun from l...
https://python.langchain.com/en/latest/_modules/langchain/chains/graph_qa/base.html
aa7e7a67a60a-1
) -> GraphQAChain: """Initialize from LLM.""" qa_chain = LLMChain(llm=llm, prompt=qa_prompt) entity_chain = LLMChain(llm=llm, prompt=entity_prompt) return cls( qa_chain=qa_chain, entity_extraction_chain=entity_chain, **kwargs, ) def _call( ...
https://python.langchain.com/en/latest/_modules/langchain/chains/graph_qa/base.html
e6702995ffe2-0
Source code for langchain.chains.graph_qa.cypher """Question answering over a graph.""" from __future__ import annotations from typing import Any, Dict, List, Optional from pydantic import Field from langchain.base_language import BaseLanguageModel from langchain.callbacks.manager import CallbackManagerForChainRun from...
https://python.langchain.com/en/latest/_modules/langchain/chains/graph_qa/cypher.html
e6702995ffe2-1
**kwargs: Any, ) -> GraphCypherQAChain: """Initialize from LLM.""" qa_chain = LLMChain(llm=llm, prompt=qa_prompt) cypher_generation_chain = LLMChain(llm=llm, prompt=cypher_prompt) return cls( qa_chain=qa_chain, cypher_generation_chain=cypher_generation_chain, ...
https://python.langchain.com/en/latest/_modules/langchain/chains/graph_qa/cypher.html
e6702995ffe2-2
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 25, 2023.
https://python.langchain.com/en/latest/_modules/langchain/chains/graph_qa/cypher.html
85ac734147f3-0
Source code for langchain.chains.qa_generation.base from __future__ import annotations import json from typing import Any, Dict, List, Optional from pydantic import Field from langchain.base_language import BaseLanguageModel from langchain.callbacks.manager import CallbackManagerForChainRun from langchain.chains.base i...
https://python.langchain.com/en/latest/_modules/langchain/chains/qa_generation/base.html
85ac734147f3-1
def _call( self, inputs: Dict[str, Any], run_manager: Optional[CallbackManagerForChainRun] = None, ) -> Dict[str, List]: docs = self.text_splitter.create_documents([inputs[self.input_key]]) results = self.llm_chain.generate( [{"text": d.page_content} for d in docs...
https://python.langchain.com/en/latest/_modules/langchain/chains/qa_generation/base.html
fe17f6e40610-0
Source code for langchain.chains.constitutional_ai.base """Chain for applying constitutional principles to the outputs of another chain.""" from typing import Any, Dict, List, Optional from langchain.base_language import BaseLanguageModel from langchain.callbacks.manager import CallbackManagerForChainRun from langchain...
https://python.langchain.com/en/latest/_modules/langchain/chains/constitutional_ai/base.html
fe17f6e40610-1
critique_chain: LLMChain revision_chain: LLMChain return_intermediate_steps: bool = False [docs] @classmethod def get_principles( cls, names: Optional[List[str]] = None ) -> List[ConstitutionalPrinciple]: if names is None: return list(PRINCIPLES.values()) else: ...
https://python.langchain.com/en/latest/_modules/langchain/chains/constitutional_ai/base.html
fe17f6e40610-2
) -> Dict[str, Any]: _run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager() response = self.chain.run( **inputs, callbacks=_run_manager.get_child(), ) initial_response = response input_prompt = self.chain.prompt.format(**inputs) ...
https://python.langchain.com/en/latest/_modules/langchain/chains/constitutional_ai/base.html
fe17f6e40610-3
critiques_and_revisions.append((critique, revision)) _run_manager.on_text( text=f"Applying {constitutional_principle.name}..." + "\n\n", verbose=self.verbose, color="green", ) _run_manager.on_text( text="Critique: " + cr...
https://python.langchain.com/en/latest/_modules/langchain/chains/constitutional_ai/base.html
3d94d69ee5ec-0
Source code for langchain.chains.api.base """Chain that makes API calls and summarizes the responses to answer a question.""" from __future__ import annotations from typing import Any, Dict, List, Optional from pydantic import Field, root_validator from langchain.base_language import BaseLanguageModel from langchain.ca...
https://python.langchain.com/en/latest/_modules/langchain/chains/api/base.html
3d94d69ee5ec-1
if set(input_vars) != expected_vars: raise ValueError( f"Input variables should be {expected_vars}, got {input_vars}" ) return values @root_validator(pre=True) def validate_api_answer_prompt(cls, values: Dict) -> Dict: """Check that api answer prompt expec...
https://python.langchain.com/en/latest/_modules/langchain/chains/api/base.html
3d94d69ee5ec-2
async def _acall( self, inputs: Dict[str, Any], run_manager: Optional[AsyncCallbackManagerForChainRun] = None, ) -> Dict[str, str]: _run_manager = run_manager or AsyncCallbackManagerForChainRun.get_noop_manager() question = inputs[self.question_key] api_url = await se...
https://python.langchain.com/en/latest/_modules/langchain/chains/api/base.html
3d94d69ee5ec-3
requests_wrapper = TextRequestsWrapper(headers=headers) get_answer_chain = LLMChain(llm=llm, prompt=api_response_prompt) return cls( api_request_chain=get_request_chain, api_answer_chain=get_answer_chain, requests_wrapper=requests_wrapper, api_docs=api_doc...
https://python.langchain.com/en/latest/_modules/langchain/chains/api/base.html
ffaf05c3f472-0
Source code for langchain.chains.api.openapi.chain """Chain that makes API calls and summarizes the responses to answer a question.""" from __future__ import annotations import json from typing import Any, Dict, List, NamedTuple, Optional, cast from pydantic import BaseModel, Field from requests import Response from la...
https://python.langchain.com/en/latest/_modules/langchain/chains/api/openapi/chain.html
ffaf05c3f472-1
:meta private: """ return [self.instructions_key] @property def output_keys(self) -> List[str]: """Expect output key. :meta private: """ if not self.return_intermediate_steps: return [self.output_key] else: return [self.output_key, ...
https://python.langchain.com/en/latest/_modules/langchain/chains/api/openapi/chain.html
ffaf05c3f472-2
path = self._construct_path(args) body_params = self._extract_body_params(args) query_params = self._extract_query_params(args) return { "url": path, "data": body_params, "params": query_params, } def _get_output(self, output: str, intermediate_ste...
https://python.langchain.com/en/latest/_modules/langchain/chains/api/openapi/chain.html
ffaf05c3f472-3
method = getattr(self.requests, self.api_operation.method.value) api_response: Response = method(**request_args) if api_response.status_code != 200: method_str = str(self.api_operation.method.value) response_text = ( f"{api_response.status_code...
https://python.langchain.com/en/latest/_modules/langchain/chains/api/openapi/chain.html
ffaf05c3f472-4
# TODO: Handle async ) -> "OpenAPIEndpointChain": """Create an OpenAPIEndpoint from a spec at the specified url.""" operation = APIOperation.from_openapi_url(spec_url, path, method) return cls.from_api_operation( operation, requests=requests, llm=llm, ...
https://python.langchain.com/en/latest/_modules/langchain/chains/api/openapi/chain.html
ffaf05c3f472-5
api_operation=operation, requests=_requests, param_mapping=param_mapping, verbose=verbose, return_intermediate_steps=return_intermediate_steps, callbacks=callbacks, **kwargs, ) By Harrison Chase © Copyright 2023, Harrison Chase. ...
https://python.langchain.com/en/latest/_modules/langchain/chains/api/openapi/chain.html
12cab81bc9cb-0
Source code for langchain.chains.llm_checker.base """Chain for question-answering with self-verification.""" from __future__ import annotations import warnings from typing import Any, Dict, List, Optional from pydantic import Extra, root_validator from langchain.base_language import BaseLanguageModel from langchain.cal...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_checker/base.html
12cab81bc9cb-1
) chains = [ create_draft_answer_chain, list_assertions_chain, check_assertions_chain, revised_answer_chain, ] question_to_checked_assertions_chain = SequentialChain( chains=chains, input_variables=["question"], output_variables=["revised_statement"], ...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_checker/base.html
12cab81bc9cb-2
if "llm" in values: warnings.warn( "Directly instantiating an LLMCheckerChain with an llm is deprecated. " "Please instantiate with question_to_checked_assertions_chain " "or using the from_llm class method." ) if ( "que...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_checker/base.html
12cab81bc9cb-3
question = inputs[self.input_key] output = self.question_to_checked_assertions_chain( {"question": question}, callbacks=_run_manager.get_child() ) return {self.output_key: output["revised_statement"]} @property def _chain_type(self) -> str: return "llm_checker_chain" ...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_checker/base.html
a1ea72fdc235-0
Source code for langchain.chains.llm_bash.base """Chain that interprets a prompt and executes bash code to perform bash operations.""" from __future__ import annotations import logging import warnings from typing import Any, Dict, List, Optional from pydantic import Extra, Field, root_validator from langchain.base_lang...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_bash/base.html
a1ea72fdc235-1
def raise_deprecation(cls, values: Dict) -> Dict: if "llm" in values: warnings.warn( "Directly instantiating an LLMBashChain with an llm is deprecated. " "Please instantiate with llm_chain or using the from_llm class method." ) if "llm_chain" n...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_bash/base.html
a1ea72fdc235-2
) _run_manager.on_text(t, color="green", verbose=self.verbose) t = t.strip() try: parser = self.llm_chain.prompt.output_parser command_list = parser.parse(t) # type: ignore[union-attr] except OutputParserException as e: _run_manager.on_chain_error(e, ...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_bash/base.html
7ae9d4b20a94-0
Source code for langchain.chains.llm_math.base """Chain that interprets a prompt and executes python code to do math.""" from __future__ import annotations import math import re import warnings from typing import Any, Dict, List, Optional import numexpr from pydantic import Extra, root_validator from langchain.base_lan...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_math/base.html
7ae9d4b20a94-1
if "llm" in values: warnings.warn( "Directly instantiating an LLMMathChain with an llm is deprecated. " "Please instantiate with llm_chain argument or using the from_llm " "class method." ) if "llm_chain" not in values and values["llm"]...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_math/base.html
7ae9d4b20a94-2
) -> Dict[str, str]: run_manager.on_text(llm_output, color="green", verbose=self.verbose) llm_output = llm_output.strip() text_match = re.search(r"^```text(.*?)```", llm_output, re.DOTALL) if text_match: expression = text_match.group(1) output = self._evaluate_exp...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_math/base.html
7ae9d4b20a94-3
elif llm_output.startswith("Answer:"): answer = llm_output elif "Answer:" in llm_output: answer = "Answer: " + llm_output.split("Answer:")[-1] else: raise ValueError(f"unknown format from LLM: {llm_output}") return {self.output_key: answer} def _call( ...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_math/base.html
7ae9d4b20a94-4
[docs] @classmethod def from_llm( cls, llm: BaseLanguageModel, prompt: BasePromptTemplate = PROMPT, **kwargs: Any, ) -> LLMMathChain: llm_chain = LLMChain(llm=llm, prompt=prompt) return cls(llm_chain=llm_chain, **kwargs) By Harrison Chase © Copyright...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_math/base.html
8ba0164e295a-0
Source code for langchain.chains.combine_documents.base """Base interface for chains combining documents.""" from abc import ABC, abstractmethod from typing import Any, Dict, List, Optional, Tuple from pydantic import Field from langchain.callbacks.manager import ( AsyncCallbackManagerForChainRun, CallbackManag...
https://python.langchain.com/en/latest/_modules/langchain/chains/combine_documents/base.html
8ba0164e295a-1
:meta private: """ return [self.input_key] @property def output_keys(self) -> List[str]: """Return output key. :meta private: """ return [self.output_key] def prompt_length(self, docs: List[Document], **kwargs: Any) -> Optional[int]: """Return the prom...
https://python.langchain.com/en/latest/_modules/langchain/chains/combine_documents/base.html
8ba0164e295a-2
run_manager: Optional[AsyncCallbackManagerForChainRun] = None, ) -> Dict[str, str]: _run_manager = run_manager or AsyncCallbackManagerForChainRun.get_noop_manager() docs = inputs[self.input_key] # Other keys are assumed to be needed for LLM prediction other_keys = {k: v for k, v in i...
https://python.langchain.com/en/latest/_modules/langchain/chains/combine_documents/base.html
8ba0164e295a-3
# Other keys are assumed to be needed for LLM prediction other_keys: Dict = {k: v for k, v in inputs.items() if k != self.input_key} other_keys[self.combine_docs_chain.input_key] = docs return self.combine_docs_chain( other_keys, return_only_outputs=True, callbacks=_run_manager.get_c...
https://python.langchain.com/en/latest/_modules/langchain/chains/combine_documents/base.html
26e97e52b241-0
Source code for langchain.chains.conversational_retrieval.base """Chain for chatting with a vector database.""" from __future__ import annotations import warnings from abc import abstractmethod from pathlib import Path from typing import Any, Callable, Dict, List, Optional, Tuple, Union from pydantic import Extra, Fiel...
https://python.langchain.com/en/latest/_modules/langchain/chains/conversational_retrieval/base.html
26e97e52b241-1
human = "Human: " + dialogue_turn[0] ai = "Assistant: " + dialogue_turn[1] buffer += "\n" + "\n".join([human, ai]) else: raise ValueError( f"Unsupported chat history format: {type(dialogue_turn)}." f" Full chat history: {chat_history} " ...
https://python.langchain.com/en/latest/_modules/langchain/chains/conversational_retrieval/base.html
26e97e52b241-2
) -> Dict[str, Any]: _run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager() question = inputs["question"] get_chat_history = self.get_chat_history or _get_chat_history chat_history_str = get_chat_history(inputs["chat_history"]) if chat_history_str: ...
https://python.langchain.com/en/latest/_modules/langchain/chains/conversational_retrieval/base.html
26e97e52b241-3
new_question = await self.question_generator.arun( question=question, chat_history=chat_history_str, callbacks=callbacks ) else: new_question = question docs = await self._aget_docs(new_question, inputs) new_inputs = inputs.copy() new_inputs["quest...
https://python.langchain.com/en/latest/_modules/langchain/chains/conversational_retrieval/base.html
26e97e52b241-4
while token_count > self.max_tokens_limit: num_docs -= 1 token_count -= tokens[num_docs] return docs[:num_docs] def _get_docs(self, question: str, inputs: Dict[str, Any]) -> List[Document]: docs = self.retriever.get_relevant_documents(question) return self._re...
https://python.langchain.com/en/latest/_modules/langchain/chains/conversational_retrieval/base.html
26e97e52b241-5
) [docs]class ChatVectorDBChain(BaseConversationalRetrievalChain): """Chain for chatting with a vector database.""" vectorstore: VectorStore = Field(alias="vectorstore") top_k_docs_for_context: int = 4 search_kwargs: dict = Field(default_factory=dict) @property def _chain_type(self) -> str: ...
https://python.langchain.com/en/latest/_modules/langchain/chains/conversational_retrieval/base.html
26e97e52b241-6
combine_docs_chain_kwargs = combine_docs_chain_kwargs or {} doc_chain = load_qa_chain( llm, chain_type=chain_type, **combine_docs_chain_kwargs, ) condense_question_chain = LLMChain(llm=llm, prompt=condense_question_prompt) return cls( vecto...
https://python.langchain.com/en/latest/_modules/langchain/chains/conversational_retrieval/base.html
42d4c9824f8c-0
Source code for langchain.chains.llm_summarization_checker.base """Chain for summarization with self-verification.""" from __future__ import annotations import warnings from pathlib import Path from typing import Any, Dict, List, Optional from pydantic import Extra, root_validator from langchain.base_language import Ba...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_summarization_checker/base.html
42d4c9824f8c-1
verbose=verbose, ), LLMChain( llm=llm, prompt=check_assertions_prompt, output_key="checked_assertions", verbose=verbose, ), LLMChain( llm=llm, prompt=revised_summary_prompt, ...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_summarization_checker/base.html
42d4c9824f8c-2
input_key: str = "query" #: :meta private: output_key: str = "result" #: :meta private: max_checks: int = 2 """Maximum number of times to check the assertions. Default to double-checking.""" class Config: """Configuration for this pydantic object.""" extra = Extra.forbid arbitr...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_summarization_checker/base.html
42d4c9824f8c-3
def _call( self, inputs: Dict[str, Any], run_manager: Optional[CallbackManagerForChainRun] = None, ) -> Dict[str, str]: _run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager() all_true = False count = 0 output = None original_input ...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_summarization_checker/base.html
42d4c9824f8c-4
create_assertions_prompt, check_assertions_prompt, revised_summary_prompt, are_all_true_prompt, verbose=verbose, ) return cls(sequential_chain=chain, verbose=verbose, **kwargs) By Harrison Chase © Copyright 2023, Harrison Chase. Last up...
https://python.langchain.com/en/latest/_modules/langchain/chains/llm_summarization_checker/base.html
3d4b4ac636f1-0
Source code for langchain.chains.flare.base from __future__ import annotations import re from abc import abstractmethod from typing import Any, Dict, List, Optional, Sequence, Tuple import numpy as np from pydantic import Field from langchain.base_language import BaseLanguageModel from langchain.callbacks.manager impor...
https://python.langchain.com/en/latest/_modules/langchain/chains/flare/base.html
3d4b4ac636f1-1
) ) def _extract_tokens_and_log_probs( self, generations: List[Generation] ) -> Tuple[Sequence[str], Sequence[float]]: tokens = [] log_probs = [] for gen in generations: if gen.generation_info is None: raise ValueError tokens.extend(gen...
https://python.langchain.com/en/latest/_modules/langchain/chains/flare/base.html
3d4b4ac636f1-2
[docs]class FlareChain(Chain): question_generator_chain: QuestionGeneratorChain response_chain: _ResponseChain = Field(default_factory=_OpenAIResponseChain) output_parser: FinishedOutputParser = Field(default_factory=FinishedOutputParser) retriever: BaseRetriever min_prob: float = 0.2 min_token_...
https://python.langchain.com/en/latest/_modules/langchain/chains/flare/base.html
3d4b4ac636f1-3
question_gen_inputs = [ { "user_input": user_input, "current_response": initial_response, "uncertain_span": span, } for span in low_confidence_spans ] callbacks = _run_manager.get_child() question_gen_outputs = s...
https://python.langchain.com/en/latest/_modules/langchain/chains/flare/base.html
3d4b4ac636f1-4
) initial_response = response.strip() + " " + "".join(tokens) if not low_confidence_spans: response = initial_response final_response, finished = self.output_parser.parse(response) if finished: return {self.output_keys[0]: final...
https://python.langchain.com/en/latest/_modules/langchain/chains/flare/base.html
39b5fd17d81f-0
Source code for langchain.chains.conversation.base """Chain that carries on a conversation and calls an LLM.""" from typing import Dict, List from pydantic import Extra, Field, root_validator from langchain.chains.conversation.prompt import PROMPT from langchain.chains.llm import LLMChain from langchain.memory.buffer i...
https://python.langchain.com/en/latest/_modules/langchain/chains/conversation/base.html
39b5fd17d81f-1
f"The input key {input_key} was also found in the memory keys " f"({memory_keys}) - please provide keys that don't overlap." ) prompt_variables = values["prompt"].input_variables expected_keys = memory_keys + [input_key] if set(expected_keys) != set(prompt_variables):...
https://python.langchain.com/en/latest/_modules/langchain/chains/conversation/base.html
a0e21e89c442-0
.ipynb .pdf Model Comparison Model Comparison# Constructing your language model application will likely involved choosing between many different options of prompts, models, and even chains to use. When doing so, you will want to compare these different options on different inputs in an easy, flexible, and intuitive way...
https://python.langchain.com/en/latest/additional_resources/model_laboratory.html
a0e21e89c442-1
pink prompt = PromptTemplate(template="What is the capital of {state}?", input_variables=["state"]) model_lab_with_prompt = ModelLaboratory.from_llms(llms, prompt=prompt) model_lab_with_prompt.compare("New York") Input: New York OpenAI Params: {'model': 'text-davinci-002', 'temperature': 0.0, 'max_tokens': 256, 'top_p'...
https://python.langchain.com/en/latest/additional_resources/model_laboratory.html
a0e21e89c442-2
names = [str(open_ai_llm), str(cohere_llm)] model_lab = ModelLaboratory(chains, names=names) model_lab.compare("What is the hometown of the reigning men's U.S. Open champion?") Input: What is the hometown of the reigning men's U.S. Open champion? OpenAI Params: {'model': 'text-davinci-002', 'temperature': 0.0, 'max_tok...
https://python.langchain.com/en/latest/additional_resources/model_laboratory.html
a0e21e89c442-3
So the final answer is: Carlos Alcaraz previous Tracing next YouTube By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 25, 2023.
https://python.langchain.com/en/latest/additional_resources/model_laboratory.html
e43e101f3bce-0
.md .pdf Tracing Contents Tracing Walkthrough Changing Sessions Tracing# By enabling tracing in your LangChain runs, you’ll be able to more effectively visualize, step through, and debug your chains and agents. First, you should install tracing and set up your environment properly. You can use either a locally hosted...
https://python.langchain.com/en/latest/additional_resources/tracing.html
e43e101f3bce-1
Changing Sessions# To initially record traces to a session other than "default", you can set the LANGCHAIN_SESSION environment variable to the name of the session you want to record to: import os os.environ["LANGCHAIN_TRACING"] = "true" os.environ["LANGCHAIN_SESSION"] = "my_session" # Make sure this session actually ex...
https://python.langchain.com/en/latest/additional_resources/tracing.html
6b16ee3b662e-0
.md .pdf YouTube Contents ⛓️Official LangChain YouTube channel⛓️ Introduction to LangChain with Harrison Chase, creator of LangChain Videos (sorted by views) YouTube# This is a collection of LangChain videos on YouTube. ⛓️Official LangChain YouTube channel⛓️# Introduction to LangChain with Harrison Chase, creator of ...
https://python.langchain.com/en/latest/additional_resources/youtube.html
6b16ee3b662e-1
Run BabyAGI with Langchain Agents (with Python Code) by 1littlecoder How to Use Langchain With Zapier | Write and Send Email with GPT-3 | OpenAI API Tutorial by StarMorph AI Use Your Locally Stored Files To Get Response From GPT - OpenAI | Langchain | Python by Shweta Lodha Langchain JS | How to Use GPT-3, GPT-4 to Ref...
https://python.langchain.com/en/latest/additional_resources/youtube.html
6b16ee3b662e-2
LangChain. Crear aplicaciones Python impulsadas por GPT by Jesús Conde Easiest Way to Use GPT In Your Products | LangChain Basics Tutorial by Rachel Woods BabyAGI + GPT-4 Langchain Agent with Internet Access by tylerwhatsgood Learning LLM Agents. How does it actually work? LangChain, AutoGPT & OpenAI by Arnoldas Kemekl...
https://python.langchain.com/en/latest/additional_resources/youtube.html
6b16ee3b662e-3
⛓️ QA over documents with Auto vector index selection with Langchain router chains by echohive ⛓️ Build your own custom LLM application with Bubble.io & Langchain (No Code & Beginner friendly) by No Code Blackbox ⛓️ Simple App to Question Your Docs: Leveraging Streamlit, Hugging Face Spaces, LangChain, and Claude! by C...
https://python.langchain.com/en/latest/additional_resources/youtube.html
6b16ee3b662e-4
⛓️ LangChain In Action: Real-World Use Case With Step-by-Step Tutorial by Rabbitmetrics ⛓️ Summarizing and Querying Multiple Papers with LangChain by Automata Learning Lab ⛓️ Using Langchain (and Replit) through Tana, ask Google/Wikipedia/Wolfram Alpha to fill out a table by Stian Håklev ⛓️ Langchain PDF App (GUI) | Cr...
https://python.langchain.com/en/latest/additional_resources/youtube.html
6b16ee3b662e-5
Model Comparison Contents ⛓️Official LangChain YouTube channel⛓️ Introduction to LangChain with Harrison Chase, creator of LangChain Videos (sorted by views) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 25, 2023.
https://python.langchain.com/en/latest/additional_resources/youtube.html
52c42fdb9e7f-0
.ipynb .pdf WhyLabs Integration WhyLabs Integration# Enable observability to detect inputs and LLM issues faster, deliver continuous improvements, and avoid costly incidents. %pip install langkit -q Make sure to set the required API keys and config required to send telemetry to WhyLabs: WhyLabs API Key: https://whylabs...
https://python.langchain.com/en/latest/integrations/whylabs_profiling.html
52c42fdb9e7f-1
result = llm.generate(["Hello, World!"]) print(result) generations=[[Generation(text="\n\nMy name is John and I'm excited to learn more about programming.", generation_info={'finish_reason': 'stop', 'logprobs': None})]] llm_output={'token_usage': {'total_tokens': 20, 'prompt_tokens': 4, 'completion_tokens': 16}, 'model...
https://python.langchain.com/en/latest/integrations/whylabs_profiling.html
52c42fdb9e7f-2
whylabs.close() previous Weaviate next Wolfram Alpha Wrapper By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 25, 2023.
https://python.langchain.com/en/latest/integrations/whylabs_profiling.html
cb9b92ac4261-0
.ipynb .pdf Databricks Contents Installation and Setup Connecting to Databricks Syntax Required Parameters Optional Parameters Examples SQL Chain example SQL Database Agent example Databricks# This notebook covers how to connect to the Databricks runtimes and Databricks SQL using the SQLDatabase wrapper of LangChain....
https://python.langchain.com/en/latest/integrations/databricks.html
cb9b92ac4261-1
warehouse_id: The warehouse ID in the Databricks SQL. cluster_id: The cluster ID in the Databricks Runtime. If running in a Databricks notebook and both ‘warehouse_id’ and ‘cluster_id’ are None, it uses the ID of the cluster the notebook is attached to. engine_args: The arguments to be used when connecting Databricks. ...
https://python.langchain.com/en/latest/integrations/databricks.html
cb9b92ac4261-2
SQL Database Agent example# This example demonstrates the use of the SQL Database Agent for answering questions over a Databricks database. from langchain.agents import create_sql_agent from langchain.agents.agent_toolkits import SQLDatabaseToolkit toolkit = SQLDatabaseToolkit(db=db, llm=llm) agent = create_sql_agent( ...
https://python.langchain.com/en/latest/integrations/databricks.html
cb9b92ac4261-3
2016-02-17 17:13:57+00:00 2016-02-17 17:17:55+00:00 0.7 5.0 10103 10023 */ Thought:The trips table has the necessary columns for trip distance and duration. I will write a query to find the longest trip distance and its duration. Action: query_checker_sql_db Action Input: SELECT trip_distance, tpep_dropoff_datetime - t...
https://python.langchain.com/en/latest/integrations/databricks.html
3d376c99e7d5-0
.md .pdf AtlasDB Contents Installation and Setup Wrappers VectorStore AtlasDB# This page covers how to use Nomic’s Atlas ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific Atlas wrappers. Installation and Setup# Install the Python package with pip install ...
https://python.langchain.com/en/latest/integrations/atlas.html
7ad46bccf0c0-0
.md .pdf PGVector Contents Installation Setup Wrappers VectorStore Usage PGVector# This page covers how to use the Postgres PGVector ecosystem within LangChain It is broken into two parts: installation and setup, and then references to specific PGVector wrappers. Installation# Install the Python package with pip inst...
https://python.langchain.com/en/latest/integrations/pgvector.html
6148ff069fca-0
.md .pdf Apify Contents Overview Installation and Setup Wrappers Utility Loader Apify# This page covers how to use Apify within LangChain. Overview# Apify is a cloud platform for web scraping and data extraction, which provides an ecosystem of more than a thousand ready-made apps called Actors for various scraping, c...
https://python.langchain.com/en/latest/integrations/apify.html
21db1adc0854-0
.md .pdf Vectara Contents Installation and Setup VectorStore Vectara# What is Vectara? Vectara Overview: Vectara is developer-first API platform for building conversational search applications To use Vectara - first sign up and create an account. Then create a corpus and an API key for indexing and searching. You can...
https://python.langchain.com/en/latest/integrations/vectara.html
21db1adc0854-1
Contents Installation and Setup VectorStore By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 25, 2023.
https://python.langchain.com/en/latest/integrations/vectara.html
e7eb8090d41d-0
.md .pdf Zilliz Contents Installation and Setup Wrappers VectorStore Zilliz# This page covers how to use the Zilliz Cloud ecosystem within LangChain. Zilliz uses the Milvus integration. It is broken into two parts: installation and setup, and then references to specific Milvus wrappers. Installation and Setup# Instal...
https://python.langchain.com/en/latest/integrations/zilliz.html
96fa8f3c57c5-0
.md .pdf LanceDB Contents Installation and Setup Wrappers VectorStore LanceDB# This page covers how to use LanceDB within LangChain. It is broken into two parts: installation and setup, and then references to specific LanceDB wrappers. Installation and Setup# Install the Python SDK with pip install lancedb Wrappers# ...
https://python.langchain.com/en/latest/integrations/lancedb.html
2861aecfe3fe-0
.md .pdf Redis Contents Installation and Setup Wrappers Cache Standard Cache Semantic Cache VectorStore Retriever Memory Vector Store Retriever Memory Chat Message History Memory Redis# This page covers how to use the Redis ecosystem within LangChain. It is broken into two parts: installation and setup, and then refe...
https://python.langchain.com/en/latest/integrations/redis.html
2861aecfe3fe-1
To import this vectorstore: from langchain.vectorstores import Redis For a more detailed walkthrough of the Redis vectorstore wrapper, see this notebook. Retriever# The Redis vector store retriever wrapper generalizes the vectorstore class to perform low-latency document retrieval. To create the retriever, simply call ...
https://python.langchain.com/en/latest/integrations/redis.html
7df7af853cec-0
.md .pdf Google Search Contents Installation and Setup Wrappers Utility Tool Google Search# This page covers how to use the Google Search API within LangChain. It is broken into two parts: installation and setup, and then references to the specific Google Search wrapper. Installation and Setup# Install requirements w...
https://python.langchain.com/en/latest/integrations/google_search.html
923e106bf1a4-0
.md .pdf Qdrant Contents Installation and Setup Wrappers VectorStore Qdrant# This page covers how to use the Qdrant ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific Qdrant wrappers. Installation and Setup# Install the Python SDK with pip install qdrant-c...
https://python.langchain.com/en/latest/integrations/qdrant.html
daf15316c53c-0
.md .pdf PromptLayer Contents Installation and Setup Wrappers LLM PromptLayer# This page covers how to use PromptLayer within LangChain. It is broken into two parts: installation and setup, and then references to specific PromptLayer wrappers. Installation and Setup# If you want to work with PromptLayer: Install the ...
https://python.langchain.com/en/latest/integrations/promptlayer.html