id
stringlengths
14
16
text
stringlengths
31
2.73k
source
stringlengths
88
153
aeba3cb74158-0
.rst .pdf Welcome to LangChain Contents Getting Started Modules Use Cases Reference Docs LangChain Ecosystem Additional Resources Welcome to LangChain# LangChain is a framework for developing applications powered by language models. We believe that the most powerful and differentiated applications will not only call out to a language model via an API, but will also: Be data-aware: connect a language model to other sources of data Be agentic: allow a language model to interact with its environment The LangChain framework is designed with the above principles in mind. This is the Python specific portion of the documentation. For a purely conceptual guide to LangChain, see here. For the JavaScript documentation, see here. Getting Started# Checkout the below guide for a walkthrough of how to get started using LangChain to create an Language Model application. Getting Started Documentation Modules# There are several main modules that LangChain provides support for. For each module we provide some examples to get started, how-to guides, reference docs, and conceptual guides. These modules are, in increasing order of complexity: Models: The various model types and model integrations LangChain supports. Prompts: This includes prompt management, prompt optimization, and prompt serialization. Memory: Memory is the concept of persisting state between calls of a chain/agent. LangChain provides a standard interface for memory, a collection of memory implementations, and examples of chains/agents that use memory. Indexes: Language models are often more powerful when combined with your own text data - this module covers best practices for doing exactly that. Chains: Chains go beyond just a single LLM call, and are sequences of calls (whether to an LLM or a different utility). LangChain provides a standard interface for chains, lots of integrations with other tools, and end-to-end chains for common applications.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/index.html
aeba3cb74158-1
Agents: Agents involve an LLM making decisions about which Actions to take, taking that Action, seeing an Observation, and repeating that until done. LangChain provides a standard interface for agents, a selection of agents to choose from, and examples of end to end agents. Use Cases# The above modules can be used in a variety of ways. LangChain also provides guidance and assistance in this. Below are some of the common use cases LangChain supports. Personal Assistants: The main LangChain use case. Personal assistants need to take actions, remember interactions, and have knowledge about your data. Question Answering: The second big LangChain use case. Answering questions over specific documents, only utilizing the information in those documents to construct an answer. Chatbots: Since language models are good at producing text, that makes them ideal for creating chatbots. Querying Tabular Data: If you want to understand how to use LLMs to query data that is stored in a tabular format (csvs, SQL, dataframes, etc) you should read this page. Interacting with APIs: Enabling LLMs to interact with APIs is extremely powerful in order to give them more up-to-date information and allow them to take actions. Extraction: Extract structured information from text. Summarization: Summarizing longer documents into shorter, more condensed chunks of information. A type of Data Augmented Generation. Evaluation: Generative models are notoriously hard to evaluate with traditional metrics. One new way of evaluating them is using language models themselves to do the evaluation. LangChain provides some prompts/chains for assisting in this. Reference Docs# All of LangChain’s reference documentation, in one place. Full documentation on all methods, classes, installation methods, and integration setups for LangChain. Reference Documentation LangChain Ecosystem# Guides for how other companies/products can be used with LangChain LangChain Ecosystem
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/index.html
aeba3cb74158-2
Guides for how other companies/products can be used with LangChain LangChain Ecosystem Additional Resources# Additional collection of resources we think may be useful as you develop your application! LangChainHub: The LangChainHub is a place to share and explore other prompts, chains, and agents. Glossary: A glossary of all related terms, papers, methods, etc. Whether implemented in LangChain or not! Gallery: A collection of our favorite projects that use LangChain. Useful for finding inspiration or seeing how things were done in other applications. Deployments: A collection of instructions, code snippets, and template repositories for deploying LangChain apps. Tracing: A guide on using tracing in LangChain to visualize the execution of chains and agents. Model Laboratory: Experimenting with different prompts, models, and chains is a big part of developing the best possible application. The ModelLaboratory makes it easy to do so. Discord: Join us on our Discord to discuss all things LangChain! Production Support: As you move your LangChains into production, we’d love to offer more comprehensive support. Please fill out this form and we’ll set up a dedicated support Slack channel. next Quickstart Guide Contents Getting Started Modules Use Cases Reference Docs LangChain Ecosystem Additional Resources By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/index.html
1e1ddafb99a3-0
Index _ | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | Z _ __call__() (langchain.llms.AI21 method) (langchain.llms.AlephAlpha method) (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.Banana method) (langchain.llms.CerebriumAI method) (langchain.llms.Cohere method) (langchain.llms.DeepInfra method) (langchain.llms.ForefrontAI method) (langchain.llms.GooseAI method) (langchain.llms.GPT4All method) (langchain.llms.HuggingFaceEndpoint method) (langchain.llms.HuggingFaceHub method) (langchain.llms.HuggingFacePipeline method) (langchain.llms.LlamaCpp method) (langchain.llms.Modal method) (langchain.llms.NLPCloud method) (langchain.llms.OpenAI method) (langchain.llms.OpenAIChat method) (langchain.llms.Petals method) (langchain.llms.PromptLayerOpenAI method) (langchain.llms.PromptLayerOpenAIChat method) (langchain.llms.Replicate method) (langchain.llms.SagemakerEndpoint method) (langchain.llms.SelfHostedHuggingFaceLLM method) (langchain.llms.SelfHostedPipeline method) (langchain.llms.StochasticAI method) (langchain.llms.Writer method) A aapply() (langchain.chains.LLMChain method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-1
A aapply() (langchain.chains.LLMChain method) aapply_and_parse() (langchain.chains.LLMChain method) add() (langchain.docstore.InMemoryDocstore method) add_documents() (langchain.vectorstores.VectorStore method) add_embeddings() (langchain.vectorstores.FAISS method) add_example() (langchain.prompts.example_selector.LengthBasedExampleSelector method) (langchain.prompts.example_selector.SemanticSimilarityExampleSelector method) add_texts() (langchain.vectorstores.AtlasDB method) (langchain.vectorstores.Chroma method) (langchain.vectorstores.DeepLake method) (langchain.vectorstores.ElasticVectorSearch method) (langchain.vectorstores.FAISS method) (langchain.vectorstores.Milvus method) (langchain.vectorstores.OpenSearchVectorSearch method) (langchain.vectorstores.Pinecone method) (langchain.vectorstores.Qdrant method) (langchain.vectorstores.VectorStore method) (langchain.vectorstores.Weaviate method) agenerate() (langchain.chains.LLMChain method) (langchain.llms.AI21 method) (langchain.llms.AlephAlpha method) (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.Banana method) (langchain.llms.CerebriumAI method) (langchain.llms.Cohere method) (langchain.llms.DeepInfra method) (langchain.llms.ForefrontAI method) (langchain.llms.GooseAI method) (langchain.llms.GPT4All method) (langchain.llms.HuggingFaceEndpoint method) (langchain.llms.HuggingFaceHub method) (langchain.llms.HuggingFacePipeline method) (langchain.llms.LlamaCpp method) (langchain.llms.Modal method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-2
(langchain.llms.LlamaCpp method) (langchain.llms.Modal method) (langchain.llms.NLPCloud method) (langchain.llms.OpenAI method) (langchain.llms.OpenAIChat method) (langchain.llms.Petals method) (langchain.llms.PromptLayerOpenAI method) (langchain.llms.PromptLayerOpenAIChat method) (langchain.llms.Replicate method) (langchain.llms.SagemakerEndpoint method) (langchain.llms.SelfHostedHuggingFaceLLM method) (langchain.llms.SelfHostedPipeline method) (langchain.llms.StochasticAI method) (langchain.llms.Writer method) agenerate_prompt() (langchain.llms.AI21 method) (langchain.llms.AlephAlpha method) (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.Banana method) (langchain.llms.CerebriumAI method) (langchain.llms.Cohere method) (langchain.llms.DeepInfra method) (langchain.llms.ForefrontAI method) (langchain.llms.GooseAI method) (langchain.llms.GPT4All method) (langchain.llms.HuggingFaceEndpoint method) (langchain.llms.HuggingFaceHub method) (langchain.llms.HuggingFacePipeline method) (langchain.llms.LlamaCpp method) (langchain.llms.Modal method) (langchain.llms.NLPCloud method) (langchain.llms.OpenAI method) (langchain.llms.OpenAIChat method) (langchain.llms.Petals method) (langchain.llms.PromptLayerOpenAI method) (langchain.llms.PromptLayerOpenAIChat method) (langchain.llms.Replicate method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-3
(langchain.llms.Replicate method) (langchain.llms.SagemakerEndpoint method) (langchain.llms.SelfHostedHuggingFaceLLM method) (langchain.llms.SelfHostedPipeline method) (langchain.llms.StochasticAI method) (langchain.llms.Writer method) agent (langchain.agents.AgentExecutor attribute) (langchain.agents.MRKLChain attribute) (langchain.agents.ReActChain attribute) (langchain.agents.SelfAskWithSearchChain attribute) AgentType (class in langchain.agents) ai_prefix (langchain.agents.ConversationalAgent attribute) aiosession (langchain.serpapi.SerpAPIWrapper attribute) (langchain.utilities.searx_search.SearxSearchWrapper attribute) aleph_alpha_api_key (langchain.llms.AlephAlpha attribute) allowed_tools (langchain.agents.Agent attribute) (langchain.agents.ReActTextWorldAgent attribute) (langchain.agents.ZeroShotAgent attribute) answers (langchain.utilities.searx_search.SearxResults property) api_answer_chain (langchain.chains.APIChain attribute) api_docs (langchain.chains.APIChain attribute) api_request_chain (langchain.chains.APIChain attribute) api_url (langchain.llms.StochasticAI attribute) aplan() (langchain.agents.Agent method) (langchain.agents.BaseSingleActionAgent method) (langchain.agents.LLMSingleActionAgent method) apply() (langchain.chains.LLMChain method) apply_and_parse() (langchain.chains.LLMChain method) apredict() (langchain.chains.LLMChain method) apredict_and_parse() (langchain.chains.LLMChain method) aprep_prompts() (langchain.chains.LLMChain method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-4
aprep_prompts() (langchain.chains.LLMChain method) are_all_true_prompt (langchain.chains.LLMSummarizationCheckerChain attribute) aresults() (langchain.utilities.searx_search.SearxSearchWrapper method) arun() (langchain.serpapi.SerpAPIWrapper method) (langchain.utilities.searx_search.SearxSearchWrapper method) as_retriever() (langchain.vectorstores.VectorStore method) AtlasDB (class in langchain.vectorstores) B bad_words (langchain.llms.NLPCloud attribute) base_embeddings (langchain.chains.HypotheticalDocumentEmbedder attribute) base_url (langchain.llms.AI21 attribute) (langchain.llms.ForefrontAI attribute) (langchain.llms.Writer attribute) batch_size (langchain.llms.AzureOpenAI attribute) beam_search_diversity_rate (langchain.llms.Writer attribute) beam_width (langchain.llms.Writer attribute) best_of (langchain.llms.AlephAlpha attribute) (langchain.llms.AzureOpenAI attribute) C callback_manager (langchain.agents.MRKLChain attribute) (langchain.agents.ReActChain attribute) (langchain.agents.SelfAskWithSearchChain attribute) categories (langchain.utilities.searx_search.SearxSearchWrapper attribute) chain (langchain.chains.ConstitutionalChain attribute) chains (langchain.chains.SequentialChain attribute) (langchain.chains.SimpleSequentialChain attribute) CharacterTextSplitter (class in langchain.text_splitter) CHAT_CONVERSATIONAL_REACT_DESCRIPTION (langchain.agents.AgentType attribute) CHAT_ZERO_SHOT_REACT_DESCRIPTION (langchain.agents.AgentType attribute) check_assertions_prompt (langchain.chains.LLMCheckerChain attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-5
check_assertions_prompt (langchain.chains.LLMCheckerChain attribute) (langchain.chains.LLMSummarizationCheckerChain attribute) Chroma (class in langchain.vectorstores) chunk_size (langchain.embeddings.OpenAIEmbeddings attribute) client (langchain.llms.Petals attribute) combine_docs_chain (langchain.chains.AnalyzeDocumentChain attribute) combine_documents_chain (langchain.chains.MapReduceChain attribute) combine_embeddings() (langchain.chains.HypotheticalDocumentEmbedder method) completion_bias_exclusion_first_token_only (langchain.llms.AlephAlpha attribute) compress_to_size (langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding attribute) constitutional_principles (langchain.chains.ConstitutionalChain attribute) construct() (langchain.llms.AI21 class method) (langchain.llms.AlephAlpha class method) (langchain.llms.Anthropic class method) (langchain.llms.AzureOpenAI class method) (langchain.llms.Banana class method) (langchain.llms.CerebriumAI class method) (langchain.llms.Cohere class method) (langchain.llms.DeepInfra class method) (langchain.llms.ForefrontAI class method) (langchain.llms.GooseAI class method) (langchain.llms.GPT4All class method) (langchain.llms.HuggingFaceEndpoint class method) (langchain.llms.HuggingFaceHub class method) (langchain.llms.HuggingFacePipeline class method) (langchain.llms.LlamaCpp class method) (langchain.llms.Modal class method) (langchain.llms.NLPCloud class method) (langchain.llms.OpenAI class method) (langchain.llms.OpenAIChat class method) (langchain.llms.Petals class method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-6
(langchain.llms.Petals class method) (langchain.llms.PromptLayerOpenAI class method) (langchain.llms.PromptLayerOpenAIChat class method) (langchain.llms.Replicate class method) (langchain.llms.SagemakerEndpoint class method) (langchain.llms.SelfHostedHuggingFaceLLM class method) (langchain.llms.SelfHostedPipeline class method) (langchain.llms.StochasticAI class method) (langchain.llms.Writer class method) content_handler (langchain.embeddings.SagemakerEndpointEmbeddings attribute) (langchain.llms.SagemakerEndpoint attribute) CONTENT_KEY (langchain.vectorstores.Qdrant attribute) contextual_control_threshold (langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding attribute) (langchain.llms.AlephAlpha attribute) control_log_additive (langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding attribute) (langchain.llms.AlephAlpha attribute) CONVERSATIONAL_REACT_DESCRIPTION (langchain.agents.AgentType attribute) copy() (langchain.llms.AI21 method) (langchain.llms.AlephAlpha method) (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.Banana method) (langchain.llms.CerebriumAI method) (langchain.llms.Cohere method) (langchain.llms.DeepInfra method) (langchain.llms.ForefrontAI method) (langchain.llms.GooseAI method) (langchain.llms.GPT4All method) (langchain.llms.HuggingFaceEndpoint method) (langchain.llms.HuggingFaceHub method) (langchain.llms.HuggingFacePipeline method) (langchain.llms.LlamaCpp method) (langchain.llms.Modal method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-7
(langchain.llms.LlamaCpp method) (langchain.llms.Modal method) (langchain.llms.NLPCloud method) (langchain.llms.OpenAI method) (langchain.llms.OpenAIChat method) (langchain.llms.Petals method) (langchain.llms.PromptLayerOpenAI method) (langchain.llms.PromptLayerOpenAIChat method) (langchain.llms.Replicate method) (langchain.llms.SagemakerEndpoint method) (langchain.llms.SelfHostedHuggingFaceLLM method) (langchain.llms.SelfHostedPipeline method) (langchain.llms.StochasticAI method) (langchain.llms.Writer method) coroutine (langchain.agents.Tool attribute) countPenalty (langchain.llms.AI21 attribute) create_assertions_prompt (langchain.chains.LLMSummarizationCheckerChain attribute) create_csv_agent() (in module langchain.agents) create_documents() (langchain.text_splitter.TextSplitter method) create_draft_answer_prompt (langchain.chains.LLMCheckerChain attribute) create_index() (langchain.vectorstores.AtlasDB method) create_json_agent() (in module langchain.agents) create_llm_result() (langchain.llms.AzureOpenAI method) (langchain.llms.OpenAI method) (langchain.llms.PromptLayerOpenAI method) create_openapi_agent() (in module langchain.agents) create_outputs() (langchain.chains.LLMChain method) create_pandas_dataframe_agent() (in module langchain.agents) create_prompt() (langchain.agents.Agent class method) (langchain.agents.ConversationalAgent class method) (langchain.agents.ConversationalChatAgent class method) (langchain.agents.ReActTextWorldAgent class method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-8
(langchain.agents.ReActTextWorldAgent class method) (langchain.agents.ZeroShotAgent class method) create_sql_agent() (in module langchain.agents) create_vectorstore_agent() (in module langchain.agents) create_vectorstore_router_agent() (in module langchain.agents) credentials_profile_name (langchain.embeddings.SagemakerEndpointEmbeddings attribute) (langchain.llms.SagemakerEndpoint attribute) critique_chain (langchain.chains.ConstitutionalChain attribute) D database (langchain.chains.SQLDatabaseChain attribute) decider_chain (langchain.chains.SQLDatabaseSequentialChain attribute) DeepLake (class in langchain.vectorstores) delete_collection() (langchain.vectorstores.Chroma method) delete_dataset() (langchain.vectorstores.DeepLake method) deployment_name (langchain.llms.AzureOpenAI attribute) description (langchain.agents.Tool attribute) device (langchain.llms.SelfHostedHuggingFaceLLM attribute) dict() (langchain.agents.BaseSingleActionAgent method) (langchain.llms.AI21 method) (langchain.llms.AlephAlpha method) (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.Banana method) (langchain.llms.CerebriumAI method) (langchain.llms.Cohere method) (langchain.llms.DeepInfra method) (langchain.llms.ForefrontAI method) (langchain.llms.GooseAI method) (langchain.llms.GPT4All method) (langchain.llms.HuggingFaceEndpoint method) (langchain.llms.HuggingFaceHub method) (langchain.llms.HuggingFacePipeline method) (langchain.llms.LlamaCpp method) (langchain.llms.Modal method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-9
(langchain.llms.LlamaCpp method) (langchain.llms.Modal method) (langchain.llms.NLPCloud method) (langchain.llms.OpenAI method) (langchain.llms.OpenAIChat method) (langchain.llms.Petals method) (langchain.llms.PromptLayerOpenAI method) (langchain.llms.PromptLayerOpenAIChat method) (langchain.llms.Replicate method) (langchain.llms.SagemakerEndpoint method) (langchain.llms.SelfHostedHuggingFaceLLM method) (langchain.llms.SelfHostedPipeline method) (langchain.llms.StochasticAI method) (langchain.llms.Writer method) (langchain.prompts.BasePromptTemplate method) (langchain.prompts.FewShotPromptTemplate method) (langchain.prompts.FewShotPromptWithTemplates method) do_sample (langchain.llms.NLPCloud attribute) (langchain.llms.Petals attribute) E early_stopping (langchain.llms.NLPCloud attribute) early_stopping_method (langchain.agents.AgentExecutor attribute) (langchain.agents.MRKLChain attribute) (langchain.agents.ReActChain attribute) (langchain.agents.SelfAskWithSearchChain attribute) echo (langchain.llms.AlephAlpha attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) ElasticVectorSearch (class in langchain.vectorstores) embed_documents() (langchain.chains.HypotheticalDocumentEmbedder method) (langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding method) (langchain.embeddings.AlephAlphaSymmetricSemanticEmbedding method) (langchain.embeddings.CohereEmbeddings method) (langchain.embeddings.FakeEmbeddings method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-10
(langchain.embeddings.FakeEmbeddings method) (langchain.embeddings.HuggingFaceEmbeddings method) (langchain.embeddings.HuggingFaceHubEmbeddings method) (langchain.embeddings.HuggingFaceInstructEmbeddings method) (langchain.embeddings.LlamaCppEmbeddings method) (langchain.embeddings.OpenAIEmbeddings method) (langchain.embeddings.SagemakerEndpointEmbeddings method) (langchain.embeddings.SelfHostedEmbeddings method) (langchain.embeddings.SelfHostedHuggingFaceInstructEmbeddings method) (langchain.embeddings.TensorflowHubEmbeddings method) embed_instruction (langchain.embeddings.HuggingFaceInstructEmbeddings attribute) (langchain.embeddings.SelfHostedHuggingFaceInstructEmbeddings attribute) embed_query() (langchain.chains.HypotheticalDocumentEmbedder method) (langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding method) (langchain.embeddings.AlephAlphaSymmetricSemanticEmbedding method) (langchain.embeddings.CohereEmbeddings method) (langchain.embeddings.FakeEmbeddings method) (langchain.embeddings.HuggingFaceEmbeddings method) (langchain.embeddings.HuggingFaceHubEmbeddings method) (langchain.embeddings.HuggingFaceInstructEmbeddings method) (langchain.embeddings.LlamaCppEmbeddings method) (langchain.embeddings.OpenAIEmbeddings method) (langchain.embeddings.SagemakerEndpointEmbeddings method) (langchain.embeddings.SelfHostedEmbeddings method) (langchain.embeddings.SelfHostedHuggingFaceInstructEmbeddings method) (langchain.embeddings.TensorflowHubEmbeddings method) embedding (langchain.llms.GPT4All attribute) endpoint_kwargs (langchain.embeddings.SagemakerEndpointEmbeddings attribute) (langchain.llms.SagemakerEndpoint attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-11
(langchain.llms.SagemakerEndpoint attribute) endpoint_name (langchain.embeddings.SagemakerEndpointEmbeddings attribute) (langchain.llms.SagemakerEndpoint attribute) endpoint_url (langchain.llms.CerebriumAI attribute) (langchain.llms.ForefrontAI attribute) (langchain.llms.HuggingFaceEndpoint attribute) (langchain.llms.Modal attribute) engines (langchain.utilities.searx_search.SearxSearchWrapper attribute) entity_extraction_chain (langchain.chains.GraphQAChain attribute) error (langchain.chains.OpenAIModerationChain attribute) example_keys (langchain.prompts.example_selector.SemanticSimilarityExampleSelector attribute) example_prompt (langchain.prompts.example_selector.LengthBasedExampleSelector attribute) (langchain.prompts.FewShotPromptTemplate attribute) (langchain.prompts.FewShotPromptWithTemplates attribute) example_selector (langchain.prompts.FewShotPromptTemplate attribute) (langchain.prompts.FewShotPromptWithTemplates attribute) example_separator (langchain.prompts.FewShotPromptTemplate attribute) (langchain.prompts.FewShotPromptWithTemplates attribute) examples (langchain.prompts.example_selector.LengthBasedExampleSelector attribute) (langchain.prompts.FewShotPromptTemplate attribute) (langchain.prompts.FewShotPromptWithTemplates attribute) F f16_kv (langchain.embeddings.LlamaCppEmbeddings attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) FAISS (class in langchain.vectorstores) fetch_k (langchain.prompts.example_selector.MaxMarginalRelevanceExampleSelector attribute) finish_tool_name (langchain.agents.Agent property) (langchain.agents.ConversationalAgent property) format() (langchain.prompts.BaseChatPromptTemplate method) (langchain.prompts.BasePromptTemplate method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-12
(langchain.prompts.BasePromptTemplate method) (langchain.prompts.ChatPromptTemplate method) (langchain.prompts.FewShotPromptTemplate method) (langchain.prompts.FewShotPromptWithTemplates method) (langchain.prompts.PromptTemplate method) format_messages() (langchain.prompts.BaseChatPromptTemplate method) (langchain.prompts.ChatPromptTemplate method) (langchain.prompts.MessagesPlaceholder method) format_prompt() (langchain.prompts.BaseChatPromptTemplate method) (langchain.prompts.BasePromptTemplate method) (langchain.prompts.StringPromptTemplate method) frequency_penalty (langchain.llms.AlephAlpha attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.Cohere attribute) (langchain.llms.GooseAI attribute) frequencyPenalty (langchain.llms.AI21 attribute) from_agent_and_tools() (langchain.agents.AgentExecutor class method) from_chains() (langchain.agents.MRKLChain class method) from_colored_object_prompt() (langchain.chains.PALChain class method) from_documents() (langchain.vectorstores.AtlasDB class method) (langchain.vectorstores.Chroma class method) (langchain.vectorstores.Qdrant class method) (langchain.vectorstores.VectorStore class method) from_embeddings() (langchain.vectorstores.FAISS class method) from_examples() (langchain.prompts.example_selector.MaxMarginalRelevanceExampleSelector class method) (langchain.prompts.example_selector.SemanticSimilarityExampleSelector class method) (langchain.prompts.PromptTemplate class method) from_existing_index() (langchain.vectorstores.Pinecone class method) from_file() (langchain.prompts.PromptTemplate class method) from_huggingface_tokenizer() (langchain.text_splitter.TextSplitter class method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-13
from_huggingface_tokenizer() (langchain.text_splitter.TextSplitter class method) from_llm() (langchain.chains.ChatVectorDBChain class method) (langchain.chains.ConstitutionalChain class method) (langchain.chains.ConversationalRetrievalChain class method) (langchain.chains.GraphQAChain class method) (langchain.chains.HypotheticalDocumentEmbedder class method) (langchain.chains.QAGenerationChain class method) (langchain.chains.SQLDatabaseSequentialChain class method) from_llm_and_api_docs() (langchain.chains.APIChain class method) from_llm_and_tools() (langchain.agents.Agent class method) (langchain.agents.ConversationalAgent class method) (langchain.agents.ConversationalChatAgent class method) (langchain.agents.ZeroShotAgent class method) from_math_prompt() (langchain.chains.PALChain class method) from_model_id() (langchain.llms.HuggingFacePipeline class method) from_params() (langchain.chains.MapReduceChain class method) from_pipeline() (langchain.llms.SelfHostedHuggingFaceLLM class method) (langchain.llms.SelfHostedPipeline class method) from_string() (langchain.chains.LLMChain class method) from_template() (langchain.prompts.PromptTemplate class method) from_texts() (langchain.vectorstores.AtlasDB class method) (langchain.vectorstores.Chroma class method) (langchain.vectorstores.DeepLake class method) (langchain.vectorstores.ElasticVectorSearch class method) (langchain.vectorstores.FAISS class method) (langchain.vectorstores.Milvus class method) (langchain.vectorstores.OpenSearchVectorSearch class method) (langchain.vectorstores.Pinecone class method) (langchain.vectorstores.Qdrant class method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-14
(langchain.vectorstores.Qdrant class method) (langchain.vectorstores.VectorStore class method) (langchain.vectorstores.Weaviate class method) from_tiktoken_encoder() (langchain.text_splitter.TextSplitter class method) func (langchain.agents.Tool attribute) G generate() (langchain.chains.LLMChain method) (langchain.llms.AI21 method) (langchain.llms.AlephAlpha method) (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.Banana method) (langchain.llms.CerebriumAI method) (langchain.llms.Cohere method) (langchain.llms.DeepInfra method) (langchain.llms.ForefrontAI method) (langchain.llms.GooseAI method) (langchain.llms.GPT4All method) (langchain.llms.HuggingFaceEndpoint method) (langchain.llms.HuggingFaceHub method) (langchain.llms.HuggingFacePipeline method) (langchain.llms.LlamaCpp method) (langchain.llms.Modal method) (langchain.llms.NLPCloud method) (langchain.llms.OpenAI method) (langchain.llms.OpenAIChat method) (langchain.llms.Petals method) (langchain.llms.PromptLayerOpenAI method) (langchain.llms.PromptLayerOpenAIChat method) (langchain.llms.Replicate method) (langchain.llms.SagemakerEndpoint method) (langchain.llms.SelfHostedHuggingFaceLLM method) (langchain.llms.SelfHostedPipeline method) (langchain.llms.StochasticAI method) (langchain.llms.Writer method) generate_prompt() (langchain.llms.AI21 method) (langchain.llms.AlephAlpha method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-15
(langchain.llms.AlephAlpha method) (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.Banana method) (langchain.llms.CerebriumAI method) (langchain.llms.Cohere method) (langchain.llms.DeepInfra method) (langchain.llms.ForefrontAI method) (langchain.llms.GooseAI method) (langchain.llms.GPT4All method) (langchain.llms.HuggingFaceEndpoint method) (langchain.llms.HuggingFaceHub method) (langchain.llms.HuggingFacePipeline method) (langchain.llms.LlamaCpp method) (langchain.llms.Modal method) (langchain.llms.NLPCloud method) (langchain.llms.OpenAI method) (langchain.llms.OpenAIChat method) (langchain.llms.Petals method) (langchain.llms.PromptLayerOpenAI method) (langchain.llms.PromptLayerOpenAIChat method) (langchain.llms.Replicate method) (langchain.llms.SagemakerEndpoint method) (langchain.llms.SelfHostedHuggingFaceLLM method) (langchain.llms.SelfHostedPipeline method) (langchain.llms.StochasticAI method) (langchain.llms.Writer method) get_all_tool_names() (in module langchain.agents) get_allowed_tools() (langchain.agents.Agent method) (langchain.agents.BaseSingleActionAgent method) get_answer_expr (langchain.chains.PALChain attribute) get_full_inputs() (langchain.agents.Agent method) get_num_tokens() (langchain.llms.AI21 method) (langchain.llms.AlephAlpha method) (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-16
(langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.Banana method) (langchain.llms.CerebriumAI method) (langchain.llms.Cohere method) (langchain.llms.DeepInfra method) (langchain.llms.ForefrontAI method) (langchain.llms.GooseAI method) (langchain.llms.GPT4All method) (langchain.llms.HuggingFaceEndpoint method) (langchain.llms.HuggingFaceHub method) (langchain.llms.HuggingFacePipeline method) (langchain.llms.LlamaCpp method) (langchain.llms.Modal method) (langchain.llms.NLPCloud method) (langchain.llms.OpenAI method) (langchain.llms.OpenAIChat method) (langchain.llms.Petals method) (langchain.llms.PromptLayerOpenAI method) (langchain.llms.PromptLayerOpenAIChat method) (langchain.llms.Replicate method) (langchain.llms.SagemakerEndpoint method) (langchain.llms.SelfHostedHuggingFaceLLM method) (langchain.llms.SelfHostedPipeline method) (langchain.llms.StochasticAI method) (langchain.llms.Writer method) get_num_tokens_from_messages() (langchain.llms.AI21 method) (langchain.llms.AlephAlpha method) (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.Banana method) (langchain.llms.CerebriumAI method) (langchain.llms.Cohere method) (langchain.llms.DeepInfra method) (langchain.llms.ForefrontAI method) (langchain.llms.GooseAI method) (langchain.llms.GPT4All method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-17
(langchain.llms.GooseAI method) (langchain.llms.GPT4All method) (langchain.llms.HuggingFaceEndpoint method) (langchain.llms.HuggingFaceHub method) (langchain.llms.HuggingFacePipeline method) (langchain.llms.LlamaCpp method) (langchain.llms.Modal method) (langchain.llms.NLPCloud method) (langchain.llms.OpenAI method) (langchain.llms.OpenAIChat method) (langchain.llms.Petals method) (langchain.llms.PromptLayerOpenAI method) (langchain.llms.PromptLayerOpenAIChat method) (langchain.llms.Replicate method) (langchain.llms.SagemakerEndpoint method) (langchain.llms.SelfHostedHuggingFaceLLM method) (langchain.llms.SelfHostedPipeline method) (langchain.llms.StochasticAI method) (langchain.llms.Writer method) get_params() (langchain.serpapi.SerpAPIWrapper method) get_principles() (langchain.chains.ConstitutionalChain class method) get_sub_prompts() (langchain.llms.AzureOpenAI method) (langchain.llms.OpenAI method) (langchain.llms.PromptLayerOpenAI method) get_text_length (langchain.prompts.example_selector.LengthBasedExampleSelector attribute) globals (langchain.python.PythonREPL attribute) graph (langchain.chains.GraphQAChain attribute) H hardware (langchain.embeddings.SelfHostedHuggingFaceEmbeddings attribute) (langchain.llms.SelfHostedHuggingFaceLLM attribute) (langchain.llms.SelfHostedPipeline attribute) headers (langchain.utilities.searx_search.SearxSearchWrapper attribute) hosting (langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-18
hosting (langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding attribute) I inference_fn (langchain.embeddings.SelfHostedEmbeddings attribute) (langchain.embeddings.SelfHostedHuggingFaceEmbeddings attribute) (langchain.llms.SelfHostedHuggingFaceLLM attribute) (langchain.llms.SelfHostedPipeline attribute) inference_kwargs (langchain.embeddings.SelfHostedEmbeddings attribute) initialize_agent() (in module langchain.agents) InMemoryDocstore (class in langchain.docstore) input_key (langchain.chains.QAGenerationChain attribute) input_keys (langchain.chains.ConstitutionalChain property) (langchain.chains.ConversationChain property) (langchain.chains.HypotheticalDocumentEmbedder property) (langchain.chains.QAGenerationChain property) (langchain.prompts.example_selector.SemanticSimilarityExampleSelector attribute) input_variables (langchain.chains.SequentialChain attribute) (langchain.chains.TransformChain attribute) (langchain.prompts.BasePromptTemplate attribute) (langchain.prompts.FewShotPromptTemplate attribute) (langchain.prompts.FewShotPromptWithTemplates attribute) (langchain.prompts.MessagesPlaceholder property) (langchain.prompts.PromptTemplate attribute) J json() (langchain.llms.AI21 method) (langchain.llms.AlephAlpha method) (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.Banana method) (langchain.llms.CerebriumAI method) (langchain.llms.Cohere method) (langchain.llms.DeepInfra method) (langchain.llms.ForefrontAI method) (langchain.llms.GooseAI method) (langchain.llms.GPT4All method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-19
(langchain.llms.GooseAI method) (langchain.llms.GPT4All method) (langchain.llms.HuggingFaceEndpoint method) (langchain.llms.HuggingFaceHub method) (langchain.llms.HuggingFacePipeline method) (langchain.llms.LlamaCpp method) (langchain.llms.Modal method) (langchain.llms.NLPCloud method) (langchain.llms.OpenAI method) (langchain.llms.OpenAIChat method) (langchain.llms.Petals method) (langchain.llms.PromptLayerOpenAI method) (langchain.llms.PromptLayerOpenAIChat method) (langchain.llms.Replicate method) (langchain.llms.SagemakerEndpoint method) (langchain.llms.SelfHostedHuggingFaceLLM method) (langchain.llms.SelfHostedPipeline method) (langchain.llms.StochasticAI method) (langchain.llms.Writer method) K k (langchain.chains.QAGenerationChain attribute) (langchain.chains.VectorDBQA attribute) (langchain.chains.VectorDBQAWithSourcesChain attribute) (langchain.llms.Cohere attribute) (langchain.prompts.example_selector.SemanticSimilarityExampleSelector attribute) (langchain.utilities.searx_search.SearxSearchWrapper attribute) L langchain.agents module langchain.chains module langchain.docstore module langchain.embeddings module langchain.llms module langchain.prompts module langchain.prompts.example_selector module langchain.python module langchain.serpapi module langchain.text_splitter module langchain.utilities.searx_search
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-20
module langchain.utilities.searx_search module langchain.vectorstores module last_n_tokens_size (langchain.llms.LlamaCpp attribute) LatexTextSplitter (class in langchain.text_splitter) length (langchain.llms.ForefrontAI attribute) (langchain.llms.Writer attribute) length_no_input (langchain.llms.NLPCloud attribute) length_penalty (langchain.llms.NLPCloud attribute) length_pentaly (langchain.llms.Writer attribute) list_assertions_prompt (langchain.chains.LLMCheckerChain attribute) llm (langchain.chains.LLMBashChain attribute) (langchain.chains.LLMChain attribute) (langchain.chains.LLMCheckerChain attribute) (langchain.chains.LLMMathChain attribute) (langchain.chains.LLMSummarizationCheckerChain attribute) (langchain.chains.PALChain attribute) (langchain.chains.SQLDatabaseChain attribute) llm_chain (langchain.agents.Agent attribute) (langchain.agents.LLMSingleActionAgent attribute) (langchain.agents.ReActTextWorldAgent attribute) (langchain.agents.ZeroShotAgent attribute) (langchain.chains.HypotheticalDocumentEmbedder attribute) (langchain.chains.LLMRequestsChain attribute) (langchain.chains.QAGenerationChain attribute) llm_prefix (langchain.agents.Agent property) (langchain.agents.ConversationalAgent property) (langchain.agents.ConversationalChatAgent property) (langchain.agents.ZeroShotAgent property) load_agent() (in module langchain.agents) load_chain() (in module langchain.chains) load_fn_kwargs (langchain.embeddings.SelfHostedHuggingFaceEmbeddings attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-21
load_fn_kwargs (langchain.embeddings.SelfHostedHuggingFaceEmbeddings attribute) (langchain.llms.SelfHostedHuggingFaceLLM attribute) (langchain.llms.SelfHostedPipeline attribute) load_local() (langchain.vectorstores.FAISS class method) load_prompt() (in module langchain.prompts) load_tools() (in module langchain.agents) locals (langchain.python.PythonREPL attribute) log_probs (langchain.llms.AlephAlpha attribute) logit_bias (langchain.llms.AlephAlpha attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.GooseAI attribute) logitBias (langchain.llms.AI21 attribute) logits_all (langchain.embeddings.LlamaCppEmbeddings attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) logprobs (langchain.llms.LlamaCpp attribute) (langchain.llms.Writer attribute) lookup_tool() (langchain.agents.AgentExecutor method) M MarkdownTextSplitter (class in langchain.text_splitter) max_checks (langchain.chains.LLMSummarizationCheckerChain attribute) max_iterations (langchain.agents.AgentExecutor attribute) (langchain.agents.MRKLChain attribute) (langchain.agents.ReActChain attribute) (langchain.agents.SelfAskWithSearchChain attribute) max_length (langchain.llms.NLPCloud attribute) (langchain.llms.Petals attribute) (langchain.prompts.example_selector.LengthBasedExampleSelector attribute) max_marginal_relevance_search() (langchain.vectorstores.Chroma method) (langchain.vectorstores.FAISS method) (langchain.vectorstores.Milvus method) (langchain.vectorstores.Qdrant method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-22
(langchain.vectorstores.Milvus method) (langchain.vectorstores.Qdrant method) (langchain.vectorstores.VectorStore method) max_marginal_relevance_search_by_vector() (langchain.vectorstores.Chroma method) (langchain.vectorstores.FAISS method) (langchain.vectorstores.VectorStore method) max_new_tokens (langchain.llms.Petals attribute) max_retries (langchain.embeddings.OpenAIEmbeddings attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.OpenAIChat attribute) (langchain.llms.PromptLayerOpenAIChat attribute) max_tokens (langchain.llms.AzureOpenAI attribute) (langchain.llms.Cohere attribute) (langchain.llms.GooseAI attribute) (langchain.llms.LlamaCpp attribute) max_tokens_for_prompt() (langchain.llms.AzureOpenAI method) (langchain.llms.OpenAI method) (langchain.llms.PromptLayerOpenAI method) max_tokens_limit (langchain.chains.ConversationalRetrievalChain attribute) (langchain.chains.RetrievalQAWithSourcesChain attribute) (langchain.chains.VectorDBQAWithSourcesChain attribute) max_tokens_to_sample (langchain.llms.Anthropic attribute) maximum_tokens (langchain.llms.AlephAlpha attribute) maxTokens (langchain.llms.AI21 attribute) memory (langchain.agents.MRKLChain attribute) (langchain.agents.ReActChain attribute) (langchain.agents.SelfAskWithSearchChain attribute) (langchain.chains.ConversationChain attribute) merge_from() (langchain.vectorstores.FAISS method) METADATA_KEY (langchain.vectorstores.Qdrant attribute) Milvus (class in langchain.vectorstores) min_length (langchain.llms.NLPCloud attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-23
min_length (langchain.llms.NLPCloud attribute) min_tokens (langchain.llms.GooseAI attribute) minimum_tokens (langchain.llms.AlephAlpha attribute) minTokens (langchain.llms.AI21 attribute) model (langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding attribute) (langchain.embeddings.CohereEmbeddings attribute) (langchain.llms.AI21 attribute) (langchain.llms.AlephAlpha attribute) (langchain.llms.Anthropic attribute) (langchain.llms.Cohere attribute) (langchain.llms.GPT4All attribute) model_id (langchain.embeddings.SelfHostedHuggingFaceEmbeddings attribute) (langchain.embeddings.SelfHostedHuggingFaceInstructEmbeddings attribute) (langchain.llms.HuggingFacePipeline attribute) (langchain.llms.SelfHostedHuggingFaceLLM attribute) (langchain.llms.Writer attribute) model_key (langchain.llms.Banana attribute) model_kwargs (langchain.embeddings.HuggingFaceHubEmbeddings attribute) (langchain.embeddings.SagemakerEndpointEmbeddings attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.Banana attribute) (langchain.llms.CerebriumAI attribute) (langchain.llms.GooseAI attribute) (langchain.llms.HuggingFaceEndpoint attribute) (langchain.llms.HuggingFaceHub attribute) (langchain.llms.HuggingFacePipeline attribute) (langchain.llms.Modal attribute) (langchain.llms.OpenAIChat attribute) (langchain.llms.Petals attribute) (langchain.llms.PromptLayerOpenAIChat attribute) (langchain.llms.SagemakerEndpoint attribute) (langchain.llms.SelfHostedHuggingFaceLLM attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-24
(langchain.llms.SelfHostedHuggingFaceLLM attribute) (langchain.llms.StochasticAI attribute) model_load_fn (langchain.embeddings.SelfHostedHuggingFaceEmbeddings attribute) (langchain.llms.SelfHostedHuggingFaceLLM attribute) (langchain.llms.SelfHostedPipeline attribute) model_name (langchain.chains.OpenAIModerationChain attribute) (langchain.embeddings.HuggingFaceEmbeddings attribute) (langchain.embeddings.HuggingFaceInstructEmbeddings attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.GooseAI attribute) (langchain.llms.NLPCloud attribute) (langchain.llms.OpenAIChat attribute) (langchain.llms.Petals attribute) (langchain.llms.PromptLayerOpenAIChat attribute) model_path (langchain.llms.LlamaCpp attribute) model_reqs (langchain.embeddings.SelfHostedHuggingFaceEmbeddings attribute) (langchain.embeddings.SelfHostedHuggingFaceInstructEmbeddings attribute) (langchain.llms.SelfHostedHuggingFaceLLM attribute) (langchain.llms.SelfHostedPipeline attribute) model_url (langchain.embeddings.TensorflowHubEmbeddings attribute) modelname_to_contextsize() (langchain.llms.AzureOpenAI method) (langchain.llms.OpenAI method) (langchain.llms.PromptLayerOpenAI method) module langchain.agents langchain.chains langchain.docstore langchain.embeddings langchain.llms langchain.prompts langchain.prompts.example_selector langchain.python langchain.serpapi langchain.text_splitter langchain.utilities.searx_search langchain.vectorstores N n (langchain.llms.AlephAlpha attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-25
langchain.vectorstores N n (langchain.llms.AlephAlpha attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.GooseAI attribute) n_batch (langchain.embeddings.LlamaCppEmbeddings attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) n_ctx (langchain.embeddings.LlamaCppEmbeddings attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) n_parts (langchain.embeddings.LlamaCppEmbeddings attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) n_predict (langchain.llms.GPT4All attribute) n_threads (langchain.embeddings.LlamaCppEmbeddings attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) NLTKTextSplitter (class in langchain.text_splitter) normalize (langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding attribute) num_beams (langchain.llms.NLPCloud attribute) num_return_sequences (langchain.llms.NLPCloud attribute) numResults (langchain.llms.AI21 attribute) O observation_prefix (langchain.agents.Agent property) (langchain.agents.ConversationalAgent property) (langchain.agents.ConversationalChatAgent property) (langchain.agents.ZeroShotAgent property) openai_api_key (langchain.chains.OpenAIModerationChain attribute) OpenSearchVectorSearch (class in langchain.vectorstores) output_key (langchain.chains.QAGenerationChain attribute) output_keys (langchain.chains.ConstitutionalChain property) (langchain.chains.HypotheticalDocumentEmbedder property)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-26
(langchain.chains.HypotheticalDocumentEmbedder property) (langchain.chains.QAGenerationChain property) output_parser (langchain.agents.ConversationalChatAgent attribute) (langchain.agents.LLMSingleActionAgent attribute) (langchain.prompts.BasePromptTemplate attribute) output_variables (langchain.chains.TransformChain attribute) P p (langchain.llms.Cohere attribute) params (langchain.serpapi.SerpAPIWrapper attribute) (langchain.utilities.searx_search.SearxSearchWrapper attribute) parse() (langchain.agents.AgentOutputParser method) partial() (langchain.prompts.BasePromptTemplate method) (langchain.prompts.ChatPromptTemplate method) penalty_bias (langchain.llms.AlephAlpha attribute) penalty_exceptions (langchain.llms.AlephAlpha attribute) penalty_exceptions_include_stop_sequences (langchain.llms.AlephAlpha attribute) persist() (langchain.vectorstores.Chroma method) (langchain.vectorstores.DeepLake method) Pinecone (class in langchain.vectorstores) plan() (langchain.agents.Agent method) (langchain.agents.BaseSingleActionAgent method) (langchain.agents.LLMSingleActionAgent method) predict() (langchain.chains.LLMChain method) predict_and_parse() (langchain.chains.LLMChain method) prefix (langchain.prompts.FewShotPromptTemplate attribute) (langchain.prompts.FewShotPromptWithTemplates attribute) prefix_messages (langchain.llms.OpenAIChat attribute) (langchain.llms.PromptLayerOpenAIChat attribute) prep_prompts() (langchain.chains.LLMChain method) prep_streaming_params() (langchain.llms.AzureOpenAI method) (langchain.llms.OpenAI method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-27
(langchain.llms.OpenAI method) (langchain.llms.PromptLayerOpenAI method) presence_penalty (langchain.llms.AlephAlpha attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.Cohere attribute) (langchain.llms.GooseAI attribute) presencePenalty (langchain.llms.AI21 attribute) Prompt (in module langchain.prompts) prompt (langchain.chains.ConversationChain attribute) (langchain.chains.LLMBashChain attribute) (langchain.chains.LLMChain attribute) (langchain.chains.LLMMathChain attribute) (langchain.chains.PALChain attribute) (langchain.chains.SQLDatabaseChain attribute) python_globals (langchain.chains.PALChain attribute) python_locals (langchain.chains.PALChain attribute) PythonCodeTextSplitter (class in langchain.text_splitter) Q qa_chain (langchain.chains.GraphQAChain attribute) Qdrant (class in langchain.vectorstores) query_instruction (langchain.embeddings.HuggingFaceInstructEmbeddings attribute) (langchain.embeddings.SelfHostedHuggingFaceInstructEmbeddings attribute) query_suffix (langchain.utilities.searx_search.SearxSearchWrapper attribute) R random_seed (langchain.llms.Writer attribute) raw_completion (langchain.llms.AlephAlpha attribute) REACT_DOCSTORE (langchain.agents.AgentType attribute) RecursiveCharacterTextSplitter (class in langchain.text_splitter) reduce_k_below_max_tokens (langchain.chains.RetrievalQAWithSourcesChain attribute) (langchain.chains.VectorDBQAWithSourcesChain attribute) region_name (langchain.embeddings.SagemakerEndpointEmbeddings attribute) (langchain.llms.SagemakerEndpoint attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-28
(langchain.llms.SagemakerEndpoint attribute) remove_end_sequence (langchain.llms.NLPCloud attribute) remove_input (langchain.llms.NLPCloud attribute) repeat_last_n (langchain.llms.GPT4All attribute) repeat_penalty (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) repetition_penalties_include_completion (langchain.llms.AlephAlpha attribute) repetition_penalties_include_prompt (langchain.llms.AlephAlpha attribute) repetition_penalty (langchain.llms.ForefrontAI attribute) (langchain.llms.NLPCloud attribute) (langchain.llms.Writer attribute) repo_id (langchain.embeddings.HuggingFaceHubEmbeddings attribute) (langchain.llms.HuggingFaceHub attribute) request_timeout (langchain.llms.AzureOpenAI attribute) requests_wrapper (langchain.chains.APIChain attribute) (langchain.chains.LLMRequestsChain attribute) results() (langchain.serpapi.SerpAPIWrapper method) (langchain.utilities.searx_search.SearxSearchWrapper method) retriever (langchain.chains.ConversationalRetrievalChain attribute) (langchain.chains.RetrievalQA attribute) (langchain.chains.RetrievalQAWithSourcesChain attribute) return_all (langchain.chains.SequentialChain attribute) return_direct (langchain.chains.SQLDatabaseChain attribute) return_intermediate_steps (langchain.agents.AgentExecutor attribute) (langchain.agents.MRKLChain attribute) (langchain.agents.ReActChain attribute) (langchain.agents.SelfAskWithSearchChain attribute) (langchain.chains.PALChain attribute) (langchain.chains.SQLDatabaseChain attribute) (langchain.chains.SQLDatabaseSequentialChain attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-29
(langchain.chains.SQLDatabaseChain attribute) (langchain.chains.SQLDatabaseSequentialChain attribute) return_stopped_response() (langchain.agents.Agent method) (langchain.agents.BaseSingleActionAgent method) return_values (langchain.agents.Agent property) (langchain.agents.BaseSingleActionAgent property) revised_answer_prompt (langchain.chains.LLMCheckerChain attribute) revised_summary_prompt (langchain.chains.LLMSummarizationCheckerChain attribute) revision_chain (langchain.chains.ConstitutionalChain attribute) run() (langchain.python.PythonREPL method) (langchain.serpapi.SerpAPIWrapper method) (langchain.utilities.searx_search.SearxSearchWrapper method) S save() (langchain.agents.AgentExecutor method) (langchain.agents.BaseSingleActionAgent method) (langchain.llms.AI21 method) (langchain.llms.AlephAlpha method) (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.Banana method) (langchain.llms.CerebriumAI method) (langchain.llms.Cohere method) (langchain.llms.DeepInfra method) (langchain.llms.ForefrontAI method) (langchain.llms.GooseAI method) (langchain.llms.GPT4All method) (langchain.llms.HuggingFaceEndpoint method) (langchain.llms.HuggingFaceHub method) (langchain.llms.HuggingFacePipeline method) (langchain.llms.LlamaCpp method) (langchain.llms.Modal method) (langchain.llms.NLPCloud method) (langchain.llms.OpenAI method) (langchain.llms.OpenAIChat method) (langchain.llms.Petals method) (langchain.llms.PromptLayerOpenAI method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-30
(langchain.llms.PromptLayerOpenAI method) (langchain.llms.PromptLayerOpenAIChat method) (langchain.llms.Replicate method) (langchain.llms.SagemakerEndpoint method) (langchain.llms.SelfHostedHuggingFaceLLM method) (langchain.llms.SelfHostedPipeline method) (langchain.llms.StochasticAI method) (langchain.llms.Writer method) (langchain.prompts.BasePromptTemplate method) (langchain.prompts.ChatPromptTemplate method) save_agent() (langchain.agents.AgentExecutor method) save_local() (langchain.vectorstores.FAISS method) search() (langchain.docstore.InMemoryDocstore method) (langchain.docstore.Wikipedia method) search_kwargs (langchain.chains.ChatVectorDBChain attribute) (langchain.chains.VectorDBQA attribute) (langchain.chains.VectorDBQAWithSourcesChain attribute) search_type (langchain.chains.VectorDBQA attribute) searx_host (langchain.utilities.searx_search.SearxSearchWrapper attribute) SearxResults (class in langchain.utilities.searx_search) seed (langchain.embeddings.LlamaCppEmbeddings attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) select_examples() (langchain.prompts.example_selector.LengthBasedExampleSelector method) (langchain.prompts.example_selector.MaxMarginalRelevanceExampleSelector method) (langchain.prompts.example_selector.SemanticSimilarityExampleSelector method) SELF_ASK_WITH_SEARCH (langchain.agents.AgentType attribute) serpapi_api_key (langchain.serpapi.SerpAPIWrapper attribute) similarity_search() (langchain.vectorstores.AtlasDB method) (langchain.vectorstores.Chroma method) (langchain.vectorstores.DeepLake method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-31
(langchain.vectorstores.Chroma method) (langchain.vectorstores.DeepLake method) (langchain.vectorstores.ElasticVectorSearch method) (langchain.vectorstores.FAISS method) (langchain.vectorstores.Milvus method) (langchain.vectorstores.OpenSearchVectorSearch method) (langchain.vectorstores.Pinecone method) (langchain.vectorstores.Qdrant method) (langchain.vectorstores.VectorStore method) (langchain.vectorstores.Weaviate method) similarity_search_by_vector() (langchain.vectorstores.Chroma method) (langchain.vectorstores.FAISS method) (langchain.vectorstores.VectorStore method) similarity_search_with_score() (langchain.vectorstores.Chroma method) (langchain.vectorstores.FAISS method) (langchain.vectorstores.Milvus method) (langchain.vectorstores.Pinecone method) (langchain.vectorstores.Qdrant method) similarity_search_with_score_by_vector() (langchain.vectorstores.FAISS method) SpacyTextSplitter (class in langchain.text_splitter) split_documents() (langchain.text_splitter.TextSplitter method) split_text() (langchain.text_splitter.CharacterTextSplitter method) (langchain.text_splitter.NLTKTextSplitter method) (langchain.text_splitter.RecursiveCharacterTextSplitter method) (langchain.text_splitter.SpacyTextSplitter method) (langchain.text_splitter.TextSplitter method) (langchain.text_splitter.TokenTextSplitter method) sql_chain (langchain.chains.SQLDatabaseSequentialChain attribute) stop (langchain.agents.LLMSingleActionAgent attribute) (langchain.chains.PALChain attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) (langchain.llms.Writer attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-32
(langchain.llms.LlamaCpp attribute) (langchain.llms.Writer attribute) stop_sequences (langchain.llms.AlephAlpha attribute) stream() (langchain.llms.Anthropic method) (langchain.llms.AzureOpenAI method) (langchain.llms.OpenAI method) (langchain.llms.PromptLayerOpenAI method) streaming (langchain.llms.Anthropic attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.GPT4All attribute) (langchain.llms.OpenAIChat attribute) (langchain.llms.PromptLayerOpenAIChat attribute) strip_outputs (langchain.chains.SimpleSequentialChain attribute) suffix (langchain.llms.LlamaCpp attribute) (langchain.prompts.FewShotPromptTemplate attribute) (langchain.prompts.FewShotPromptWithTemplates attribute) T task (langchain.embeddings.HuggingFaceHubEmbeddings attribute) (langchain.llms.HuggingFaceEndpoint attribute) (langchain.llms.HuggingFaceHub attribute) (langchain.llms.SelfHostedHuggingFaceLLM attribute) temp (langchain.llms.GPT4All attribute) temperature (langchain.llms.AI21 attribute) (langchain.llms.AlephAlpha attribute) (langchain.llms.Anthropic attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.Cohere attribute) (langchain.llms.ForefrontAI attribute) (langchain.llms.GooseAI attribute) (langchain.llms.LlamaCpp attribute) (langchain.llms.NLPCloud attribute) (langchain.llms.Petals attribute) (langchain.llms.Writer attribute) template (langchain.prompts.PromptTemplate attribute) template_format (langchain.prompts.FewShotPromptTemplate attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-33
template_format (langchain.prompts.FewShotPromptTemplate attribute) (langchain.prompts.FewShotPromptWithTemplates attribute) (langchain.prompts.PromptTemplate attribute) text_length (langchain.chains.LLMRequestsChain attribute) text_splitter (langchain.chains.AnalyzeDocumentChain attribute) (langchain.chains.MapReduceChain attribute) (langchain.chains.QAGenerationChain attribute) TextSplitter (class in langchain.text_splitter) tokenizer (langchain.llms.Petals attribute) tokens (langchain.llms.AlephAlpha attribute) tokens_to_generate (langchain.llms.Writer attribute) TokenTextSplitter (class in langchain.text_splitter) tool() (in module langchain.agents) tool_run_logging_kwargs() (langchain.agents.Agent method) (langchain.agents.BaseSingleActionAgent method) (langchain.agents.LLMSingleActionAgent method) tools (langchain.agents.AgentExecutor attribute) (langchain.agents.MRKLChain attribute) (langchain.agents.ReActChain attribute) (langchain.agents.SelfAskWithSearchChain attribute) top_k (langchain.chains.SQLDatabaseChain attribute) (langchain.llms.AlephAlpha attribute) (langchain.llms.Anthropic attribute) (langchain.llms.ForefrontAI attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) (langchain.llms.NLPCloud attribute) (langchain.llms.Petals attribute) (langchain.llms.Writer attribute) top_k_docs_for_context (langchain.chains.ChatVectorDBChain attribute) top_p (langchain.llms.AlephAlpha attribute) (langchain.llms.Anthropic attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.ForefrontAI attribute)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-34
(langchain.llms.AzureOpenAI attribute) (langchain.llms.ForefrontAI attribute) (langchain.llms.GooseAI attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) (langchain.llms.NLPCloud attribute) (langchain.llms.Petals attribute) (langchain.llms.Writer attribute) topP (langchain.llms.AI21 attribute) transform (langchain.chains.TransformChain attribute) truncate (langchain.embeddings.CohereEmbeddings attribute) (langchain.llms.Cohere attribute) U unsecure (langchain.utilities.searx_search.SearxSearchWrapper attribute) update_forward_refs() (langchain.llms.AI21 class method) (langchain.llms.AlephAlpha class method) (langchain.llms.Anthropic class method) (langchain.llms.AzureOpenAI class method) (langchain.llms.Banana class method) (langchain.llms.CerebriumAI class method) (langchain.llms.Cohere class method) (langchain.llms.DeepInfra class method) (langchain.llms.ForefrontAI class method) (langchain.llms.GooseAI class method) (langchain.llms.GPT4All class method) (langchain.llms.HuggingFaceEndpoint class method) (langchain.llms.HuggingFaceHub class method) (langchain.llms.HuggingFacePipeline class method) (langchain.llms.LlamaCpp class method) (langchain.llms.Modal class method) (langchain.llms.NLPCloud class method) (langchain.llms.OpenAI class method) (langchain.llms.OpenAIChat class method) (langchain.llms.Petals class method) (langchain.llms.PromptLayerOpenAI class method)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-35
(langchain.llms.PromptLayerOpenAI class method) (langchain.llms.PromptLayerOpenAIChat class method) (langchain.llms.Replicate class method) (langchain.llms.SagemakerEndpoint class method) (langchain.llms.SelfHostedHuggingFaceLLM class method) (langchain.llms.SelfHostedPipeline class method) (langchain.llms.StochasticAI class method) (langchain.llms.Writer class method) use_mlock (langchain.embeddings.LlamaCppEmbeddings attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) use_multiplicative_presence_penalty (langchain.llms.AlephAlpha attribute) V validate_template (langchain.prompts.FewShotPromptTemplate attribute) (langchain.prompts.FewShotPromptWithTemplates attribute) (langchain.prompts.PromptTemplate attribute) VectorStore (class in langchain.vectorstores) vectorstore (langchain.chains.ChatVectorDBChain attribute) (langchain.chains.VectorDBQA attribute) (langchain.chains.VectorDBQAWithSourcesChain attribute) (langchain.prompts.example_selector.SemanticSimilarityExampleSelector attribute) verbose (langchain.agents.MRKLChain attribute) (langchain.agents.ReActChain attribute) (langchain.agents.SelfAskWithSearchChain attribute) (langchain.llms.AzureOpenAI attribute) (langchain.llms.OpenAI attribute) (langchain.llms.OpenAIChat attribute) vocab_only (langchain.embeddings.LlamaCppEmbeddings attribute) (langchain.llms.GPT4All attribute) (langchain.llms.LlamaCpp attribute) W Weaviate (class in langchain.vectorstores) Wikipedia (class in langchain.docstore) Z
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
1e1ddafb99a3-36
Wikipedia (class in langchain.docstore) Z ZERO_SHOT_REACT_DESCRIPTION (langchain.agents.AgentType attribute) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/genindex.html
def01e4517dc-0
Search Error Please activate JavaScript to enable the search functionality. Ctrl+K By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/search.html
1a18e84a5a85-0
.rst .pdf API References API References# All of LangChain’s reference documentation, in one place. Full documentation on all methods, classes, and APIs in LangChain. Prompts Utilities Chains Agents previous Integrations next Utilities By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/reference.html
e8a54cdcb1e2-0
.rst .pdf LangChain Ecosystem LangChain Ecosystem# Guides for how other companies/products can be used with LangChain AI21 Labs Aim Apify AtlasDB Banana CerebriumAI Chroma ClearML Integration Getting API Credentials Setting Up Scenario 1: Just an LLM Scenario 2: Creating a agent with tools Tips and Next Steps Cohere DeepInfra Deep Lake ForefrontAI Google Search Wrapper Google Serper Wrapper GooseAI GPT4All Graphsignal Hazy Research Helicone Hugging Face Jina Llama.cpp Milvus Modal NLPCloud OpenAI OpenSearch Petals PGVector Pinecone PromptLayer Qdrant Replicate Runhouse SearxNG Search API SerpAPI StochasticAI Unstructured Weights & Biases Weaviate Wolfram Alpha Wrapper Writer previous Agents next AI21 Labs By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/ecosystem.html
4e55088beee3-0
.md .pdf Glossary Contents Chain of Thought Prompting Action Plan Generation ReAct Prompting Self-ask Prompt Chaining Memetic Proxy Self Consistency Inception MemPrompt Glossary# This is a collection of terminology commonly used when developing LLM applications. It contains reference to external papers or sources where the concept was first introduced, as well as to places in LangChain where the concept is used. Chain of Thought Prompting# A prompting technique used to encourage the model to generate a series of intermediate reasoning steps. A less formal way to induce this behavior is to include “Let’s think step-by-step” in the prompt. Resources: Chain-of-Thought Paper Step-by-Step Paper Action Plan Generation# A prompt usage that uses a language model to generate actions to take. The results of these actions can then be fed back into the language model to generate a subsequent action. Resources: WebGPT Paper SayCan Paper ReAct Prompting# A prompting technique that combines Chain-of-Thought prompting with action plan generation. This induces the to model to think about what action to take, then take it. Resources: Paper LangChain Example Self-ask# A prompting method that builds on top of chain-of-thought prompting. In this method, the model explicitly asks itself follow-up questions, which are then answered by an external search engine. Resources: Paper LangChain Example Prompt Chaining# Combining multiple LLM calls together, with the output of one-step being the input to the next. Resources: PromptChainer Paper Language Model Cascades ICE Primer Book Socratic Models Memetic Proxy#
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/glossary.html
4e55088beee3-1
Language Model Cascades ICE Primer Book Socratic Models Memetic Proxy# Encouraging the LLM to respond in a certain way framing the discussion in a context that the model knows of and that will result in that type of response. For example, as a conversation between a student and a teacher. Resources: Paper Self Consistency# A decoding strategy that samples a diverse set of reasoning paths and then selects the most consistent answer. Is most effective when combined with Chain-of-thought prompting. Resources: Paper Inception# Also called “First Person Instruction”. Encouraging the model to think a certain way by including the start of the model’s response in the prompt. Resources: Example MemPrompt# MemPrompt maintains a memory of errors and user feedback, and uses them to prevent repetition of mistakes. Resources: Paper previous Writer next LangChain Gallery Contents Chain of Thought Prompting Action Plan Generation ReAct Prompting Self-ask Prompt Chaining Memetic Proxy Self Consistency Inception MemPrompt By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/glossary.html
fabd14f4341a-0
.rst .pdf LangChain Gallery Contents Open Source Misc. Colab Notebooks Proprietary LangChain Gallery# Lots of people have built some pretty awesome stuff with LangChain. This is a collection of our favorites. If you see any other demos that you think we should highlight, be sure to let us know! Open Source# HowDoI.ai This is an experiment in building a large-language-model-backed chatbot. It can hold a conversation, remember previous comments/questions, and answer all types of queries (history, web search, movie data, weather, news, and more). YouTube Transcription QA with Sources An end-to-end example of doing question answering on YouTube transcripts, returning the timestamps as sources to legitimize the answer. QA Slack Bot This application is a Slack Bot that uses Langchain and OpenAI’s GPT3 language model to provide domain specific answers. You provide the documents. ThoughtSource A central, open resource and community around data and tools related to chain-of-thought reasoning in large language models. LLM Strategy This Python package adds a decorator llm_strategy that connects to an LLM (such as OpenAI’s GPT-3) and uses the LLM to “implement” abstract methods in interface classes. It does this by forwarding requests to the LLM and converting the responses back to Python data using Python’s @dataclasses. Zero-Shot Corporate Lobbyist A notebook showing how to use GPT to help with the work of a corporate lobbyist. Dagster Documentation ChatBot A jupyter notebook demonstrating how you could create a semantic search engine on documents in one of your Google Folders Google Folder Semantic Search Build a GitHub support bot with GPT3, LangChain, and Python. Talk With Wind Record sounds of anything (birds, wind, fire, train station) and chat with it.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/gallery.html
fabd14f4341a-1
Record sounds of anything (birds, wind, fire, train station) and chat with it. ChatGPT LangChain This simple application demonstrates a conversational agent implemented with OpenAI GPT-3.5 and LangChain. When necessary, it leverages tools for complex math, searching the internet, and accessing news and weather. GPT Math Techniques A Hugging Face spaces project showing off the benefits of using PAL for math problems. GPT Political Compass Measure the political compass of GPT. Notion Database Question-Answering Bot Open source GitHub project shows how to use LangChain to create a chatbot that can answer questions about an arbitrary Notion database. LlamaIndex LlamaIndex (formerly GPT Index) is a project consisting of a set of data structures that are created using GPT-3 and can be traversed using GPT-3 in order to answer queries. Grover’s Algorithm Leveraging Qiskit, OpenAI and LangChain to demonstrate Grover’s algorithm QNimGPT A chat UI to play Nim, where a player can select an opponent, either a quantum computer or an AI ReAct TextWorld Leveraging the ReActTextWorldAgent to play TextWorld with an LLM! Fact Checker This repo is a simple demonstration of using LangChain to do fact-checking with prompt chaining. DocsGPT Answer questions about the documentation of any project Misc. Colab Notebooks# Wolfram Alpha in Conversational Agent Give ChatGPT a WolframAlpha neural implant Tool Updates in Agents Agent improvements (6th Jan 2023) Conversational Agent with Tools (Langchain AGI) Langchain AGI (23rd Dec 2022) Proprietary# Daimon A chat-based AI personal assistant with long-term memory about you.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/gallery.html
fabd14f4341a-2
Daimon A chat-based AI personal assistant with long-term memory about you. AI Assisted SQL Query Generator An app to write SQL using natural language, and execute against real DB. Clerkie Stack Tracing QA Bot to help debug complex stack tracing (especially the ones that go multi-function/file deep). Sales Email Writer By Raza Habib, this demo utilizes LangChain + SerpAPI + HumanLoop to write sales emails. Give it a company name and a person, this application will use Google Search (via SerpAPI) to get more information on the company and the person, and then write them a sales message. Question-Answering on a Web Browser By Zahid Khawaja, this demo utilizes question answering to answer questions about a given website. A followup added this for YouTube videos, and then another followup added it for Wikipedia. Mynd A journaling app for self-care that uses AI to uncover insights and patterns over time. previous Glossary next Deployments Contents Open Source Misc. Colab Notebooks Proprietary By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/gallery.html
8bb42fe3b009-0
.md .pdf Deployments Contents Streamlit Gradio (on Hugging Face) Beam Vercel SteamShip Langchain-serve Deployments# So you’ve made a really cool chain - now what? How do you deploy it and make it easily sharable with the world? This section covers several options for that. Note that these are meant as quick deployment options for prototypes and demos, and not for production systems. If you are looking for help with deployment of a production system, please contact us directly. What follows is a list of template GitHub repositories aimed that are intended to be very easy to fork and modify to use your chain. This is far from an exhaustive list of options, and we are EXTREMELY open to contributions here. Streamlit# This repo serves as a template for how to deploy a LangChain with Streamlit. It implements a chatbot interface. It also contains instructions for how to deploy this app on the Streamlit platform. Gradio (on Hugging Face)# This repo serves as a template for how deploy a LangChain with Gradio. It implements a chatbot interface, with a “Bring-Your-Own-Token” approach (nice for not wracking up big bills). It also contains instructions for how to deploy this app on the Hugging Face platform. This is heavily influenced by James Weaver’s excellent examples. Beam# This repo serves as a template for how deploy a LangChain with Beam. It implements a Question Answering app and contains instructions for deploying the app as a serverless REST API. Vercel# A minimal example on how to run LangChain on Vercel using Flask. SteamShip# This repository contains LangChain adapters for Steamship, enabling LangChain developers to rapidly deploy their apps on Steamship.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/deployments.html
8bb42fe3b009-1
This includes: production ready endpoints, horizontal scaling across dependencies, persistant storage of app state, multi-tenancy support, etc. Langchain-serve# This repository allows users to serve local chains and agents as RESTful, gRPC, or Websocket APIs thanks to Jina. Deploy your chains & agents with ease and enjoy independent scaling, serverless and autoscaling APIs, as well as a Streamlit playground on Jina AI Cloud. previous LangChain Gallery next Tracing Contents Streamlit Gradio (on Hugging Face) Beam Vercel SteamShip Langchain-serve By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/deployments.html
0775e1d99a11-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 version of this (uses Docker) or a cloud hosted version (in closed alpha). If you’re interested in using the hosted platform, please fill out the form here. Locally Hosted Setup Cloud Hosted Setup Tracing Walkthrough# When you first access the UI, you should see a page with your tracing sessions. An initial one “default” should already be created for you. A session is just a way to group traces together. If you click on a session, it will take you to a page with no recorded traces that says “No Runs.” You can create a new session with the new session form. If we click on the default session, we can see that to start we have no traces stored. If we now start running chains and agents with tracing enabled, we will see data show up here. To do so, we can run this notebook as an example. After running it, we will see an initial trace show up. From here we can explore the trace at a high level by clicking on the arrow to show nested runs. We can keep on clicking further and further down to explore deeper and deeper. We can also click on the “Explore” button of the top level run to dive even deeper. Here, we can see the inputs and outputs in full, as well as all the nested traces. We can keep on exploring each of these nested traces in more detail. For example, here is the lowest level trace with the exact inputs/outputs to the LLM. Changing Sessions#
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/tracing.html
0775e1d99a11-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_HANDLER"] = "langchain" os.environ["LANGCHAIN_SESSION"] = "my_session" # Make sure this session actually exists. You can create a new session in the UI. To switch sessions mid-script or mid-notebook, do NOT set the LANGCHAIN_SESSION environment variable. Instead: langchain.set_tracing_callback_manager(session_name="my_session") previous Deployments Contents Tracing Walkthrough Changing Sessions By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/tracing.html
faf2021d0f22-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. LangChain provides the concept of a ModelLaboratory to test out and try different models. from langchain import LLMChain, OpenAI, Cohere, HuggingFaceHub, PromptTemplate from langchain.model_laboratory import ModelLaboratory llms = [ OpenAI(temperature=0), Cohere(model="command-xlarge-20221108", max_tokens=20, temperature=0), HuggingFaceHub(repo_id="google/flan-t5-xl", model_kwargs={"temperature":1}) ] model_lab = ModelLaboratory.from_llms(llms) model_lab.compare("What color is a flamingo?") Input: What color is a flamingo? OpenAI Params: {'model': 'text-davinci-002', 'temperature': 0.0, 'max_tokens': 256, 'top_p': 1, 'frequency_penalty': 0, 'presence_penalty': 0, 'n': 1, 'best_of': 1} Flamingos are pink. Cohere Params: {'model': 'command-xlarge-20221108', 'max_tokens': 20, 'temperature': 0.0, 'k': 0, 'p': 1, 'frequency_penalty': 0, 'presence_penalty': 0} Pink HuggingFaceHub Params: {'repo_id': 'google/flan-t5-xl', 'temperature': 1} pink
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/model_laboratory.html
faf2021d0f22-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': 1, 'frequency_penalty': 0, 'presence_penalty': 0, 'n': 1, 'best_of': 1} The capital of New York is Albany. Cohere Params: {'model': 'command-xlarge-20221108', 'max_tokens': 20, 'temperature': 0.0, 'k': 0, 'p': 1, 'frequency_penalty': 0, 'presence_penalty': 0} The capital of New York is Albany. HuggingFaceHub Params: {'repo_id': 'google/flan-t5-xl', 'temperature': 1} st john s from langchain import SelfAskWithSearchChain, SerpAPIWrapper open_ai_llm = OpenAI(temperature=0) search = SerpAPIWrapper() self_ask_with_search_openai = SelfAskWithSearchChain(llm=open_ai_llm, search_chain=search, verbose=True) cohere_llm = Cohere(temperature=0, model="command-xlarge-20221108") search = SerpAPIWrapper() self_ask_with_search_cohere = SelfAskWithSearchChain(llm=cohere_llm, search_chain=search, verbose=True) chains = [self_ask_with_search_openai, self_ask_with_search_cohere] names = [str(open_ai_llm), str(cohere_llm)]
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/model_laboratory.html
faf2021d0f22-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_tokens': 256, 'top_p': 1, 'frequency_penalty': 0, 'presence_penalty': 0, 'n': 1, 'best_of': 1} > Entering new chain... What is the hometown of the reigning men's U.S. Open champion? Are follow up questions needed here: Yes. Follow up: Who is the reigning men's U.S. Open champion? Intermediate answer: Carlos Alcaraz. Follow up: Where is Carlos Alcaraz from? Intermediate answer: El Palmar, Spain. So the final answer is: El Palmar, Spain > Finished chain. So the final answer is: El Palmar, Spain Cohere Params: {'model': 'command-xlarge-20221108', 'max_tokens': 256, 'temperature': 0.0, 'k': 0, 'p': 1, 'frequency_penalty': 0, 'presence_penalty': 0} > Entering new chain... What is the hometown of the reigning men's U.S. Open champion? Are follow up questions needed here: Yes. Follow up: Who is the reigning men's U.S. Open champion? Intermediate answer: Carlos Alcaraz. So the final answer is: Carlos Alcaraz > Finished chain. So the final answer is: Carlos Alcaraz By Harrison Chase
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/model_laboratory.html
faf2021d0f22-3
So the final answer is: Carlos Alcaraz By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/model_laboratory.html
321c3fc21769-0
.md .pdf Quickstart Guide Contents Installation Environment Setup Building a Language Model Application: LLMs Building a Language Model Application: Chat Models Quickstart Guide# This tutorial gives you a quick walkthrough about building an end-to-end language model application with LangChain. Installation# To get started, install LangChain with the following command: pip install langchain Environment Setup# Using LangChain will usually require integrations with one or more model providers, data stores, apis, etc. For this example, we will be using OpenAI’s APIs, so we will first need to install their SDK: pip install openai We will then need to set the environment variable in the terminal. export OPENAI_API_KEY="..." Alternatively, you could do this from inside the Jupyter notebook (or Python script): import os os.environ["OPENAI_API_KEY"] = "..." Building a Language Model Application: LLMs# Now that we have installed LangChain and set up our environment, we can start building our language model application. LangChain provides many modules that can be used to build language model applications. Modules can be combined to create more complex applications, or be used individually for simple applications. LLMs: Get predictions from a language model The most basic building block of LangChain is calling an LLM on some input. Let’s walk through a simple example of how to do this. For this purpose, let’s pretend we are building a service that generates a company name based on what the company makes. In order to do this, we first need to import the LLM wrapper. from langchain.llms import OpenAI We can then initialize the wrapper with any arguments. In this example, we probably want the outputs to be MORE random, so we’ll initialize it with a HIGH temperature.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
321c3fc21769-1
llm = OpenAI(temperature=0.9) We can now call it on some input! text = "What would be a good company name for a company that makes colorful socks?" print(llm(text)) Feetful of Fun For more details on how to use LLMs within LangChain, see the LLM getting started guide. Prompt Templates: Manage prompts for LLMs Calling an LLM is a great first step, but it’s just the beginning. Normally when you use an LLM in an application, you are not sending user input directly to the LLM. Instead, you are probably taking user input and constructing a prompt, and then sending that to the LLM. For example, in the previous example, the text we passed in was hardcoded to ask for a name for a company that made colorful socks. In this imaginary service, what we would want to do is take only the user input describing what the company does, and then format the prompt with that information. This is easy to do with LangChain! First lets define the prompt template: from langchain.prompts import PromptTemplate prompt = PromptTemplate( input_variables=["product"], template="What is a good name for a company that makes {product}?", ) Let’s now see how this works! We can call the .format method to format it. print(prompt.format(product="colorful socks")) What is a good name for a company that makes colorful socks? For more details, check out the getting started guide for prompts. Chains: Combine LLMs and prompts in multi-step workflows Up until now, we’ve worked with the PromptTemplate and LLM primitives by themselves. But of course, a real application is not just one primitive, but rather a combination of them.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
321c3fc21769-2
A chain in LangChain is made up of links, which can be either primitives like LLMs or other chains. The most core type of chain is an LLMChain, which consists of a PromptTemplate and an LLM. Extending the previous example, we can construct an LLMChain which takes user input, formats it with a PromptTemplate, and then passes the formatted response to an LLM. from langchain.prompts import PromptTemplate from langchain.llms import OpenAI llm = OpenAI(temperature=0.9) prompt = PromptTemplate( input_variables=["product"], template="What is a good name for a company that makes {product}?", ) We can now create a very simple chain that will take user input, format the prompt with it, and then send it to the LLM: from langchain.chains import LLMChain chain = LLMChain(llm=llm, prompt=prompt) Now we can run that chain only specifying the product! chain.run("colorful socks") # -> '\n\nSocktastic!' There we go! There’s the first chain - an LLM Chain. This is one of the simpler types of chains, but understanding how it works will set you up well for working with more complex chains. For more details, check out the getting started guide for chains. Agents: Dynamically Call Chains Based on User Input So far the chains we’ve looked at run in a predetermined order. Agents no longer do: they use an LLM to determine which actions to take and in what order. An action can either be using a tool and observing its output, or returning to the user. When used correctly agents can be extremely powerful. In this tutorial, we show you how to easily use agents through the simplest, highest level API.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
321c3fc21769-3
In order to load agents, you should understand the following concepts: Tool: A function that performs a specific duty. This can be things like: Google Search, Database lookup, Python REPL, other chains. The interface for a tool is currently a function that is expected to have a string as an input, with a string as an output. LLM: The language model powering the agent. Agent: The agent to use. This should be a string that references a support agent class. Because this notebook focuses on the simplest, highest level API, this only covers using the standard supported agents. If you want to implement a custom agent, see the documentation for custom agents (coming soon). Agents: For a list of supported agents and their specifications, see here. Tools: For a list of predefined tools and their specifications, see here. For this example, you will also need to install the SerpAPI Python package. pip install google-search-results And set the appropriate environment variables. import os os.environ["SERPAPI_API_KEY"] = "..." Now we can get started! from langchain.agents import load_tools from langchain.agents import initialize_agent from langchain.agents import AgentType from langchain.llms import OpenAI # First, let's load the language model we're going to use to control the agent. llm = OpenAI(temperature=0) # Next, let's load some tools to use. Note that the `llm-math` tool uses an LLM, so we need to pass that in. tools = load_tools(["serpapi", "llm-math"], llm=llm) # Finally, let's initialize an agent with the tools, the language model, and the type of agent we want to use.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
321c3fc21769-4
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) # Now let's test it out! agent.run("What was the high temperature in SF yesterday in Fahrenheit? What is that number raised to the .023 power?") > Entering new AgentExecutor chain... I need to find the temperature first, then use the calculator to raise it to the .023 power. Action: Search Action Input: "High temperature in SF yesterday" Observation: San Francisco Temperature Yesterday. Maximum temperature yesterday: 57 °F (at 1:56 pm) Minimum temperature yesterday: 49 °F (at 1:56 am) Average temperature ... Thought: I now have the temperature, so I can use the calculator to raise it to the .023 power. Action: Calculator Action Input: 57^.023 Observation: Answer: 1.0974509573251117 Thought: I now know the final answer Final Answer: The high temperature in SF yesterday in Fahrenheit raised to the .023 power is 1.0974509573251117. > Finished chain. Memory: Add State to Chains and Agents So far, all the chains and agents we’ve gone through have been stateless. But often, you may want a chain or agent to have some concept of “memory” so that it may remember information about its previous interactions. The clearest and simple example of this is when designing a chatbot - you want it to remember previous messages so it can use context from that to have a better conversation. This would be a type of “short-term memory”. On the more complex side, you could imagine a chain/agent remembering key pieces of information over time - this would be a form of “long-term memory”. For more concrete ideas on the latter, see this awesome paper.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
321c3fc21769-5
LangChain provides several specially created chains just for this purpose. This notebook walks through using one of those chains (the ConversationChain) with two different types of memory. By default, the ConversationChain has a simple type of memory that remembers all previous inputs/outputs and adds them to the context that is passed. Let’s take a look at using this chain (setting verbose=True so we can see the prompt). from langchain import OpenAI, ConversationChain llm = OpenAI(temperature=0) conversation = ConversationChain(llm=llm, verbose=True) conversation.predict(input="Hi there!") > Entering new chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation: Human: Hi there! AI: > Finished chain. ' Hello! How are you today?' conversation.predict(input="I'm doing well! Just having a conversation with an AI.") > Entering new chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation: Human: Hi there! AI: Hello! How are you today? Human: I'm doing well! Just having a conversation with an AI. AI: > Finished chain. " That's great! What would you like to talk about?" Building a Language Model Application: Chat Models#
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
321c3fc21769-6
Building a Language Model Application: Chat Models# Similarly, you can use chat models instead of LLMs. Chat models are a variation on language models. While chat models use language models under the hood, the interface they expose is a bit different: rather than expose a “text in, text out” API, they expose an interface where “chat messages” are the inputs and outputs. Chat model APIs are fairly new, so we are still figuring out the correct abstractions. Get Message Completions from a Chat Model You can get chat completions by passing one or more messages to the chat model. The response will be a message. The types of messages currently supported in LangChain are AIMessage, HumanMessage, SystemMessage, and ChatMessage – ChatMessage takes in an arbitrary role parameter. Most of the time, you’ll just be dealing with HumanMessage, AIMessage, and SystemMessage. from langchain.chat_models import ChatOpenAI from langchain.schema import ( AIMessage, HumanMessage, SystemMessage ) chat = ChatOpenAI(temperature=0) You can get completions by passing in a single message. chat([HumanMessage(content="Translate this sentence from English to French. I love programming.")]) # -> AIMessage(content="J'aime programmer.", additional_kwargs={}) You can also pass in multiple messages for OpenAI’s gpt-3.5-turbo and gpt-4 models. messages = [ SystemMessage(content="You are a helpful assistant that translates English to French."), HumanMessage(content="Translate this sentence from English to French. I love programming.") ] chat(messages) # -> AIMessage(content="J'aime programmer.", additional_kwargs={}) You can go one step further and generate completions for multiple sets of messages using generate. This returns an LLMResult with an additional message parameter:
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
321c3fc21769-7
batch_messages = [ [ SystemMessage(content="You are a helpful assistant that translates English to French."), HumanMessage(content="Translate this sentence from English to French. I love programming.") ], [ SystemMessage(content="You are a helpful assistant that translates English to French."), HumanMessage(content="Translate this sentence from English to French. I love artificial intelligence.") ], ] result = chat.generate(batch_messages) result # -> LLMResult(generations=[[ChatGeneration(text="J'aime programmer.", generation_info=None, message=AIMessage(content="J'aime programmer.", additional_kwargs={}))], [ChatGeneration(text="J'aime l'intelligence artificielle.", generation_info=None, message=AIMessage(content="J'aime l'intelligence artificielle.", additional_kwargs={}))]], llm_output={'token_usage': {'prompt_tokens': 71, 'completion_tokens': 18, 'total_tokens': 89}}) You can recover things like token usage from this LLMResult: result.llm_output['token_usage'] # -> {'prompt_tokens': 71, 'completion_tokens': 18, 'total_tokens': 89} Chat Prompt Templates Similar to LLMs, you can make use of templating by using a MessagePromptTemplate. You can build a ChatPromptTemplate from one or more MessagePromptTemplates. You can use ChatPromptTemplate’s format_prompt – this returns a PromptValue, which you can convert to a string or Message object, depending on whether you want to use the formatted value as input to an llm or chat model. For convience, there is a from_template method exposed on the template. If you were to use this template, this is what it would look like: from langchain.chat_models import ChatOpenAI from langchain.prompts.chat import ( ChatPromptTemplate,
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
321c3fc21769-8
from langchain.prompts.chat import ( ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate, ) chat = ChatOpenAI(temperature=0) template="You are a helpful assistant that translates {input_language} to {output_language}." system_message_prompt = SystemMessagePromptTemplate.from_template(template) human_template="{text}" human_message_prompt = HumanMessagePromptTemplate.from_template(human_template) chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt]) # get a chat completion from the formatted messages chat(chat_prompt.format_prompt(input_language="English", output_language="French", text="I love programming.").to_messages()) # -> AIMessage(content="J'aime programmer.", additional_kwargs={}) Chains with Chat Models The LLMChain discussed in the above section can be used with chat models as well: from langchain.chat_models import ChatOpenAI from langchain import LLMChain from langchain.prompts.chat import ( ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate, ) chat = ChatOpenAI(temperature=0) template="You are a helpful assistant that translates {input_language} to {output_language}." system_message_prompt = SystemMessagePromptTemplate.from_template(template) human_template="{text}" human_message_prompt = HumanMessagePromptTemplate.from_template(human_template) chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt]) chain = LLMChain(llm=chat, prompt=chat_prompt) chain.run(input_language="English", output_language="French", text="I love programming.") # -> "J'aime programmer." Agents with Chat Models Agents can also be used with chat models, you can initialize one using AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION as the agent type.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
321c3fc21769-9
from langchain.agents import load_tools from langchain.agents import initialize_agent from langchain.agents import AgentType from langchain.chat_models import ChatOpenAI from langchain.llms import OpenAI # First, let's load the language model we're going to use to control the agent. chat = ChatOpenAI(temperature=0) # Next, let's load some tools to use. Note that the `llm-math` tool uses an LLM, so we need to pass that in. llm = OpenAI(temperature=0) tools = load_tools(["serpapi", "llm-math"], llm=llm) # Finally, let's initialize an agent with the tools, the language model, and the type of agent we want to use. agent = initialize_agent(tools, chat, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True) # Now let's test it out! agent.run("Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?") > Entering new AgentExecutor chain... Thought: I need to use a search engine to find Olivia Wilde's boyfriend and a calculator to raise his age to the 0.23 power. Action: { "action": "Search", "action_input": "Olivia Wilde boyfriend" } Observation: Sudeikis and Wilde's relationship ended in November 2020. Wilde was publicly served with court documents regarding child custody while she was presenting Don't Worry Darling at CinemaCon 2022. In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Thought:I need to use a search engine to find Harry Styles' current age. Action: { "action": "Search",
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
321c3fc21769-10
Action: { "action": "Search", "action_input": "Harry Styles age" } Observation: 29 years Thought:Now I need to calculate 29 raised to the 0.23 power. Action: { "action": "Calculator", "action_input": "29^0.23" } Observation: Answer: 2.169459462491557 Thought:I now know the final answer. Final Answer: 2.169459462491557 > Finished chain. '2.169459462491557' Memory: Add State to Chains and Agents You can use Memory with chains and agents initialized with chat models. The main difference between this and Memory for LLMs is that rather than trying to condense all previous messages into a string, we can keep them as their own unique memory object. from langchain.prompts import ( ChatPromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate, HumanMessagePromptTemplate ) from langchain.chains import ConversationChain from langchain.chat_models import ChatOpenAI from langchain.memory import ConversationBufferMemory prompt = ChatPromptTemplate.from_messages([ SystemMessagePromptTemplate.from_template("The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know."), MessagesPlaceholder(variable_name="history"), HumanMessagePromptTemplate.from_template("{input}") ]) llm = ChatOpenAI(temperature=0) memory = ConversationBufferMemory(return_messages=True) conversation = ConversationChain(memory=memory, prompt=prompt, llm=llm) conversation.predict(input="Hi there!")
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
321c3fc21769-11
conversation.predict(input="Hi there!") # -> 'Hello! How can I assist you today?' conversation.predict(input="I'm doing well! Just having a conversation with an AI.") # -> "That sounds like fun! I'm happy to chat with you. Is there anything specific you'd like to talk about?" conversation.predict(input="Tell me about yourself.") # -> "Sure! I am an AI language model created by OpenAI. I was trained on a large dataset of text from the internet, which allows me to understand and generate human-like language. I can answer questions, provide information, and even have conversations like this one. Is there anything else you'd like to know about me?" previous Welcome to LangChain next Models Contents Installation Environment Setup Building a Language Model Application: LLMs Building a Language Model Application: Chat Models By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/getting_started/getting_started.html
1edb18876dbb-0
.rst .pdf Models Contents Go Deeper Models# Note Conceptual Guide This section of the documentation deals with different types of models that are used in LangChain. On this page we will go over the model types at a high level, but we have individual pages for each model type. The pages contain more detailed “how-to” guides for working with that model, as well as a list of different model providers. LLMs Large Language Models (LLMs) are the first type of models we cover. These models take a text string as input, and return a text string as output. Chat Models Chat Models are the second type of models we cover. These models are usually backed by a language model, but their APIs are more structured. Specifically, these models take a list of Chat Messages as input, and return a Chat Message. Text Embedding Models The third type of models we cover are text embedding models. These models take text as input and return a list of floats. Go Deeper# LLMs Chat Models Text Embedding Models previous Quickstart Guide next LLMs Contents Go Deeper By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models.html
2f5ac5adc1eb-0
.rst .pdf Prompts Contents Go Deeper Prompts# Note Conceptual Guide The new way of programming models is through prompts. A “prompt” refers to the input to the model. This input is rarely hard coded, but rather is often constructed from multiple components. A PromptTemplate is responsible for the construction of this input. LangChain provides several classes and functions to make constructing and working with prompts easy. This section of documentation is split into four sections: LLM Prompt Templates How to use PromptTemplates to prompt Language Models. Chat Prompt Templates How to use PromptTemplates to prompt Chat Models. Example Selectors Often times it is useful to include examples in prompts. These examples can be hardcoded, but it is often more powerful if they are dynamically selected. This section goes over example selection. Output Parsers Language models (and Chat Models) output text. But many times you may want to get more structured information than just text back. This is where output parsers come in. Output Parsers are responsible for (1) instructing the model how output should be formatted, (2) parsing output into the desired formatting (including retrying if necessary). Go Deeper# Prompt Templates Chat Prompt Template Example Selectors Output Parsers previous TensorflowHub next Prompt Templates Contents Go Deeper By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/prompts.html
610d8f632207-0
.rst .pdf Indexes Contents Go Deeper Indexes# Note Conceptual Guide Indexes refer to ways to structure documents so that LLMs can best interact with them. This module contains utility functions for working with documents, different types of indexes, and then examples for using those indexes in chains. The most common way that indexes are used in chains is in a “retrieval” step. This step refers to taking a user’s query and returning the most relevant documents. We draw this distinction because (1) an index can be used for other things besides retrieval, and (2) retrieval can use other logic besides an index to find relevant documents. We therefor have a concept of a “Retriever” interface - this is the interface that most chains work with. Most of the time when we talk about indexes and retrieval we are talking about indexing and retrieving unstructured data (like text documents). For interacting with structured data (SQL tables, etc) or APIs, please see the corresponding use case sections for links to relevant functionality. The primary index and retrieval types supported by LangChain are currently centered around vector databases, and therefore a lot of the functionality we dive deep on those topics. For an overview of everything related to this, please see the below notebook for getting started: Getting Started We then provide a deep dive on the four main components. Document Loaders How to load documents from a variety of sources. Text Splitters An overview of the abstractions and implementions around splitting text. VectorStores An overview of VectorStores and the many integrations LangChain provides. Retrievers An overview of Retrievers and the implementations LangChain provides. Go Deeper# Document Loaders Text Splitters Vectorstores Retrievers previous Structured Output Parser next Getting Started Contents Go Deeper
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/indexes.html
610d8f632207-1
previous Structured Output Parser next Getting Started Contents Go Deeper By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/indexes.html
20ee4b212749-0
.rst .pdf Memory Memory# Note Conceptual Guide By default, Chains and Agents are stateless, meaning that they treat each incoming query independently (as are the underlying LLMs and chat models). In some applications (chatbots being a GREAT example) it is highly important to remember previous interactions, both at a short term but also at a long term level. The concept of “Memory” exists to do exactly that. LangChain provides memory components in two forms. First, LangChain provides helper utilities for managing and manipulating previous chat messages. These are designed to be modular and useful regardless of how they are used. Secondly, LangChain provides easy ways to incorporate these utilities into chains. The following sections of documentation are provided: Getting Started: An overview of how to get started with different types of memory. How-To Guides: A collection of how-to guides. These highlight different types of memory, as well as how to use memory in chains. Memory Getting Started How-To Guides previous VectorStore Retriever next Getting Started By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/memory.html
aea75e43c546-0
.rst .pdf Chains Chains# Note Conceptual Guide Using an LLM in isolation is fine for some simple applications, but many more complex ones require chaining LLMs - either with each other or with other experts. LangChain provides a standard interface for Chains, as well as some common implementations of chains for ease of use. The following sections of documentation are provided: Getting Started: A getting started guide for chains, to get you up and running quickly. How-To Guides: A collection of how-to guides. These highlight how to use various types of chains. Reference: API reference documentation for all Chain classes. previous Redis Chat Message History next Getting Started By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/chains.html
e99cc6ad2995-0
.rst .pdf Agents Contents Go Deeper Agents# Note Conceptual Guide Some applications will require not just a predetermined chain of calls to LLMs/other tools, but potentially an unknown chain that depends on the user’s input. In these types of chains, there is a “agent” which has access to a suite of tools. Depending on the user input, the agent can then decide which, if any, of these tools to call. In this section of documentation, we first start with a Getting Started notebook to cover how to use all things related to agents in an end-to-end manner. We then split the documentation into the following sections: Tools An overview of the various tools LangChain supports. Agents An overview of the different agent types. Toolkits An overview of toolkits, and examples of the different ones LangChain supports. Agent Executor An overview of the Agent Executor class and examples of how to use it. Go Deeper# Tools Agents Toolkits Agent Executors previous Chains next Getting Started Contents Go Deeper By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/agents.html
2b34bad144f5-0
.rst .pdf LLMs LLMs# Note Conceptual Guide Large Language Models (LLMs) are a core component of LangChain. LangChain is not a provider of LLMs, but rather provides a standard interface through which you can interact with a variety of LLMs. The following sections of documentation are provided: Getting Started: An overview of all the functionality the LangChain LLM class provides. How-To Guides: A collection of how-to guides. These highlight how to accomplish various objectives with our LLM class (streaming, async, etc). Integrations: A collection of examples on how to integrate different LLM providers with LangChain (OpenAI, Hugging Face, etc). Reference: API reference documentation for all LLM classes. previous Models next Getting Started By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms.html
77ca23f29076-0
.rst .pdf Chat Models Chat Models# Note Conceptual Guide Chat models are a variation on language models. While chat models use language models under the hood, the interface they expose is a bit different. Rather than expose a “text in, text out” API, they expose an interface where “chat messages” are the inputs and outputs. Chat model APIs are fairly new, so we are still figuring out the correct abstractions. The following sections of documentation are provided: Getting Started: An overview of all the functionality the LangChain LLM class provides. How-To Guides: A collection of how-to guides. These highlight how to accomplish various objectives with our LLM class (streaming, async, etc). Integrations: A collection of examples on how to integrate different LLM providers with LangChain (OpenAI, Hugging Face, etc). previous LLMs next Getting Started By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/chat.html
8a4c0a4169c0-0
.rst .pdf Text Embedding Models Text Embedding Models# Note Conceptual Guide This documentation goes over how to use the Embedding class in LangChain. The Embedding class is a class designed for interfacing with embeddings. There are lots of Embedding providers (OpenAI, Cohere, Hugging Face, etc) - this class is designed to provide a standard interface for all of them. Embeddings create a vector representation of a piece of text. This is useful because it means we can think about text in the vector space, and do things like semantic search where we look for pieces of text that are most similar in the vector space. The base Embedding class in LangChain exposes two methods: embed_documents and embed_query. The largest difference is that these two methods have different interfaces: one works over multiple documents, while the other works over a single document. Besides this, another reason for having these as two separate methods is that some embedding providers have different embedding methods for documents (to be searched over) vs queries (the search query itself). The following integrations exist for text embeddings. Aleph Alpha AzureOpenAI Cohere Fake Embeddings Hugging Face Hub InstructEmbeddings Jina Llama-cpp OpenAI SageMaker Endpoint Embeddings Self Hosted Embeddings TensorflowHub previous PromptLayer ChatOpenAI next Aleph Alpha By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/text_embedding.html
b1a820342d3e-0
.ipynb .pdf Getting Started Getting Started# This notebook goes over how to use the LLM class in LangChain. The LLM class is a class designed for interfacing with LLMs. There are lots of LLM providers (OpenAI, Cohere, Hugging Face, etc) - this class is designed to provide a standard interface for all of them. In this part of the documentation, we will focus on generic LLM functionality. For details on working with a specific LLM wrapper, please see the examples in the How-To section. For this notebook, we will work with an OpenAI LLM wrapper, although the functionalities highlighted are generic for all LLM types. from langchain.llms import OpenAI llm = OpenAI(model_name="text-ada-001", n=2, best_of=2) Generate Text: The most basic functionality an LLM has is just the ability to call it, passing in a string and getting back a string. llm("Tell me a joke") '\n\nWhy did the chicken cross the road?\n\nTo get to the other side.' Generate: More broadly, you can call it with a list of inputs, getting back a more complete response than just the text. This complete response includes things like multiple top responses, as well as LLM provider specific information llm_result = llm.generate(["Tell me a joke", "Tell me a poem"]*15) len(llm_result.generations) 30 llm_result.generations[0] [Generation(text='\n\nWhy did the chicken cross the road?\n\nTo get to the other side!'), Generation(text='\n\nWhy did the chicken cross the road?\n\nTo get to the other side.')] llm_result.generations[-1]
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/getting_started.html
b1a820342d3e-1
llm_result.generations[-1] [Generation(text="\n\nWhat if love neverspeech\n\nWhat if love never ended\n\nWhat if love was only a feeling\n\nI'll never know this love\n\nIt's not a feeling\n\nBut it's what we have for each other\n\nWe just know that love is something strong\n\nAnd we can't help but be happy\n\nWe just feel what love is for us\n\nAnd we love each other with all our heart\n\nWe just don't know how\n\nHow it will go\n\nBut we know that love is something strong\n\nAnd we'll always have each other\n\nIn our lives."), Generation(text='\n\nOnce upon a time\n\nThere was a love so pure and true\n\nIt lasted for centuries\n\nAnd never became stale or dry\n\nIt was moving and alive\n\nAnd the heart of the love-ick\n\nIs still beating strong and true.')] You can also access provider specific information that is returned. This information is NOT standardized across providers. llm_result.llm_output {'token_usage': {'completion_tokens': 3903, 'total_tokens': 4023, 'prompt_tokens': 120}} Number of Tokens: You can also estimate how many tokens a piece of text will be in that model. This is useful because models have a context length (and cost more for more tokens), which means you need to be aware of how long the text you are passing in is. Notice that by default the tokens are estimated using a HuggingFace tokenizer. llm.get_num_tokens("what a joke") 3 previous LLMs next Generic Functionality By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/getting_started.html
4a558a82bf39-0
.rst .pdf Generic Functionality Generic Functionality# The examples here all address certain “how-to” guides for working with LLMs. How to use the async API for LLMs How to write a custom LLM wrapper How (and why) to use the fake LLM How to cache LLM calls How to serialize LLM classes How to stream LLM and Chat Model responses How to track token usage previous Getting Started next How to use the async API for LLMs By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/how_to_guides.html
e1db37c17139-0
.rst .pdf Integrations Integrations# The examples here are all “how-to” guides for how to integrate with various LLM providers. AI21 Aleph Alpha Anthropic Azure OpenAI LLM Example Banana CerebriumAI LLM Example Cohere DeepInfra LLM Example ForefrontAI LLM Example GooseAI LLM Example GPT4all Hugging Face Hub Llama-cpp Manifest Modal OpenAI Petals LLM Example PromptLayer OpenAI Replicate SageMakerEndpoint Self-Hosted Models via Runhouse StochasticAI Writer previous How to track token usage next AI21 By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/integrations.html
be66d16908cb-0
.ipynb .pdf How to use the async API for LLMs How to use the async API for LLMs# LangChain provides async support for LLMs by leveraging the asyncio library. Async support is particularly useful for calling multiple LLMs concurrently, as these calls are network-bound. Currently, OpenAI, PromptLayerOpenAI, ChatOpenAI and Anthropic are supported, but async support for other LLMs is on the roadmap. You can use the agenerate method to call an OpenAI LLM asynchronously. import time import asyncio from langchain.llms import OpenAI def generate_serially(): llm = OpenAI(temperature=0.9) for _ in range(10): resp = llm.generate(["Hello, how are you?"]) print(resp.generations[0][0].text) async def async_generate(llm): resp = await llm.agenerate(["Hello, how are you?"]) print(resp.generations[0][0].text) async def generate_concurrently(): llm = OpenAI(temperature=0.9) tasks = [async_generate(llm) for _ in range(10)] await asyncio.gather(*tasks) s = time.perf_counter() # If running this outside of Jupyter, use asyncio.run(generate_concurrently()) await generate_concurrently() elapsed = time.perf_counter() - s print('\033[1m' + f"Concurrent executed in {elapsed:0.2f} seconds." + '\033[0m') s = time.perf_counter() generate_serially() elapsed = time.perf_counter() - s print('\033[1m' + f"Serial executed in {elapsed:0.2f} seconds." + '\033[0m')
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/async_llm.html
be66d16908cb-1
I'm doing well, thank you. How about you? I'm doing well, thank you. How about you? I'm doing well, how about you? I'm doing well, thank you. How about you? I'm doing well, thank you. How about you? I'm doing well, thank you. How about yourself? I'm doing well, thank you! How about you? I'm doing well, thank you. How about you? I'm doing well, thank you! How about you? I'm doing well, thank you. How about you? Concurrent executed in 1.39 seconds. I'm doing well, thank you. How about you? I'm doing well, thank you. How about you? I'm doing well, thank you. How about you? I'm doing well, thank you. How about you? I'm doing well, thank you. How about yourself? I'm doing well, thanks for asking. How about you? I'm doing well, thanks! How about you? I'm doing well, thank you. How about you? I'm doing well, thank you. How about yourself? I'm doing well, thanks for asking. How about you? Serial executed in 5.77 seconds. previous Generic Functionality next How to write a custom LLM wrapper By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/async_llm.html
9149c720a568-0
.ipynb .pdf How to write a custom LLM wrapper How to write a custom LLM wrapper# This notebook goes over how to create a custom LLM wrapper, in case you want to use your own LLM or a different wrapper than one that is supported in LangChain. There is only one required thing that a custom LLM needs to implement: A _call method that takes in a string, some optional stop words, and returns a string There is a second optional thing it can implement: An _identifying_params property that is used to help with printing of this class. Should return a dictionary. Let’s implement a very simple custom LLM that just returns the first N characters of the input. from langchain.llms.base import LLM from typing import Optional, List, Mapping, Any class CustomLLM(LLM): n: int @property def _llm_type(self) -> str: return "custom" def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str: if stop is not None: raise ValueError("stop kwargs are not permitted.") return prompt[:self.n] @property def _identifying_params(self) -> Mapping[str, Any]: """Get the identifying parameters.""" return {"n": self.n} We can now use this as an any other LLM. llm = CustomLLM(n=10) llm("This is a foobar thing") 'This is a ' We can also print the LLM and see its custom print. print(llm) CustomLLM Params: {'n': 10} previous How to use the async API for LLMs next
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/custom_llm.html
9149c720a568-1
previous How to use the async API for LLMs next How (and why) to use the fake LLM By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/custom_llm.html
2cb408cd3ac3-0
.ipynb .pdf How (and why) to use the fake LLM How (and why) to use the fake LLM# We expose a fake LLM class that can be used for testing. This allows you to mock out calls to the LLM and simulate what would happen if the LLM responded in a certain way. In this notebook we go over how to use this. We start this with using the FakeLLM in an agent. from langchain.llms.fake import FakeListLLM from langchain.agents import load_tools from langchain.agents import initialize_agent from langchain.agents import AgentType tools = load_tools(["python_repl"]) responses=[ "Action: Python REPL\nAction Input: print(2 + 2)", "Final Answer: 4" ] llm = FakeListLLM(responses=responses) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("whats 2 + 2") > Entering new AgentExecutor chain... Action: Python REPL Action Input: print(2 + 2) Observation: 4 Thought:Final Answer: 4 > Finished chain. '4' previous How to write a custom LLM wrapper next How to cache LLM calls By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/fake_llm.html
2ea8433aafea-0
.ipynb .pdf How to cache LLM calls Contents In Memory Cache SQLite Cache Redis Cache SQLAlchemy Cache Custom SQLAlchemy Schemas Optional Caching Optional Caching in Chains How to cache LLM calls# This notebook covers how to cache results of individual LLM calls. from langchain.llms import OpenAI In Memory Cache# import langchain from langchain.cache import InMemoryCache langchain.llm_cache = InMemoryCache() # To make the caching really obvious, lets use a slower model. llm = OpenAI(model_name="text-davinci-002", n=2, best_of=2) %%time # The first time, it is not yet in cache, so it should take longer llm("Tell me a joke") CPU times: user 30.7 ms, sys: 18.6 ms, total: 49.3 ms Wall time: 791 ms "\n\nWhy couldn't the bicycle stand up by itself? Because it was...two tired!" %%time # The second time it is, so it goes faster llm("Tell me a joke") CPU times: user 80 µs, sys: 0 ns, total: 80 µs Wall time: 83.9 µs "\n\nWhy couldn't the bicycle stand up by itself? Because it was...two tired!" SQLite Cache# !rm .langchain.db # We can do the same thing with a SQLite cache from langchain.cache import SQLiteCache langchain.llm_cache = SQLiteCache(database_path=".langchain.db") %%time # The first time, it is not yet in cache, so it should take longer llm("Tell me a joke")
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/llm_caching.html
2ea8433aafea-1
llm("Tell me a joke") CPU times: user 17 ms, sys: 9.76 ms, total: 26.7 ms Wall time: 825 ms '\n\nWhy did the chicken cross the road?\n\nTo get to the other side.' %%time # The second time it is, so it goes faster llm("Tell me a joke") CPU times: user 2.46 ms, sys: 1.23 ms, total: 3.7 ms Wall time: 2.67 ms '\n\nWhy did the chicken cross the road?\n\nTo get to the other side.' Redis Cache# # We can do the same thing with a Redis cache # (make sure your local Redis instance is running first before running this example) from redis import Redis from langchain.cache import RedisCache langchain.llm_cache = RedisCache(redis_=Redis()) %%time # The first time, it is not yet in cache, so it should take longer llm("Tell me a joke") %%time # The second time it is, so it goes faster llm("Tell me a joke") SQLAlchemy Cache# # You can use SQLAlchemyCache to cache with any SQL database supported by SQLAlchemy. # from langchain.cache import SQLAlchemyCache # from sqlalchemy import create_engine # engine = create_engine("postgresql://postgres:postgres@localhost:5432/postgres") # langchain.llm_cache = SQLAlchemyCache(engine) Custom SQLAlchemy Schemas# # You can define your own declarative SQLAlchemyCache child class to customize the schema used for caching. For example, to support high-speed fulltext prompt indexing with Postgres, use: from sqlalchemy import Column, Integer, String, Computed, Index, Sequence from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/llm_caching.html
2ea8433aafea-2
from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy_utils import TSVectorType from langchain.cache import SQLAlchemyCache Base = declarative_base() class FulltextLLMCache(Base): # type: ignore """Postgres table for fulltext-indexed LLM Cache""" __tablename__ = "llm_cache_fulltext" id = Column(Integer, Sequence('cache_id'), primary_key=True) prompt = Column(String, nullable=False) llm = Column(String, nullable=False) idx = Column(Integer) response = Column(String) prompt_tsv = Column(TSVectorType(), Computed("to_tsvector('english', llm || ' ' || prompt)", persisted=True)) __table_args__ = ( Index("idx_fulltext_prompt_tsv", prompt_tsv, postgresql_using="gin"), ) engine = create_engine("postgresql://postgres:postgres@localhost:5432/postgres") langchain.llm_cache = SQLAlchemyCache(engine, FulltextLLMCache) Optional Caching# You can also turn off caching for specific LLMs should you choose. In the example below, even though global caching is enabled, we turn it off for a specific LLM llm = OpenAI(model_name="text-davinci-002", n=2, best_of=2, cache=False) %%time llm("Tell me a joke") CPU times: user 5.8 ms, sys: 2.71 ms, total: 8.51 ms Wall time: 745 ms '\n\nWhy did the chicken cross the road?\n\nTo get to the other side!' %%time llm("Tell me a joke")
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/llm_caching.html
2ea8433aafea-3
%%time llm("Tell me a joke") CPU times: user 4.91 ms, sys: 2.64 ms, total: 7.55 ms Wall time: 623 ms '\n\nTwo guys stole a calendar. They got six months each.' Optional Caching in Chains# You can also turn off caching for particular nodes in chains. Note that because of certain interfaces, its often easier to construct the chain first, and then edit the LLM afterwards. As an example, we will load a summarizer map-reduce chain. We will cache results for the map-step, but then not freeze it for the combine step. llm = OpenAI(model_name="text-davinci-002") no_cache_llm = OpenAI(model_name="text-davinci-002", cache=False) from langchain.text_splitter import CharacterTextSplitter from langchain.chains.mapreduce import MapReduceChain text_splitter = CharacterTextSplitter() with open('../../../state_of_the_union.txt') as f: state_of_the_union = f.read() texts = text_splitter.split_text(state_of_the_union) from langchain.docstore.document import Document docs = [Document(page_content=t) for t in texts[:3]] from langchain.chains.summarize import load_summarize_chain chain = load_summarize_chain(llm, chain_type="map_reduce", reduce_llm=no_cache_llm) %%time chain.run(docs) CPU times: user 452 ms, sys: 60.3 ms, total: 512 ms Wall time: 5.09 s
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/llm_caching.html
2ea8433aafea-4
Wall time: 5.09 s '\n\nPresident Biden is discussing the American Rescue Plan and the Bipartisan Infrastructure Law, which will create jobs and help Americans. He also talks about his vision for America, which includes investing in education and infrastructure. In response to Russian aggression in Ukraine, the United States is joining with European allies to impose sanctions and isolate Russia. American forces are being mobilized to protect NATO countries in the event that Putin decides to keep moving west. The Ukrainians are bravely fighting back, but the next few weeks will be hard for them. Putin will pay a high price for his actions in the long run. Americans should not be alarmed, as the United States is taking action to protect its interests and allies.' When we run it again, we see that it runs substantially faster but the final answer is different. This is due to caching at the map steps, but not at the reduce step. %%time chain.run(docs) CPU times: user 11.5 ms, sys: 4.33 ms, total: 15.8 ms Wall time: 1.04 s '\n\nPresident Biden is discussing the American Rescue Plan and the Bipartisan Infrastructure Law, which will create jobs and help Americans. He also talks about his vision for America, which includes investing in education and infrastructure.' previous How (and why) to use the fake LLM next How to serialize LLM classes Contents In Memory Cache SQLite Cache Redis Cache SQLAlchemy Cache Custom SQLAlchemy Schemas Optional Caching Optional Caching in Chains By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/llm_caching.html
6a64cb5f4e18-0
.ipynb .pdf How to serialize LLM classes Contents Loading Saving How to serialize LLM classes# This notebook walks through how to write and read an LLM Configuration to and from disk. This is useful if you want to save the configuration for a given LLM (e.g., the provider, the temperature, etc). from langchain.llms import OpenAI from langchain.llms.loading import load_llm Loading# First, lets go over loading an LLM from disk. LLMs can be saved on disk in two formats: json or yaml. No matter the extension, they are loaded in the same way. !cat llm.json { "model_name": "text-davinci-003", "temperature": 0.7, "max_tokens": 256, "top_p": 1.0, "frequency_penalty": 0.0, "presence_penalty": 0.0, "n": 1, "best_of": 1, "request_timeout": null, "_type": "openai" } llm = load_llm("llm.json") !cat llm.yaml _type: openai best_of: 1 frequency_penalty: 0.0 max_tokens: 256 model_name: text-davinci-003 n: 1 presence_penalty: 0.0 request_timeout: null temperature: 0.7 top_p: 1.0 llm = load_llm("llm.yaml") Saving# If you want to go from an LLM in memory to a serialized version of it, you can do so easily by calling the .save method. Again, this supports both json and yaml. llm.save("llm.json")
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/llm_serialization.html
6a64cb5f4e18-1
llm.save("llm.json") llm.save("llm.yaml") previous How to cache LLM calls next How to stream LLM and Chat Model responses Contents Loading Saving By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/llm_serialization.html
c732c3672ad6-0
.ipynb .pdf How to stream LLM and Chat Model responses How to stream LLM and Chat Model responses# LangChain provides streaming support for LLMs. Currently, we support streaming for the OpenAI, ChatOpenAI. and Anthropic implementations, but streaming support for other LLM implementations is on the roadmap. To utilize streaming, use a CallbackHandler that implements on_llm_new_token. In this example, we are using StreamingStdOutCallbackHandler. from langchain.llms import OpenAI, Anthropic from langchain.chat_models import ChatOpenAI from langchain.callbacks.base import CallbackManager from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler from langchain.schema import HumanMessage llm = OpenAI(streaming=True, callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]), verbose=True, temperature=0) resp = llm("Write me a song about sparkling water.") Verse 1 I'm sippin' on sparkling water, It's so refreshing and light, It's the perfect way to quench my thirst On a hot summer night. Chorus Sparkling water, sparkling water, It's the best way to stay hydrated, It's so crisp and so clean, It's the perfect way to stay refreshed. Verse 2 I'm sippin' on sparkling water, It's so bubbly and bright, It's the perfect way to cool me down On a hot summer night. Chorus Sparkling water, sparkling water, It's the best way to stay hydrated, It's so crisp and so clean, It's the perfect way to stay refreshed. Verse 3 I'm sippin' on sparkling water, It's so light and so clear, It's the perfect way to keep me cool On a hot summer night. Chorus
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/streaming_llm.html
c732c3672ad6-1
It's the perfect way to keep me cool On a hot summer night. Chorus Sparkling water, sparkling water, It's the best way to stay hydrated, It's so crisp and so clean, It's the perfect way to stay refreshed. We still have access to the end LLMResult if using generate. However, token_usage is not currently supported for streaming. llm.generate(["Tell me a joke."]) Q: What did the fish say when it hit the wall? A: Dam! LLMResult(generations=[[Generation(text='\n\nQ: What did the fish say when it hit the wall?\nA: Dam!', generation_info={'finish_reason': None, 'logprobs': None})]], llm_output={'token_usage': {}, 'model_name': 'text-davinci-003'}) Here’s an example with the ChatOpenAI chat model implementation: chat = ChatOpenAI(streaming=True, callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]), verbose=True, temperature=0) resp = chat([HumanMessage(content="Write me a song about sparkling water.")]) Verse 1: Bubbles rising to the top A refreshing drink that never stops Clear and crisp, it's oh so pure Sparkling water, I can't ignore Chorus: Sparkling water, oh how you shine A taste so clean, it's simply divine You quench my thirst, you make me feel alive Sparkling water, you're my favorite vibe Verse 2: No sugar, no calories, just H2O A drink that's good for me, don't you know With lemon or lime, you're even better Sparkling water, you're my forever Chorus: Sparkling water, oh how you shine A taste so clean, it's simply divine
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/streaming_llm.html
c732c3672ad6-2
Sparkling water, oh how you shine A taste so clean, it's simply divine You quench my thirst, you make me feel alive Sparkling water, you're my favorite vibe Bridge: You're my go-to drink, day or night You make me feel so light I'll never give you up, you're my true love Sparkling water, you're sent from above Chorus: Sparkling water, oh how you shine A taste so clean, it's simply divine You quench my thirst, you make me feel alive Sparkling water, you're my favorite vibe Outro: Sparkling water, you're the one for me I'll never let you go, can't you see You're my drink of choice, forevermore Sparkling water, I adore. Here is an example with the Anthropic LLM implementation, which uses their claude model. llm = Anthropic(streaming=True, callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]), verbose=True, temperature=0) llm("Write me a song about sparkling water.") Sparkling water, bubbles so bright, Fizzing and popping in the light. No sugar or calories, a healthy delight, Sparkling water, refreshing and light. Carbonation that tickles the tongue, In flavors of lemon and lime unsung. Sparkling water, a drink quite all right, Bubbles sparkling in the light. '\nSparkling water, bubbles so bright,\n\nFizzing and popping in the light.\n\nNo sugar or calories, a healthy delight,\n\nSparkling water, refreshing and light.\n\nCarbonation that tickles the tongue,\n\nIn flavors of lemon and lime unsung.\n\nSparkling water, a drink quite all right,\n\nBubbles sparkling in the light.' previous
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/streaming_llm.html
c732c3672ad6-3
previous How to serialize LLM classes next How to track token usage By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 05, 2023.
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/streaming_llm.html
3c90e747c7a7-0
.ipynb .pdf How to track token usage How to track token usage# This notebook goes over how to track your token usage for specific calls. It is currently only implemented for the OpenAI API. Let’s first look at an extremely simple example of tracking token usage for a single LLM call. from langchain.llms import OpenAI from langchain.callbacks import get_openai_callback llm = OpenAI(model_name="text-davinci-002", n=2, best_of=2) with get_openai_callback() as cb: result = llm("Tell me a joke") print(f"Total Tokens: {cb.total_tokens}") print(f"Prompt Tokens: {cb.prompt_tokens}") print(f"Completion Tokens: {cb.completion_tokens}") print(f"Successful Requests: {cb.successful_requests}") print(f"Total Cost (USD): ${cb.total_cost}") Total Tokens: 39 Prompt Tokens: 4 Completion Tokens: 35 Successful Requests: 1 Total Cost (USD): $0.0007800000000000001 Anything inside the context manager will get tracked. Here’s an example of using it to track multiple calls in sequence. with get_openai_callback() as cb: result = llm("Tell me a joke") result2 = llm("Tell me a joke") print(cb.total_tokens) 91 If a chain or agent with multiple steps in it is used, it will track all those steps. from langchain.agents import load_tools from langchain.agents import initialize_agent from langchain.agents import AgentType from langchain.llms import OpenAI llm = OpenAI(temperature=0) tools = load_tools(["serpapi", "llm-math"], llm=llm)
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/token_usage_tracking.html
3c90e747c7a7-1
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) with get_openai_callback() as cb: response = agent.run("Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?") print(f"Total Tokens: {cb.total_tokens}") print(f"Prompt Tokens: {cb.prompt_tokens}") print(f"Completion Tokens: {cb.completion_tokens}") print(f"Total Cost (USD): ${cb.total_cost}") > Entering new AgentExecutor chain... I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power. Action: Search Action Input: "Olivia Wilde boyfriend" Observation: Sudeikis and Wilde's relationship ended in November 2020. Wilde was publicly served with court documents regarding child custody while she was presenting Don't Worry Darling at CinemaCon 2022. In January 2021, Wilde began dating singer Harry Styles after meeting during the filming of Don't Worry Darling. Thought: I need to find out Harry Styles' age. Action: Search Action Input: "Harry Styles age" Observation: 29 years Thought: I need to calculate 29 raised to the 0.23 power. Action: Calculator Action Input: 29^0.23 Observation: Answer: 2.169459462491557 Thought: I now know the final answer. Final Answer: Harry Styles, Olivia Wilde's boyfriend, is 29 years old and his age raised to the 0.23 power is 2.169459462491557. > Finished chain. Total Tokens: 1506 Prompt Tokens: 1350 Completion Tokens: 156 Total Cost (USD): $0.03012
/content/drive/MyDrive/Chatgpt-plugins/https://python.langchain.com/en/latest/modules/models/llms/examples/token_usage_tracking.html