├── .gitignore ├── README.md ├── README.translator.md ├── __pycache__ └── api.cpython-311.pyc ├── api_reference ├── Makefile ├── _static │ ├── css │ │ └── custom.css │ └── js │ │ └── mendablesearch.js ├── agents.rst ├── conf.py ├── data_connection.rst ├── index.rst ├── make.bat ├── model_io.rst ├── models.rst ├── modules │ ├── agent_toolkits.rst │ ├── agents.rst │ ├── base_classes.rst │ ├── callbacks.rst │ ├── chains.rst │ ├── chat_models.rst │ ├── document_loaders.rst │ ├── document_transformers.rst │ ├── embeddings.rst │ ├── example_selector.rst │ ├── experimental.rst │ ├── llms.rst │ ├── memory.rst │ ├── output_parsers.rst │ ├── prompts.rst │ ├── retrievers.rst │ ├── tools.rst │ ├── utilities.rst │ └── vectorstores.rst └── prompts.rst ├── babel.config.js ├── blog ├── 2019-05-28-first-blog-post.md ├── 2019-05-29-long-blog-post.md ├── 2021-08-01-mdx-blog-post.mdx ├── 2021-08-26-welcome │ ├── docusaurus-plushie-banner.jpeg │ └── index.md └── authors.yml ├── code-block-loader.js ├── docs ├── _static │ ├── ApifyActors.png │ ├── DataberryDashboard.png │ ├── HeliconeDashboard.png │ ├── HeliconeKeys.png │ ├── MetalDash.png │ ├── android-chrome-192x192.png │ ├── android-chrome-512x512.png │ ├── apple-touch-icon.png │ ├── css │ │ └── custom.css │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ ├── js │ │ └── mendablesearch.js │ ├── lc_modules.jpg │ ├── parrot-chainlink-icon.png │ └── parrot-icon.png ├── _templates │ └── integration.mdx ├── additional_resources │ ├── index.mdx │ └── youtube.mdx ├── changelog │ ├── core.mdx │ └── langchain.mdx ├── contributing │ ├── documentation.mdx │ ├── faq.mdx │ ├── index.mdx │ ├── integrations.mdx │ ├── repo_structure.mdx │ └── testing.mdx ├── ecosystem │ └── integrations │ │ ├── agent_with_wandb_tracing.md │ │ ├── ai21.mdx │ │ ├── airbyte.mdx │ │ ├── alibabacloud_opensearch.md │ │ ├── analyticdb.mdx │ │ ├── annoy.mdx │ │ ├── anyscale.mdx │ │ ├── apify.mdx │ │ ├── argilla.mdx │ │ ├── arxiv.mdx │ │ ├── awadb.md │ │ ├── aws_s3.mdx │ │ ├── azlyrics.mdx │ │ ├── azure_blob_storage.mdx │ │ ├── azure_cognitive_search_.mdx │ │ ├── azure_openai.mdx │ │ ├── baseten.md │ │ ├── beam.mdx │ │ ├── bedrock.mdx │ │ ├── bilibili.mdx │ │ ├── blackboard.mdx │ │ ├── cassandra.mdx │ │ ├── cerebriumai.mdx │ │ ├── chroma.mdx │ │ ├── clearml_tracking.md │ │ ├── cohere.mdx │ │ ├── college_confidential.mdx │ │ ├── comet_tracking.md │ │ ├── confluence.mdx │ │ ├── ctransformers.mdx │ │ ├── databerry.mdx │ │ ├── databricks.md │ │ ├── databricks │ │ └── databricks.md │ │ ├── deepinfra.mdx │ │ ├── deeplake.mdx │ │ ├── diffbot.mdx │ │ ├── discord.mdx │ │ ├── docugami.mdx │ │ ├── duckdb.mdx │ │ ├── elasticsearch.mdx │ │ ├── evernote.mdx │ │ ├── facebook_chat.mdx │ │ ├── figma.mdx │ │ ├── forefrontai.mdx │ │ ├── git.mdx │ │ ├── gitbook.mdx │ │ ├── google_bigquery.mdx │ │ ├── google_cloud_storage.mdx │ │ ├── google_drive.mdx │ │ ├── google_search.mdx │ │ ├── google_serper.mdx │ │ ├── gooseai.mdx │ │ ├── gpt4all.mdx │ │ ├── graphsignal.mdx │ │ ├── gutenberg.mdx │ │ ├── hacker_news.mdx │ │ ├── hazy_research.mdx │ │ ├── helicone.mdx │ │ ├── huggingface.mdx │ │ ├── ifixit.mdx │ │ ├── imsdb.mdx │ │ ├── index.mdx │ │ ├── jina.mdx │ │ ├── lancedb.mdx │ │ ├── langchain_decorators.mdx │ │ ├── llamacpp.mdx │ │ ├── mediawikidump.mdx │ │ ├── metal.mdx │ │ ├── microsoft_onedrive.mdx │ │ ├── microsoft_powerpoint.mdx │ │ ├── microsoft_word.mdx │ │ ├── milvus.mdx │ │ ├── mlflow_tracking.md │ │ ├── modal.mdx │ │ ├── modelscope.mdx │ │ ├── modern_treasury.mdx │ │ ├── momento.mdx │ │ ├── myscale.mdx │ │ ├── nlpcloud.mdx │ │ ├── notion.mdx │ │ ├── obsidian.mdx │ │ ├── openai.mdx │ │ ├── opensearch.mdx │ │ ├── openweathermap.mdx │ │ ├── petals.mdx │ │ ├── pgvector.mdx │ │ ├── pinecone.mdx │ │ ├── pipelineai.mdx │ │ ├── predictionguard.mdx │ │ ├── promptlayer.mdx │ │ ├── psychic.mdx │ │ ├── qdrant.mdx │ │ ├── ray_serve.md │ │ ├── rebuff.md │ │ ├── reddit.mdx │ │ ├── redis.mdx │ │ ├── replicate.mdx │ │ ├── roam.mdx │ │ ├── runhouse.mdx │ │ ├── rwkv.mdx │ │ ├── sagemaker_endpoint.mdx │ │ ├── searx.mdx │ │ ├── serpapi.mdx │ │ ├── shaleprotocol.md │ │ ├── sklearn.mdx │ │ ├── slack.mdx │ │ ├── spacy.mdx │ │ ├── spreedly.mdx │ │ ├── stochasticai.mdx │ │ ├── stripe.mdx │ │ ├── tair.mdx │ │ ├── telegram.mdx │ │ ├── tomarkdown.mdx │ │ ├── trello.mdx │ │ ├── twitter.mdx │ │ ├── unstructured.mdx │ │ ├── vectara │ │ ├── index.mdx │ │ ├── vectara_chat.md │ │ └── vectara_text_generation.md │ │ ├── vespa.mdx │ │ ├── weather.mdx │ │ ├── weaviate.mdx │ │ ├── whatsapp.mdx │ │ ├── whylabs_profiling.md │ │ ├── wikipedia.mdx │ │ ├── wolfram_alpha.mdx │ │ ├── writer.mdx │ │ ├── yeagerai.mdx │ │ ├── youtube.mdx │ │ ├── zep.mdx │ │ └── zilliz.mdx ├── expression_language │ ├── cookbook │ │ ├── agent.md │ │ ├── code_writing.md │ │ ├── embedding_router.md │ │ ├── memory.md │ │ ├── moderation.md │ │ ├── prompt_llm_parser.md │ │ ├── retrieval.md │ │ ├── sql_db.md │ │ └── tools.md │ ├── get_started.md │ ├── how_to │ │ ├── binding.md │ │ ├── decorator.md │ │ ├── fallbacks.md │ │ ├── functions.md │ │ ├── generators.md │ │ ├── index.mdx │ │ ├── inspect.md │ │ ├── map.md │ │ ├── message_history.md │ │ ├── passthrough.md │ │ └── routing.md │ ├── index.mdx │ ├── interface.md │ ├── streaming.md │ └── why.mdx ├── get_started │ ├── installation.mdx │ ├── introduction.mdx │ └── quickstart.mdx ├── guides │ ├── deployments │ │ ├── index.mdx │ │ └── template_repos.mdx │ ├── evaluation │ │ ├── agent_benchmarking.ipynb │ │ ├── agent_benchmarking.md │ │ ├── agent_vectordb_sota_pg.ipynb │ │ ├── agent_vectordb_sota_pg.md │ │ ├── benchmarking_template.ipynb │ │ ├── benchmarking_template.md │ │ ├── comparison │ │ │ └── index.mdx │ │ ├── data_augmented_question_answering.ipynb │ │ ├── data_augmented_question_answering.md │ │ ├── examples │ │ │ └── index.mdx │ │ ├── generic_agent_evaluation.ipynb │ │ ├── generic_agent_evaluation.md │ │ ├── huggingface_datasets.ipynb │ │ ├── huggingface_datasets.md │ │ ├── index.mdx │ │ ├── llm_math.ipynb │ │ ├── llm_math.md │ │ ├── openapi_eval.ipynb │ │ ├── openapi_eval.md │ │ ├── qa_benchmarking_pg.ipynb │ │ ├── qa_benchmarking_pg.md │ │ ├── qa_benchmarking_sota.ipynb │ │ ├── qa_benchmarking_sota.md │ │ ├── qa_generation.ipynb │ │ ├── qa_generation.md │ │ ├── question_answering.ipynb │ │ ├── question_answering.md │ │ ├── sql_qa_benchmarking_chinook.ipynb │ │ ├── sql_qa_benchmarking_chinook.md │ │ └── string │ │ │ └── index.mdx │ ├── index.mdx │ ├── langsmith │ │ └── index.md │ ├── model_laboratory.ipynb │ ├── model_laboratory.md │ ├── safety │ │ ├── index.mdx │ │ ├── logical_fallacy_chain.mdx │ │ └── moderation.mdx │ └── tracing │ │ ├── agent_with_tracing.ipynb │ │ ├── agent_with_tracing.md │ │ ├── default_empty.png │ │ ├── explore.png │ │ ├── explore_llm.png │ │ ├── explore_trace.png │ │ ├── first_trace.png │ │ ├── homepage.png │ │ └── index.mdx ├── index.mdx ├── langsmith │ ├── img │ │ └── test_results.png │ └── index.md ├── modules │ ├── agents │ │ ├── agent_types │ │ │ ├── chat_conversation_agent.mdx │ │ │ ├── index.mdx │ │ │ ├── openai_functions_agent.md │ │ │ ├── openai_functions_agent.mdx │ │ │ ├── react.mdx │ │ │ ├── react_docstore.md │ │ │ ├── self_ask_with_search.md │ │ │ └── structured_chat.mdx │ │ ├── how_to │ │ │ ├── _category_.yml │ │ │ ├── add_memory_openai_functions.md │ │ │ ├── agent_vectorstore.md │ │ │ ├── async_agent.md │ │ │ ├── chatgpt_clone.md │ │ │ ├── custom_agent.md │ │ │ ├── custom_agent_with_tool_retrieval.md │ │ │ ├── custom_llm_agent.mdx │ │ │ ├── custom_llm_chat_agent.mdx │ │ │ ├── custom_mrkl_agent.md │ │ │ ├── custom_multi_action_agent.md │ │ │ ├── handle_parsing_errors.md │ │ │ ├── intermediate_steps.md │ │ │ ├── max_iterations.md │ │ │ ├── max_time_limit.md │ │ │ ├── mrkl.mdx │ │ │ ├── sharedmemory_for_tools.md │ │ │ ├── streaming_stdout_final_only.md │ │ │ └── use_toolkits_with_openai_functions.md │ │ ├── index.mdx │ │ ├── toolkits │ │ │ ├── azure_cognitive_services.md │ │ │ ├── csv.md │ │ │ ├── document_comparison_toolkit.md │ │ │ ├── gmail.md │ │ │ ├── index.mdx │ │ │ ├── jira.md │ │ │ ├── json.md │ │ │ ├── openapi.md │ │ │ ├── openapi_nla.md │ │ │ ├── pandas.md │ │ │ ├── playwright.md │ │ │ ├── powerbi.md │ │ │ ├── python.md │ │ │ ├── spark.md │ │ │ ├── spark_sql.md │ │ │ ├── sql_database.md │ │ │ └── vectorstore.md │ │ └── tools │ │ │ ├── how_to │ │ │ ├── _category_.yml │ │ │ ├── custom_tools.md │ │ │ ├── human_approval.md │ │ │ ├── multi_input_tool.md │ │ │ ├── tool_input_validation.md │ │ │ └── tools_as_openai_functions.md │ │ │ ├── index.mdx │ │ │ └── integrations │ │ │ ├── _category_.yml │ │ │ ├── apify.md │ │ │ ├── arxiv.md │ │ │ ├── awslambda.md │ │ │ ├── bash.md │ │ │ ├── bing_search.md │ │ │ ├── brave_search.md │ │ │ ├── chatgpt_plugins.md │ │ │ ├── ddg.md │ │ │ ├── filesystem.md │ │ │ ├── google_places.md │ │ │ ├── google_search.md │ │ │ ├── google_serper.md │ │ │ ├── gradio_tools.md │ │ │ ├── graphql.md │ │ │ ├── huggingface_tools.md │ │ │ ├── human_tools.md │ │ │ ├── ifttt.md │ │ │ ├── metaphor_search.md │ │ │ ├── openweathermap.md │ │ │ ├── pubmed.md │ │ │ ├── python.md │ │ │ ├── requests.md │ │ │ ├── sceneXplain.md │ │ │ ├── search_tools.md │ │ │ ├── searx_search.md │ │ │ ├── serpapi.md │ │ │ ├── twilio.md │ │ │ ├── wikipedia.md │ │ │ ├── wolfram_alpha.md │ │ │ ├── youtube.md │ │ │ └── zapier.md │ ├── callbacks │ │ ├── how_to │ │ │ ├── _category_.yml │ │ │ ├── async_callbacks.md │ │ │ ├── custom_callbacks.md │ │ │ ├── custom_chain.mdx │ │ │ ├── filecallbackhandler.md │ │ │ ├── multiple_callbacks.md │ │ │ ├── tags.mdx │ │ │ ├── token_counting.md │ │ │ └── tracing.md │ │ ├── index.mdx │ │ └── integrations │ │ │ ├── _category_.yml │ │ │ └── argilla.md │ ├── chains │ │ ├── additional │ │ │ ├── analyze_document.mdx │ │ │ ├── constitutional_chain.mdx │ │ │ ├── extraction.md │ │ │ ├── flare.md │ │ │ ├── graph_cypher_qa.md │ │ │ ├── graph_nebula_qa.md │ │ │ ├── graph_qa.md │ │ │ ├── hyde.md │ │ │ ├── index.mdx │ │ │ ├── llm_bash.md │ │ │ ├── llm_checker.md │ │ │ ├── llm_math.md │ │ │ ├── llm_requests.md │ │ │ ├── llm_summarization_checker.md │ │ │ ├── moderation.mdx │ │ │ ├── multi_prompt_router.mdx │ │ │ ├── multi_retrieval_qa_router.mdx │ │ │ ├── openai_functions_retrieval_qa.md │ │ │ ├── openapi.md │ │ │ ├── pal.md │ │ │ ├── qa_citations.md │ │ │ ├── question_answering.mdx │ │ │ ├── tagging.md │ │ │ └── vector_db_text_generation.md │ │ ├── document │ │ │ ├── index.mdx │ │ │ ├── map_reduce.mdx │ │ │ ├── map_rerank.mdx │ │ │ ├── refine.mdx │ │ │ └── stuff.mdx │ │ ├── foundational │ │ │ ├── index.mdx │ │ │ ├── llm_chain.mdx │ │ │ ├── router.md │ │ │ ├── sequential_chains.mdx │ │ │ └── transformation.md │ │ ├── how_to │ │ │ ├── async_chain.md │ │ │ ├── call_methods.md │ │ │ ├── custom_chain.md │ │ │ ├── debugging.mdx │ │ │ ├── from_hub.md │ │ │ ├── index.mdx │ │ │ ├── memory.mdx │ │ │ └── serialization.md │ │ ├── index.mdx │ │ └── popular │ │ │ ├── api.mdx │ │ │ ├── chat_vector_db.mdx │ │ │ ├── index.mdx │ │ │ ├── sqlite.mdx │ │ │ ├── summarize.mdx │ │ │ └── vector_db_qa.mdx │ ├── data_connection │ │ ├── document_loaders │ │ │ ├── csv.mdx │ │ │ ├── file_directory.mdx │ │ │ ├── how_to │ │ │ │ ├── _category_.yml │ │ │ │ ├── csv.mdx │ │ │ │ ├── file_directory.mdx │ │ │ │ ├── html.mdx │ │ │ │ ├── json.mdx │ │ │ │ ├── markdown.mdx │ │ │ │ └── pdf.mdx │ │ │ ├── index.mdx │ │ │ ├── integrations │ │ │ │ ├── _category_.yml │ │ │ │ ├── acreom.md │ │ │ │ ├── airbyte_json.md │ │ │ │ ├── airtable.md │ │ │ │ ├── alibaba_cloud_maxcompute.md │ │ │ │ ├── apify_dataset.md │ │ │ │ ├── arxiv.md │ │ │ │ ├── aws_s3_directory.md │ │ │ │ ├── aws_s3_file.md │ │ │ │ ├── azlyrics.md │ │ │ │ ├── azure_blob_storage_container.md │ │ │ │ ├── azure_blob_storage_file.md │ │ │ │ ├── bibtex.md │ │ │ │ ├── bilibili.md │ │ │ │ ├── blackboard.md │ │ │ │ ├── blockchain.md │ │ │ │ ├── chatgpt_loader.md │ │ │ │ ├── college_confidential.md │ │ │ │ ├── confluence.md │ │ │ │ ├── conll-u.md │ │ │ │ ├── copypaste.md │ │ │ │ ├── csv.md │ │ │ │ ├── diffbot.md │ │ │ │ ├── discord.md │ │ │ │ ├── docugami.md │ │ │ │ ├── duckdb.md │ │ │ │ ├── email.md │ │ │ │ ├── embaas.md │ │ │ │ ├── epub.md │ │ │ │ ├── evernote.md │ │ │ │ ├── example_data │ │ │ │ │ └── notebook.md │ │ │ │ ├── excel.md │ │ │ │ ├── facebook_chat.md │ │ │ │ ├── fauna.md │ │ │ │ ├── figma.md │ │ │ │ ├── git.md │ │ │ │ ├── gitbook.md │ │ │ │ ├── github.md │ │ │ │ ├── google_bigquery.md │ │ │ │ ├── google_cloud_storage_directory.md │ │ │ │ ├── google_cloud_storage_file.md │ │ │ │ ├── google_drive.md │ │ │ │ ├── gutenberg.md │ │ │ │ ├── hacker_news.md │ │ │ │ ├── hugging_face_dataset.md │ │ │ │ ├── ifixit.md │ │ │ │ ├── image.md │ │ │ │ ├── image_captions.md │ │ │ │ ├── imsdb.md │ │ │ │ ├── iugu.md │ │ │ │ ├── joplin.md │ │ │ │ ├── jupyter_notebook.md │ │ │ │ ├── mastodon.md │ │ │ │ ├── mediawikidump.md │ │ │ │ ├── microsoft_onedrive.md │ │ │ │ ├── microsoft_powerpoint.md │ │ │ │ ├── microsoft_word.md │ │ │ │ ├── modern_treasury.md │ │ │ │ ├── notion.md │ │ │ │ ├── notiondb.md │ │ │ │ ├── obsidian.md │ │ │ │ ├── odt.md │ │ │ │ ├── pandas_dataframe.md │ │ │ │ ├── psychic.md │ │ │ │ ├── pyspark_dataframe.md │ │ │ │ ├── readthedocs_documentation.md │ │ │ │ ├── reddit.md │ │ │ │ ├── roam.md │ │ │ │ ├── sitemap.md │ │ │ │ ├── slack.md │ │ │ │ ├── snowflake.md │ │ │ │ ├── spreedly.md │ │ │ │ ├── stripe.md │ │ │ │ ├── subtitle.md │ │ │ │ ├── telegram.md │ │ │ │ ├── tomarkdown.md │ │ │ │ ├── toml.md │ │ │ │ ├── trello.md │ │ │ │ ├── twitter.md │ │ │ │ ├── unstructured_file.md │ │ │ │ ├── url.md │ │ │ │ ├── weather.md │ │ │ │ ├── web_base.md │ │ │ │ ├── web_base_other.md │ │ │ │ ├── whatsapp_chat.md │ │ │ │ ├── wikipedia.md │ │ │ │ ├── xml.md │ │ │ │ ├── youtube_audio.md │ │ │ │ └── youtube_transcript.md │ │ │ └── markdown.mdx │ │ ├── document_transformers │ │ │ ├── index.mdx │ │ │ └── text_splitters │ │ │ │ ├── _category_.yml │ │ │ │ ├── character_text_splitter.mdx │ │ │ │ ├── code_splitter.mdx │ │ │ │ ├── markdown_header_metadata.md │ │ │ │ ├── recursive_text_splitter.mdx │ │ │ │ └── split_by_token.md │ │ ├── index.mdx │ │ ├── retrievers │ │ │ ├── contextual_compression │ │ │ │ └── index.mdx │ │ │ ├── how_to │ │ │ │ ├── _category_.yml │ │ │ │ ├── contextual_compression │ │ │ │ │ └── index.mdx │ │ │ │ ├── self_query │ │ │ │ │ ├── chroma_self_query.md │ │ │ │ │ ├── index.mdx │ │ │ │ │ ├── myscale_self_query.md │ │ │ │ │ ├── pinecone.md │ │ │ │ │ ├── qdrant_self_query.md │ │ │ │ │ └── weaviate_self_query.md │ │ │ │ ├── time_weighted_vectorstore.mdx │ │ │ │ └── vectorstore.mdx │ │ │ ├── index.mdx │ │ │ ├── integrations │ │ │ │ ├── _category_.yml │ │ │ │ ├── arxiv.md │ │ │ │ ├── aws_kendra_index_retriever.md │ │ │ │ ├── azure_cognitive_search.md │ │ │ │ ├── chatgpt-plugin.md │ │ │ │ ├── cohere-reranker.md │ │ │ │ ├── databerry.md │ │ │ │ ├── docarray_retriever.md │ │ │ │ ├── elastic_search_bm25.md │ │ │ │ ├── knn.md │ │ │ │ ├── merger_retriever.md │ │ │ │ ├── metal.md │ │ │ │ ├── pinecone_hybrid_search.md │ │ │ │ ├── pubmed.md │ │ │ │ ├── svm.md │ │ │ │ ├── tf_idf.md │ │ │ │ ├── vespa.md │ │ │ │ ├── weaviate-hybrid.md │ │ │ │ ├── wikipedia.md │ │ │ │ └── zep_memorystore.md │ │ │ ├── self_query │ │ │ │ └── index.mdx │ │ │ └── time_weighted_vectorstore.mdx │ │ ├── text_embedding │ │ │ ├── index.mdx │ │ │ └── integrations │ │ │ │ ├── _category_.yml │ │ │ │ ├── aleph_alpha.md │ │ │ │ ├── azureopenai.md │ │ │ │ ├── bedrock.md │ │ │ │ ├── cohere.md │ │ │ │ ├── dashscope.md │ │ │ │ ├── deepinfra.md │ │ │ │ ├── elasticsearch.md │ │ │ │ ├── embaas.md │ │ │ │ ├── fake.md │ │ │ │ ├── google_vertex_ai_palm.md │ │ │ │ ├── huggingfacehub.md │ │ │ │ ├── instruct_embeddings.md │ │ │ │ ├── jina.md │ │ │ │ ├── llamacpp.md │ │ │ │ ├── minimax.md │ │ │ │ ├── modelscope_hub.md │ │ │ │ ├── mosaicml.md │ │ │ │ ├── openai.md │ │ │ │ ├── sagemaker-endpoint.md │ │ │ │ ├── self-hosted.md │ │ │ │ ├── sentence_transformers.md │ │ │ │ └── tensorflowhub.md │ │ └── vectorstores │ │ │ ├── index.mdx │ │ │ └── integrations │ │ │ ├── _category_.yml │ │ │ ├── analyticdb.md │ │ │ ├── annoy.md │ │ │ ├── atlas.md │ │ │ ├── awadb.md │ │ │ ├── azuresearch.md │ │ │ ├── chroma.md │ │ │ ├── deeplake.md │ │ │ ├── docarray_hnsw.md │ │ │ ├── docarray_in_memory.md │ │ │ ├── elasticsearch.md │ │ │ ├── faiss.md │ │ │ ├── hologres.md │ │ │ ├── lancedb.md │ │ │ ├── matchingengine.md │ │ │ ├── milvus.md │ │ │ ├── myscale.md │ │ │ ├── opensearch.md │ │ │ ├── pgvector.md │ │ │ ├── pinecone.md │ │ │ ├── qdrant.md │ │ │ ├── redis.md │ │ │ ├── singlestoredb.md │ │ │ ├── sklearn.md │ │ │ ├── supabase.md │ │ │ ├── tair.md │ │ │ ├── tigris.md │ │ │ ├── typesense.md │ │ │ ├── vectara.md │ │ │ ├── weaviate.md │ │ │ └── zilliz.md │ ├── index.mdx │ ├── memory │ │ ├── chat_messages │ │ │ └── index.mdx │ │ ├── how_to │ │ │ ├── _category_.yml │ │ │ ├── adding_memory.md │ │ │ ├── adding_memory_chain_multiple_inputs.md │ │ │ ├── agent_with_memory.md │ │ │ ├── agent_with_memory_in_db.md │ │ │ ├── buffer.mdx │ │ │ ├── buffer_window.mdx │ │ │ ├── conversational_customization.md │ │ │ ├── custom_memory.md │ │ │ ├── entity_summary_memory.mdx │ │ │ ├── kg.md │ │ │ ├── multiple_memory.md │ │ │ ├── summary.mdx │ │ │ ├── summary_buffer.md │ │ │ ├── token_buffer.md │ │ │ └── vectorstore_retriever_memory.mdx │ │ ├── index.mdx │ │ ├── integrations │ │ │ ├── _category_.yml │ │ │ ├── cassandra_chat_message_history.md │ │ │ ├── dynamodb_chat_message_history.md │ │ │ ├── entity_memory_with_sqlite.md │ │ │ ├── momento_chat_message_history.md │ │ │ ├── mongodb_chat_message_history.md │ │ │ ├── motorhead_memory.md │ │ │ ├── motorhead_memory_managed.md │ │ │ ├── postgres_chat_message_history.md │ │ │ ├── redis_chat_message_history.md │ │ │ └── zep_memory.md │ │ └── types │ │ │ ├── buffer.mdx │ │ │ ├── buffer_window.mdx │ │ │ ├── index.mdx │ │ │ ├── summary.mdx │ │ │ └── vectorstore_retriever_memory.mdx │ ├── model_io │ │ ├── index.mdx │ │ ├── models │ │ │ ├── chat │ │ │ │ ├── chat_model_caching.mdx │ │ │ │ ├── how_to │ │ │ │ │ ├── _category_.yml │ │ │ │ │ ├── llm_chain.mdx │ │ │ │ │ ├── prompts.mdx │ │ │ │ │ └── streaming.mdx │ │ │ │ ├── index.mdx │ │ │ │ ├── integrations │ │ │ │ │ ├── _category_.yml │ │ │ │ │ ├── anthropic.md │ │ │ │ │ ├── azure_chat_openai.md │ │ │ │ │ ├── google_vertex_ai_palm.md │ │ │ │ │ ├── openai.md │ │ │ │ │ └── promptlayer_chatopenai.md │ │ │ │ ├── llm_chain.mdx │ │ │ │ └── streaming.mdx │ │ │ ├── index.mdx │ │ │ └── llms │ │ │ │ ├── how_to │ │ │ │ ├── _category_.yml │ │ │ │ ├── async_llm.md │ │ │ │ ├── custom_llm.md │ │ │ │ ├── fake_llm.md │ │ │ │ ├── human_input_llm.md │ │ │ │ ├── llm_caching.mdx │ │ │ │ ├── llm_serialization.md │ │ │ │ ├── streaming_llm.mdx │ │ │ │ └── token_usage_tracking.md │ │ │ │ ├── index.mdx │ │ │ │ ├── integrations │ │ │ │ ├── _category_.yml │ │ │ │ ├── ai21.md │ │ │ │ ├── aleph_alpha.md │ │ │ │ ├── anyscale.md │ │ │ │ ├── azure_openai_example.md │ │ │ │ ├── banana.md │ │ │ │ ├── baseten.md │ │ │ │ ├── beam.md │ │ │ │ ├── bedrock.md │ │ │ │ ├── cerebriumai_example.md │ │ │ │ ├── cohere.md │ │ │ │ ├── ctransformers.md │ │ │ │ ├── databricks.md │ │ │ │ ├── deepinfra_example.md │ │ │ │ ├── forefrontai_example.md │ │ │ │ ├── google_vertex_ai_palm.md │ │ │ │ ├── gooseai_example.md │ │ │ │ ├── gpt4all.md │ │ │ │ ├── huggingface_hub.md │ │ │ │ ├── huggingface_pipelines.md │ │ │ │ ├── huggingface_textgen_inference.md │ │ │ │ ├── jsonformer_experimental.md │ │ │ │ ├── llamacpp.md │ │ │ │ ├── llm_caching.md │ │ │ │ ├── manifest.md │ │ │ │ ├── modal.md │ │ │ │ ├── mosaicml.md │ │ │ │ ├── nlpcloud.md │ │ │ │ ├── openai.md │ │ │ │ ├── openlm.md │ │ │ │ ├── petals_example.md │ │ │ │ ├── pipelineai_example.md │ │ │ │ ├── predictionguard.md │ │ │ │ ├── promptlayer_openai.md │ │ │ │ ├── rellm_experimental.md │ │ │ │ ├── replicate.md │ │ │ │ ├── runhouse.md │ │ │ │ ├── sagemaker.md │ │ │ │ ├── stochasticai.md │ │ │ │ └── writer.md │ │ │ │ └── llm_caching.mdx │ │ ├── output_parsers │ │ │ ├── comma_separated.mdx │ │ │ ├── datetime.md │ │ │ ├── enum.md │ │ │ ├── index.mdx │ │ │ ├── output_fixing_parser.mdx │ │ │ ├── pydantic.md │ │ │ ├── retry.md │ │ │ └── structured.mdx │ │ └── prompts │ │ │ ├── example_selectors │ │ │ ├── custom_example_selector.md │ │ │ ├── index.mdx │ │ │ ├── length_based.mdx │ │ │ ├── mmr.md │ │ │ ├── ngram_overlap.md │ │ │ └── similarity.mdx │ │ │ ├── index.mdx │ │ │ └── prompt_templates │ │ │ ├── connecting_to_a_feature_store.md │ │ │ ├── custom_prompt_template.md │ │ │ ├── few_shot_examples.mdx │ │ │ ├── few_shot_examples_chat.md │ │ │ ├── format_output.mdx │ │ │ ├── formats.mdx │ │ │ ├── index.mdx │ │ │ ├── msg_prompt_templates.mdx │ │ │ ├── partial.mdx │ │ │ ├── prompt_composition.mdx │ │ │ ├── prompt_serialization.md │ │ │ └── validate.mdx │ ├── paul_graham_essay.txt │ └── state_of_the_union.txt ├── security.md ├── templates │ ├── anthropic-iterative-search.md │ ├── basic-critique-revise.md │ ├── cassandra-entomology-rag.md │ ├── cassandra-synonym-caching.md │ ├── chain-of-note-wiki.md │ ├── cohere-librarian.md │ ├── csv-agent.md │ ├── docs.md │ ├── elastic-query-generator.md │ ├── extraction-anthropic-functions.md │ ├── extraction-openai-functions.md │ ├── gemini-functions-agent.md │ ├── guardrails-output-parser.md │ ├── hybrid-search-weaviate.md │ ├── hyde.md │ ├── index.mdx │ ├── llama2-functions.md │ ├── neo4j-advanced-rag.md │ ├── neo4j-cypher-ft.md │ ├── neo4j-cypher-memory.md │ ├── neo4j-cypher.md │ ├── neo4j-generation.md │ ├── neo4j-parent.md │ ├── neo4j-semantic-layer.md │ ├── neo4j-semantic-ollama.md │ ├── neo4j-vector-memory.md │ ├── nvidia-rag-canonical.md │ ├── openai-functions-agent-gmail.md │ ├── openai-functions-agent.md │ ├── openai-functions-tool-retrieval-agent.md │ ├── pii-protected-chatbot.md │ ├── pirate-speak-configurable.md │ ├── pirate-speak.md │ ├── plate-chain.md │ ├── propositional-retrieval.md │ ├── python-lint.md │ ├── rag-astradb.md │ ├── rag-aws-bedrock.md │ ├── rag-aws-kendra.md │ ├── rag-chroma-multi-modal.md │ ├── rag-chroma-private.md │ ├── rag-chroma.md │ ├── rag-codellama-fireworks.md │ ├── rag-conversation-zep.md │ ├── rag-conversation.md │ ├── rag-elasticsearch.md │ ├── rag-fusion.md │ ├── rag-google-cloud-sensitive-data-protection.md │ ├── rag-google-cloud-vertexai-search.md │ ├── rag-gpt-crawler.md │ ├── rag-matching-engine.md │ ├── rag-momento-vector-index.md │ ├── rag-mongo.md │ ├── rag-multi-index-fusion.md │ ├── rag-multi-index-router.md │ ├── rag-multi-modal-mv-local.md │ ├── rag-ollama-multi-query.md │ ├── rag-opensearch.md │ ├── rag-pinecone-multi-query.md │ ├── rag-pinecone-rerank.md │ ├── rag-pinecone.md │ ├── rag-redis.md │ ├── rag-self-query.md │ ├── rag-semi-structured.md │ ├── rag-singlestoredb.md │ ├── rag-supabase.md │ ├── rag-timescale-conversation.md │ ├── rag-vectara-multiquery.md │ ├── rag-vectara.md │ ├── rag-weaviate.md │ ├── research-assistant.md │ ├── retrieval-agent-fireworks.md │ ├── retrieval-agent.md │ ├── rewrite-retrieve-read.md │ ├── robocorp-action-server.md │ ├── self-query-qdrant.md │ ├── self-query-supabase.md │ ├── shopping-assistant.md │ ├── skeleton-of-thought.md │ ├── solo-performance-prompting-agent.md │ ├── sql-llama2.md │ ├── sql-llamacpp.md │ ├── sql-ollama.md │ ├── sql-pgvector.md │ ├── sql-research-assistant.md │ ├── stepback-qa-prompting.md │ ├── summarize-anthropic.md │ ├── templates.md │ ├── vertexai-chuck-norris.md │ └── xml-agent.md └── use_cases │ ├── agent_simulations │ ├── camel_role_playing.md │ ├── characters.md │ ├── gymnasium.md │ ├── index.mdx │ ├── multi_player_dnd.md │ ├── multiagent_authoritarian.md │ ├── multiagent_bidding.md │ ├── petting_zoo.md │ ├── two_agent_debate_tools.md │ └── two_player_dnd.md │ ├── agents │ ├── baby_agi.md │ ├── baby_agi_with_agent.md │ ├── camel_role_playing.md │ ├── custom_agent_with_plugin_retrieval.md │ ├── custom_agent_with_plugin_retrieval_using_plugnplai.md │ ├── index.mdx │ ├── multi_modal_output_agent.md │ ├── sales_agent_with_context.md │ └── wikibase_agent.md │ ├── apis.mdx │ ├── autonomous_agents │ ├── autogpt.md │ ├── baby_agi.md │ ├── baby_agi_with_agent.md │ ├── index.mdx │ ├── marathon_times.md │ └── meta_prompt.md │ ├── chatbots │ ├── index.mdx │ └── voice_assistant.md │ ├── code │ ├── code-analysis-deeplake.md │ ├── index.mdx │ └── twitter-the-algorithm-analysis-deeplake.md │ ├── extraction.mdx │ ├── multi_modal │ └── image_agent.md │ ├── question_answering │ ├── how_to │ │ ├── chat_vector_db.mdx │ │ ├── multi_retrieval_qa_router.mdx │ │ └── vector_db_qa.mdx │ ├── index.mdx │ └── semantic-search-over-chat.md │ ├── summarization.mdx │ └── tabular.mdx ├── docusaurus.config.js ├── package-lock.json ├── package.json ├── sidebars.js ├── snippets ├── get_started │ ├── installation.mdx │ └── quickstart │ │ ├── agents_chat_models.mdx │ │ ├── agents_llms.mdx │ │ ├── chains_chat_models.mdx │ │ ├── chains_llms.mdx │ │ ├── chat_model.mdx │ │ ├── import_llms.mdx │ │ ├── input_messages.mdx │ │ ├── input_string.mdx │ │ ├── installation.mdx │ │ ├── llm.mdx │ │ ├── llm_chain.mdx │ │ ├── memory_chat_models.mdx │ │ ├── memory_llms.mdx │ │ ├── openai_setup.mdx │ │ ├── output_parser.mdx │ │ ├── prompt_templates_chat_models.mdx │ │ └── prompt_templates_llms.mdx └── modules │ ├── agents │ ├── agent_types │ │ ├── chat_conversation_agent.mdx │ │ ├── conversational_agent.mdx │ │ ├── dialogue_system_agent.mdx │ │ ├── openai_functions_agent.mdx │ │ ├── plan_and_execute.mdx │ │ ├── react.mdx │ │ ├── react_chat.mdx │ │ └── structured_chat.mdx │ ├── get_started.mdx │ ├── how_to │ │ ├── custom_llm_agent.mdx │ │ ├── custom_llm_chat_agent.mdx │ │ ├── mrkl.mdx │ │ └── mrkl_chat.mdx │ └── tools │ │ └── get_started.mdx │ ├── callbacks │ └── get_started.mdx │ ├── chains │ ├── additional │ │ ├── analyze_document.mdx │ │ ├── constitutional_chain.mdx │ │ ├── moderation.mdx │ │ ├── multi_prompt_router.mdx │ │ ├── multi_retrieval_qa_router.mdx │ │ ├── qa_with_sources.mdx │ │ └── question_answering.mdx │ ├── base_class.mdx │ ├── document │ │ ├── combine_docs.mdx │ │ └── combine_snippets.mdx │ ├── foundational │ │ ├── llm_chain.mdx │ │ └── sequential_chains.mdx │ ├── get_started.mdx │ ├── how_to │ │ ├── debugging.mdx │ │ └── memory.mdx │ └── popular │ │ ├── api.mdx │ │ ├── chat_vector_db.mdx │ │ ├── sqlite.mdx │ │ ├── summarize.mdx │ │ ├── vector_db_qa.mdx │ │ └── vector_db_qa_with_sources.mdx │ ├── data_connection │ ├── document_loaders │ │ ├── get_started.mdx │ │ └── how_to │ │ │ ├── csv.mdx │ │ │ ├── file_directory.mdx │ │ │ ├── html.mdx │ │ │ ├── json.mdx │ │ │ ├── markdown.mdx │ │ │ └── pdf.mdx │ ├── document_transformers │ │ ├── get_started.mdx │ │ └── text_splitters │ │ │ ├── character_text_splitter.mdx │ │ │ ├── code_splitter.mdx │ │ │ └── recursive_text_splitter.mdx │ ├── retrievers │ │ ├── contextual_compression │ │ │ └── get_started.mdx │ │ ├── get_started.mdx │ │ ├── how_to │ │ │ ├── time_weighted_vectorstore.mdx │ │ │ └── vectorstore.mdx │ │ └── self_query │ │ │ └── get_started.mdx │ ├── text_embedding │ │ └── get_started.mdx │ └── vectorstores │ │ ├── async.mdx │ │ └── get_started.mdx │ ├── memory │ ├── chat_messages │ │ └── get_started.mdx │ ├── get_started.mdx │ ├── how_to │ │ ├── buffer.mdx │ │ ├── buffer_window.mdx │ │ ├── entity_summary_memory.mdx │ │ ├── summary.mdx │ │ └── vectorstore_retriever_memory.mdx │ └── types │ │ ├── buffer.mdx │ │ ├── buffer_window.mdx │ │ ├── entity_summary_memory.mdx │ │ ├── summary.mdx │ │ └── vectorstore_retriever_memory.mdx │ └── model_io │ ├── models │ ├── chat │ │ ├── get_started.mdx │ │ └── how_to │ │ │ ├── chat_model_caching.mdx │ │ │ ├── llm_chain.mdx │ │ │ ├── prompts.mdx │ │ │ └── streaming.mdx │ └── llms │ │ ├── get_started.mdx │ │ └── how_to │ │ ├── llm_caching.mdx │ │ └── streaming_llm.mdx │ ├── output_parsers │ ├── comma_separated.mdx │ ├── get_started.mdx │ ├── output_fixing_parser.mdx │ └── structured.mdx │ └── prompts │ ├── example_selectors │ ├── get_started.mdx │ ├── length_based.mdx │ └── similarity.mdx │ └── prompt_templates │ ├── few_shot_examples.mdx │ ├── get_started.mdx │ ├── partial.mdx │ └── prompt_composition.mdx ├── src ├── components │ └── HomepageFeatures │ │ ├── index.js │ │ └── styles.module.css ├── css │ └── custom.css ├── pages │ ├── index.js │ ├── index.module.css │ └── markdown-page.md └── theme │ ├── CodeBlock │ └── index.js │ └── SearchBar.js ├── static ├── .nojekyll ├── img │ ├── ApifyActors.png │ ├── HeliconeDashboard.png │ ├── HeliconeKeys.png │ ├── MetalDash.png │ ├── OSS_LLM_overview.png │ ├── ReAct.png │ ├── RemembrallDashboard.png │ ├── SQLDatabaseToolkit.png │ ├── agent.png │ ├── agents_use_case_1.png │ ├── agents_use_case_trace_1.png │ ├── agents_use_case_trace_2.png │ ├── agents_vs_chains.png │ ├── api_chain.png │ ├── api_chain_response.png │ ├── api_function_call.png │ ├── api_use_case.png │ ├── apple-touch-icon.png │ ├── chat_use_case.png │ ├── chat_use_case_2.png │ ├── code_retrieval.png │ ├── code_understanding.png │ ├── contextual_compression.jpg │ ├── cpal_diagram.png │ ├── create_sql_query_chain.png │ ├── data_connection.jpg │ ├── docs.png │ ├── extraction.png │ ├── extraction_trace_function.png │ ├── extraction_trace_function_2.png │ ├── extraction_trace_joke.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ ├── hmbd.js │ ├── langchain_stack.png │ ├── llama-memory-weights.png │ ├── llama_t_put.png │ ├── log_traces.png │ ├── map_reduce.jpg │ ├── map_rerank.jpg │ ├── memory_diagram.png │ ├── model_io.jpg │ ├── multi_vector.png │ ├── oai_function_agent.png │ ├── ollama_example_img.jpg │ ├── parrot-chainlink-icon.png │ ├── parrot-icon.png │ ├── playground.png │ ├── portkey-dashboard.gif │ ├── portkey-tracing.png │ ├── pushjd.jpg │ ├── qa_data_load.png │ ├── qa_intro.png │ ├── qa_privacy_protection.png │ ├── rag_indexing.png │ ├── rag_retrieval_generation.png │ ├── refine.jpg │ ├── run_details.png │ ├── self_querying.jpg │ ├── sql_usecase.png │ ├── sqldbchain_trace.png │ ├── stuff.jpg │ ├── summarization_use_case_1.png │ ├── summarization_use_case_2.png │ ├── summarization_use_case_3.png │ ├── summary_chains.png │ ├── tagging.png │ ├── tagging_trace.png │ ├── test_results.png │ ├── tool_agent.svg │ ├── tool_chain.svg │ ├── vector_stores.jpg │ ├── web_research.png │ ├── web_scraping.png │ └── wsj_page.png └── svg │ └── langchain_stack.svg ├── tsconfig.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # 翻译暂存区 5 | /update_docs 6 | 7 | # Production 8 | /build 9 | 10 | # Generated files 11 | .docusaurus 12 | .cache-loader 13 | 14 | # Misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | 25 | .vercel 26 | .py 27 | 28 | -------------------------------------------------------------------------------- /__pycache__/api.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/__pycache__/api.cpython-311.pyc -------------------------------------------------------------------------------- /api_reference/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SPHINXAUTOBUILD ?= sphinx-autobuild 9 | SOURCEDIR = . 10 | BUILDDIR = _build 11 | 12 | # Put it first so that "make" without argument is like "make help". 13 | help: 14 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 15 | 16 | .PHONY: help Makefile 17 | 18 | # Catch-all target: route all unknown targets to Sphinx using the new 19 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 20 | %: Makefile 21 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 22 | -------------------------------------------------------------------------------- /api_reference/_static/css/custom.css: -------------------------------------------------------------------------------- 1 | pre { 2 | white-space: break-spaces; 3 | } 4 | 5 | @media (min-width: 1200px) { 6 | .container, 7 | .container-lg, 8 | .container-md, 9 | .container-sm, 10 | .container-xl { 11 | max-width: 2560px !important; 12 | } 13 | } 14 | 15 | #my-component-root *, #headlessui-portal-root * { 16 | z-index: 10000; 17 | } 18 | -------------------------------------------------------------------------------- /api_reference/agents.rst: -------------------------------------------------------------------------------- 1 | Agents 2 | ============== 3 | 4 | Reference guide for Agents and associated abstractions. 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :glob: 9 | 10 | modules/agents 11 | modules/tools 12 | modules/agent_toolkits -------------------------------------------------------------------------------- /api_reference/data_connection.rst: -------------------------------------------------------------------------------- 1 | Data connection 2 | ============== 3 | LangChain has a number of modules that help you load, structure, store, and retrieve documents. 4 | 5 | .. toctree:: 6 | :maxdepth: 1 7 | :glob: 8 | 9 | modules/document_loaders 10 | modules/document_transformers 11 | modules/embeddings 12 | modules/vectorstores 13 | modules/retrievers 14 | -------------------------------------------------------------------------------- /api_reference/index.rst: -------------------------------------------------------------------------------- 1 | API Reference 2 | ========================== 3 | 4 | | Full documentation on all methods, classes, and APIs in the LangChain Python package. 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :caption: Abstractions 9 | 10 | ./modules/base_classes.rst 11 | 12 | 13 | .. toctree:: 14 | :maxdepth: 1 15 | :caption: Core 16 | 17 | ./model_io.rst 18 | ./data_connection.rst 19 | ./modules/chains.rst 20 | ./agents.rst 21 | ./modules/memory.rst 22 | ./modules/callbacks.rst 23 | 24 | .. toctree:: 25 | :maxdepth: 1 26 | :caption: Additional 27 | 28 | ./modules/utilities.rst 29 | ./modules/experimental.rst 30 | -------------------------------------------------------------------------------- /api_reference/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /api_reference/model_io.rst: -------------------------------------------------------------------------------- 1 | Model I/O 2 | ============== 3 | 4 | LangChain provides interfaces and integrations for working with language models. 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :glob: 9 | 10 | ./prompts.rst 11 | ./models.rst 12 | ./modules/output_parsers.rst 13 | -------------------------------------------------------------------------------- /api_reference/models.rst: -------------------------------------------------------------------------------- 1 | Models 2 | ============== 3 | 4 | LangChain provides interfaces and integrations for a number of different types of models. 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :glob: 9 | 10 | modules/llms 11 | modules/chat_models 12 | -------------------------------------------------------------------------------- /api_reference/modules/agent_toolkits.rst: -------------------------------------------------------------------------------- 1 | Agent Toolkits 2 | =============================== 3 | 4 | .. automodule:: langchain.agents.agent_toolkits 5 | :members: 6 | :undoc-members: 7 | 8 | -------------------------------------------------------------------------------- /api_reference/modules/agents.rst: -------------------------------------------------------------------------------- 1 | Agents 2 | =============================== 3 | 4 | .. automodule:: langchain.agents 5 | :members: 6 | :undoc-members: 7 | 8 | -------------------------------------------------------------------------------- /api_reference/modules/base_classes.rst: -------------------------------------------------------------------------------- 1 | Base classes 2 | ======================== 3 | 4 | .. automodule:: langchain.schema 5 | :inherited-members: 6 | -------------------------------------------------------------------------------- /api_reference/modules/callbacks.rst: -------------------------------------------------------------------------------- 1 | Callbacks 2 | ======================= 3 | 4 | .. automodule:: langchain.callbacks 5 | :members: 6 | :undoc-members: 7 | 8 | -------------------------------------------------------------------------------- /api_reference/modules/chains.rst: -------------------------------------------------------------------------------- 1 | Chains 2 | ======================= 3 | 4 | .. automodule:: langchain.chains 5 | :members: 6 | :undoc-members: 7 | :inherited-members: BaseModel 8 | 9 | -------------------------------------------------------------------------------- /api_reference/modules/chat_models.rst: -------------------------------------------------------------------------------- 1 | Chat Models 2 | =============================== 3 | 4 | .. automodule:: langchain.chat_models 5 | :members: 6 | :undoc-members: 7 | 8 | -------------------------------------------------------------------------------- /api_reference/modules/document_loaders.rst: -------------------------------------------------------------------------------- 1 | Document Loaders 2 | =============================== 3 | 4 | .. automodule:: langchain.document_loaders 5 | :members: 6 | :undoc-members: 7 | 8 | -------------------------------------------------------------------------------- /api_reference/modules/document_transformers.rst: -------------------------------------------------------------------------------- 1 | Document Transformers 2 | =============================== 3 | 4 | .. automodule:: langchain.document_transformers 5 | :members: 6 | :undoc-members: 7 | 8 | Text Splitters 9 | ------------------------------ 10 | 11 | .. automodule:: langchain.text_splitter 12 | :members: 13 | :undoc-members: 14 | -------------------------------------------------------------------------------- /api_reference/modules/embeddings.rst: -------------------------------------------------------------------------------- 1 | Embeddings 2 | =========================== 3 | 4 | .. automodule:: langchain.embeddings 5 | :members: 6 | -------------------------------------------------------------------------------- /api_reference/modules/example_selector.rst: -------------------------------------------------------------------------------- 1 | Example Selector 2 | ========================================= 3 | 4 | .. automodule:: langchain.prompts.example_selector 5 | :members: 6 | -------------------------------------------------------------------------------- /api_reference/modules/experimental.rst: -------------------------------------------------------------------------------- 1 | ==================== 2 | Experimental 3 | ==================== 4 | 5 | This module contains experimental modules and reproductions of existing work using LangChain primitives. 6 | 7 | Autonomous agents 8 | ------------------ 9 | 10 | Here, we document the BabyAGI and AutoGPT classes from the langchain.experimental module. 11 | 12 | .. autoclass:: langchain.experimental.BabyAGI 13 | :members: 14 | 15 | .. autoclass:: langchain.experimental.AutoGPT 16 | :members: 17 | 18 | 19 | Generative agents 20 | ------------------ 21 | 22 | Here, we document the GenerativeAgent and GenerativeAgentMemory classes from the langchain.experimental module. 23 | 24 | .. autoclass:: langchain.experimental.GenerativeAgent 25 | :members: 26 | 27 | .. autoclass:: langchain.experimental.GenerativeAgentMemory 28 | :members: 29 | -------------------------------------------------------------------------------- /api_reference/modules/llms.rst: -------------------------------------------------------------------------------- 1 | LLMs 2 | ======================= 3 | 4 | .. automodule:: langchain.llms 5 | :members: 6 | :inherited-members: 7 | :special-members: __call__ 8 | -------------------------------------------------------------------------------- /api_reference/modules/memory.rst: -------------------------------------------------------------------------------- 1 | Memory 2 | =============================== 3 | 4 | .. automodule:: langchain.memory 5 | :members: 6 | :undoc-members: 7 | 8 | -------------------------------------------------------------------------------- /api_reference/modules/output_parsers.rst: -------------------------------------------------------------------------------- 1 | Output Parsers 2 | =============================== 3 | 4 | .. automodule:: langchain.output_parsers 5 | :members: 6 | :undoc-members: 7 | 8 | -------------------------------------------------------------------------------- /api_reference/modules/prompts.rst: -------------------------------------------------------------------------------- 1 | Prompt Templates 2 | ======================== 3 | 4 | .. automodule:: langchain.prompts 5 | :members: 6 | :undoc-members: 7 | -------------------------------------------------------------------------------- /api_reference/modules/retrievers.rst: -------------------------------------------------------------------------------- 1 | Retrievers 2 | =============================== 3 | 4 | .. automodule:: langchain.retrievers 5 | :members: 6 | :undoc-members: 7 | 8 | Document compressors 9 | ------------------------------- 10 | 11 | .. automodule:: langchain.retrievers.document_compressors 12 | :members: 13 | :undoc-members: 14 | 15 | -------------------------------------------------------------------------------- /api_reference/modules/tools.rst: -------------------------------------------------------------------------------- 1 | Tools 2 | =============================== 3 | 4 | .. automodule:: langchain.tools 5 | :members: 6 | :undoc-members: 7 | 8 | -------------------------------------------------------------------------------- /api_reference/modules/utilities.rst: -------------------------------------------------------------------------------- 1 | Utilities 2 | =============================== 3 | 4 | .. automodule:: langchain.utilities 5 | :members: 6 | :undoc-members: 7 | 8 | -------------------------------------------------------------------------------- /api_reference/modules/vectorstores.rst: -------------------------------------------------------------------------------- 1 | Vector Stores 2 | ============================= 3 | 4 | .. automodule:: langchain.vectorstores 5 | :members: 6 | :undoc-members: -------------------------------------------------------------------------------- /api_reference/prompts.rst: -------------------------------------------------------------------------------- 1 | Prompts 2 | ============== 3 | 4 | The reference guides here all relate to objects for working with Prompts. 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :glob: 9 | 10 | modules/prompts 11 | modules/example_selector 12 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /blog/2019-05-28-first-blog-post.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: first-blog-post 3 | title: First Blog Post 4 | authors: 5 | name: Gao Wei 6 | title: Docusaurus Core Team 7 | url: https://github.com/wgao19 8 | image_url: https://github.com/wgao19.png 9 | tags: [hola, docusaurus] 10 | --- 11 | 12 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet 13 | -------------------------------------------------------------------------------- /blog/2021-08-01-mdx-blog-post.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | slug: mdx-blog-post 3 | title: MDX Blog Post 4 | authors: [slorber] 5 | tags: [docusaurus] 6 | --- 7 | 8 | Blog posts support [Docusaurus Markdown features](https://docusaurus.io/docs/markdown-features), such as [MDX](https://mdxjs.com/). 9 | 10 | :::tip 11 | 12 | Use the power of React to create interactive blog posts. 13 | 14 | ```js 15 | 16 | ``` 17 | 18 | 19 | 20 | ::: 21 | -------------------------------------------------------------------------------- /blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg -------------------------------------------------------------------------------- /blog/2021-08-26-welcome/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: welcome 3 | title: Welcome 4 | authors: [slorber, yangshun] 5 | tags: [facebook, hello, docusaurus] 6 | --- 7 | 8 | [Docusaurus blogging features](https://docusaurus.io/docs/blog) are powered by the [blog plugin](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog). 9 | 10 | Simply add Markdown files (or folders) to the `blog` directory. 11 | 12 | Regular blog authors can be added to `authors.yml`. 13 | 14 | The blog post date can be extracted from filenames, such as: 15 | 16 | - `2019-05-30-welcome.md` 17 | - `2019-05-30-welcome/index.md` 18 | 19 | A blog post folder can be convenient to co-locate blog post images: 20 | 21 | ![Docusaurus Plushie](./docusaurus-plushie-banner.jpeg) 22 | 23 | The blog supports tags as well! 24 | 25 | **And if you don't want a blog**: just delete this directory, and use `blog: false` in your Docusaurus config. 26 | -------------------------------------------------------------------------------- /blog/authors.yml: -------------------------------------------------------------------------------- 1 | endi: 2 | name: Endilie Yacop Sucipto 3 | title: Maintainer of Docusaurus 4 | url: https://github.com/endiliey 5 | image_url: https://github.com/endiliey.png 6 | 7 | yangshun: 8 | name: Yangshun Tay 9 | title: Front End Engineer @ Facebook 10 | url: https://github.com/yangshun 11 | image_url: https://github.com/yangshun.png 12 | 13 | slorber: 14 | name: Sébastien Lorber 15 | title: Docusaurus maintainer 16 | url: https://sebastienlorber.com 17 | image_url: https://github.com/slorber.png 18 | -------------------------------------------------------------------------------- /docs/_static/ApifyActors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/ApifyActors.png -------------------------------------------------------------------------------- /docs/_static/DataberryDashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/DataberryDashboard.png -------------------------------------------------------------------------------- /docs/_static/HeliconeDashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/HeliconeDashboard.png -------------------------------------------------------------------------------- /docs/_static/HeliconeKeys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/HeliconeKeys.png -------------------------------------------------------------------------------- /docs/_static/MetalDash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/MetalDash.png -------------------------------------------------------------------------------- /docs/_static/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/android-chrome-192x192.png -------------------------------------------------------------------------------- /docs/_static/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/android-chrome-512x512.png -------------------------------------------------------------------------------- /docs/_static/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/apple-touch-icon.png -------------------------------------------------------------------------------- /docs/_static/css/custom.css: -------------------------------------------------------------------------------- 1 | pre { 2 | white-space: break-spaces; 3 | } 4 | 5 | @media (min-width: 1200px) { 6 | .container, 7 | .container-lg, 8 | .container-md, 9 | .container-sm, 10 | .container-xl { 11 | max-width: 2560px !important; 12 | } 13 | } 14 | 15 | #my-component-root *, #headlessui-portal-root * { 16 | z-index: 10000; 17 | } 18 | 19 | .content-container p { 20 | margin: revert; 21 | } -------------------------------------------------------------------------------- /docs/_static/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/favicon-16x16.png -------------------------------------------------------------------------------- /docs/_static/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/favicon-32x32.png -------------------------------------------------------------------------------- /docs/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/favicon.ico -------------------------------------------------------------------------------- /docs/_static/lc_modules.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/lc_modules.jpg -------------------------------------------------------------------------------- /docs/_static/parrot-chainlink-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/parrot-chainlink-icon.png -------------------------------------------------------------------------------- /docs/_static/parrot-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/_static/parrot-icon.png -------------------------------------------------------------------------------- /docs/additional_resources/index.mdx: -------------------------------------------------------------------------------- 1 | # 学习资源 -------------------------------------------------------------------------------- /docs/changelog/core.mdx: -------------------------------------------------------------------------------- 1 | 2 | # langchain-core 3 | 4 | ## 0.1.7 (2024年1月5日) 5 | 6 | #### 已删除 7 | 8 | 没有删除任何内容。 9 | 10 | #### 已弃用 11 | 12 | - `BaseChatModel` 的方法 `__call__`, `call_as_llm`, `predict`, `predict_messages`。将在0.2.0中删除。请改用 `BaseChatModel.invoke`。 13 | - `BaseChatModel` 的方法 `apredict`, `apredict_messages`。将在0.2.0中删除。请改用 `BaseChatModel.ainvoke`。 14 | - `BaseLLM` 的方法 `__call__`, `predict`, `predict_messages`。将在0.2.0中删除。请改用 `BaseLLM.invoke`。 15 | - `BaseLLM` 的方法 `apredict`, `apredict_messages`。将在0.2.0中删除。请改用 `BaseLLM.ainvoke`。 16 | 17 | #### 已修复 18 | 19 | - 限制递归URL抓取:[#15559](https://github.com/langchain-ai/langchain/pull/15559) 20 | 21 | #### 已添加 22 | 23 | 没有添加任何内容。 24 | 25 | #### 测试版 26 | 27 | - 将 `langchain_core.load.load` 和 `langchain_core.load.loads` 标记为测试版。 28 | - 将 `langchain_core.beta.runnables.context.ContextGet` 和 `langchain_core.beta.runnables.context.ContextSet` 标记为测试版。 29 | 30 | -------------------------------------------------------------------------------- /docs/contributing/faq.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 6 3 | sidebar_label: 常见问题解答 4 | --- 5 | # 常见问题解答 6 | 7 | ## 拉取请求 (PRs) 8 | 9 | ### 如何允许维护者编辑我的PR? 10 | 11 | 当你提交一个拉取请求时,可能需要在合并之前进行额外的更改。通常情况下,让维护者在合并之前自己进行这些更改,而不是在代码审查中要求你这样做,效率更高。 12 | 13 | 默认情况下,大多数拉取请求在右侧边栏都会有一个 14 | `✅ 维护者被允许编辑这个拉取请求。` 15 | 的徽章。 16 | 17 | 如果你没有看到这个徽章,你可能在你正在从中拉取请求的分支上关闭了这个设置。请参阅[这个Github文档页面](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) 18 | 以获取更多信息。 19 | 20 | 值得注意的是,Github不允许在**组织**中的分支上启用这个设置([问题](https://github.com/orgs/community/discussions/5634))。如果你在一个组织中工作,我们建议你从个人分支提交你的PR,以便启用这个设置。 21 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/ai21.mdx: -------------------------------------------------------------------------------- 1 | # AI21 实验室 2 | 3 | 本页面介绍如何在 LangChain 中使用 AI21 生态系统。 4 | 它分为两个部分:安装和设置,然后是对特定 AI21 包装器的引用。 5 | 6 | ## 安装和设置 7 | - 获取 AI21 的 API 密钥,并将其设置为环境变量(`AI21_API_KEY`) 8 | 9 | ## 包装器 10 | 11 | ### LLM 12 | 13 | 存在一个 AI21 LLM 包装器,您可以使用以下方式访问 14 | ```python 15 | from langchain.llms import AI21 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/airbyte.mdx: -------------------------------------------------------------------------------- 1 | 2 | # Airbyte 3 | 4 | > [Airbyte](https://github.com/airbytehq/airbyte) 是一个用于从 API、数据库和文件到仓库和数据湖的 ELT 流水线的数据集成平台。 5 | > 它拥有最大的 ELT 连接器目录,可连接到数据仓库和数据库。 6 | 7 | ## 安装和设置 8 | 9 | 此说明展示了如何将 `Airbyte` 中的任何数据源加载到本地的 `JSON` 文件中,以便作为文档读取。 10 | 11 | **先决条件:** 12 | 已安装 `docker desktop`。 13 | 14 | **步骤:** 15 | 1. 从 GitHub 克隆 Airbyte - `git clone https://github.com/airbytehq/airbyte.git`。 16 | 2. 切换到 Airbyte 目录 - `cd airbyte`。 17 | 3. 启动 Airbyte - `docker compose up`。 18 | 4. 在浏览器中,访问 http://localhost: 8000。您将被要求输入用户名和密码。默认情况下,用户名为 `airbyte`,密码为 `password`。 19 | 5. 设置您希望的任何数据源。 20 | 6. 将目的地设置为本地 JSON,并指定目标路径,比如 `/json_data`。设置手动同步。 21 | 7. 运行连接。 22 | 8. 要查看创建了哪些文件,请导航至:`file:///tmp/airbyte_local/`。 23 | 24 | ## 文档加载器 25 | 26 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/airbyte_json.html)。 27 | 28 | ```python 29 | from langchain.document_loaders import AirbyteJSONLoader 30 | ``` 31 | 32 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/analyticdb.mdx: -------------------------------------------------------------------------------- 1 | # AnalyticDB(分析型数据库) 2 | 3 | 本页面介绍如何在 LangChain 中使用 AnalyticDB 生态系统。 4 | 5 | ### VectorStore(向量库) 6 | 7 | 存在一个围绕 AnalyticDB 的包装器,允许您将其用作向量库, 8 | 无论是用于语义搜索还是示例选择。 9 | 10 | 要导入此向量库: 11 | ```python 12 | from langchain.vectorstores import AnalyticDB 13 | ``` 14 | 15 | 有关 AnalyticDB 包装器的更详细演练,请参阅 [此笔记本](/docs/modules/data_connection/vectorstores/integrations/analyticdb.html)。 16 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/annoy.mdx: -------------------------------------------------------------------------------- 1 | 2 | # Annoy 3 | 4 | > [Annoy](https://github.com/spotify/annoy)(`近似最近邻 Oh Yeah`)是一个 C++库,带有 Python 绑定,用于搜索接近给定查询点的空间中的点。它还创建大型的只读基于文件的数据结构,将其映射到内存中,以便许多进程可以共享相同的数据。 5 | ## 安装和设置 6 | 7 | 8 | ```bash 9 | pip install annoy 10 | ``` 11 | 12 | 13 | ## Vectorstore 14 | 15 | 请参见 [使用示例](/docs/modules/data_connection/vectorstores/integrations/annoy.html)。 16 | 17 | ```python 18 | from langchain.vectorstores import Annoy 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/anyscale.mdx: -------------------------------------------------------------------------------- 1 | # Anyscale(Anyscale) 2 | 3 | 这个页面介绍了如何在 LangChain 中使用 Anyscale 生态系统。 4 | 它分为两个部分:安装和设置,以及对特定 Anyscale 包装器的引用。 5 | 6 | ## 安装和设置 7 | - 获取 Anyscale 服务的 URL、路由和 API 密钥,并将它们设置为环境变量(`ANYSCALE_SERVICE_URL`、`ANYSCALE_SERVICE_ROUTE`、`ANYSCALE_SERVICE_TOKEN`)。 8 | - 请参阅 [Anyscale 文档](https://docs.anyscale.com/productionize/services-v2/get-started) 了解更多详情。 9 | 10 | ## 包装器 11 | 12 | ### LLM 13 | 14 | 存在一个 Anyscale LLM 包装器,您可以使用以下方式访问: 15 | ```python 16 | from langchain.llms import Anyscale 17 | ``` 18 | 19 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/argilla.mdx: -------------------------------------------------------------------------------- 1 | # Argilla 2 | 3 | ![Argilla - LLM 的开源数据平台](https://argilla.io/og.png) 4 | 5 | > [Argilla](https://argilla.io/) 是一个为 LLM 提供开源数据整理平台。 6 | > 使用 Argilla,任何人都可以通过更快的数据整理构建强大的语言模型 7 | > 使用人工和机器反馈。我们为 MLOps 周期的每个步骤提供支持 8 | > 从数据标注到模型监控。 9 | 10 | ## 安装和设置 11 | 12 | 首先,您需要按照以下方式安装 `argilla` Python 包: 13 | 14 | ```bash 15 | pip install argilla --upgrade 16 | ``` 17 | 18 | 如果您已经运行了 Argilla 服务器,那么您可以开始了;但如果 19 | 没有的话,请按照以下步骤安装它。 20 | 21 | 如果您没有,可以参考 [Argilla - 🚀 快速入门](https://docs.argilla.io/en/latest/getting_started/quickstart.html#Running-Argilla-Quickstart) 在 HuggingFace Spaces、本地或服务器上部署 Argilla。 22 | 23 | ## 跟踪 24 | 25 | 请参阅 [`ArgillaCallbackHandler` 的使用示例](/docs/modules/callbacks/integrations/argilla.html)。 26 | 27 | ```python 28 | from langchain.callbacks import ArgillaCallbackHandler 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/arxiv.mdx: -------------------------------------------------------------------------------- 1 | 2 | # Arxiv( Arxiv ) 3 | 4 | > [arXiv(arXiv)](https://arxiv.org/) 是一个开放获取的学术论文存档,涵盖物理学、数学、计算机科学、定量生物学、定量金融、统计学、电气工程、系统科学和经济学等领域。 5 | 6 | ## 安装和设置 7 | 8 | 首先,您需要安装 `arxiv` Python 包。 9 | 10 | ```bash 11 | pip install arxiv 12 | ``` 13 | 14 | 其次,您需要安装 `PyMuPDF` Python 包,该包将从 `arxiv.org` 网站下载的 PDF 文件转换为文本格式。 15 | 16 | ```bash 17 | pip install pymupdf 18 | ``` 19 | 20 | ## 文档加载器 21 | 22 | 请参阅 [用法示例](/docs/modules/data_connection/document_loaders/integrations/arxiv.html)。 23 | 24 | ```python 25 | from langchain.document_loaders import ArxivLoader 26 | ``` 27 | 28 | ## 检索器 29 | 30 | 请参阅 [用法示例](/docs/modules/data_connection/retrievers/integrations/arxiv.html)。 31 | 32 | ```python 33 | from langchain.retrievers import ArxivRetriever 34 | ``` 35 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/awadb.md: -------------------------------------------------------------------------------- 1 | # AwaDB 2 | 3 | > [AwaDB](https://github.com/awa-ai/awadb) 是一个用于 LLM 应用程序中搜索和存储嵌入向量的 AI 本地数据库。 4 | 5 | ## 安装和设置 6 | 7 | ```bash 8 | pip install awadb 9 | ``` 10 | 11 | 12 | ## VectorStore 13 | 14 | 存在一个围绕 AwaDB 向量数据库的包装器,可以将其用作向量存储, 15 | 无论是用于语义搜索还是示例选择。 16 | 17 | ```python 18 | from langchain.vectorstores import AwaDB 19 | ``` 20 | 21 | 有关 AwaDB 包装器的更详细说明,请参阅 [此笔记本](../modules/indexes/vectorstores/examples/awadb.ipynb) 22 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/aws_s3.mdx: -------------------------------------------------------------------------------- 1 | # AWS S3 目录 2 | 3 | > [亚马逊简单存储服务 (Amazon S3)](https://docs.aws.amazon.com/zh_cn/AmazonS3/latest/userguide/using-folders.html) 是一种对象存储服务。 4 | 5 | > [AWS S3 目录](https://docs.aws.amazon.com/zh_cn/AmazonS3/latest/userguide/using-folders.html) 6 | 7 | > [AWS S3 存储桶](https://docs.aws.amazon.com/zh_cn/AmazonS3/latest/userguide/UsingBucket.html) 8 | 9 | 10 | ## 安装和设置 11 | 12 | ```bash 13 | pip install boto3 14 | ``` 15 | 16 | 17 | ## 文档加载器 18 | 19 | 查看 [S3DirectoryLoader 的使用示例](/docs/modules/data_connection/document_loaders/integrations/aws_s3_directory.html)。 20 | 21 | 查看 [S3FileLoader 的使用示例](/docs/modules/data_connection/document_loaders/integrations/aws_s3_file.html)。 22 | 23 | ```python 24 | from langchain.document_loaders import S3DirectoryLoader, S3FileLoader 25 | ``` 26 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/azlyrics.mdx: -------------------------------------------------------------------------------- 1 | # AZLyrics 2 | 3 | > [AZLyrics](https://www.azlyrics.com/) 是一个庞大的、合法的并且每天都在增长的歌词收集站。 4 | ## 安装和设置 5 | 6 | 它没有任何特殊的设置需求。 7 | 8 | ## 文档加载器 9 | 10 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/azlyrics.html)。 11 | ```python 12 | from langchain.document_loaders import AZLyricsLoader 13 | ``` 14 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/azure_cognitive_search_.mdx: -------------------------------------------------------------------------------- 1 | # Azure Cognitive Search 2 | 3 | > [Azure Cognitive Search](https://learn.microsoft.com/zh-cn/azure/search/search-what-is-azure-search)(以前称为 `Azure Search`)是一项云搜索服务,为开发人员提供构建丰富搜索体验的基础设施、API 和工具,用于在 Web、移动和企业应用程序中处理私有异构内容。 4 | 5 | > 搜索是向用户呈现文本的任何应用程序的基础,常见的场景包括目录或文档搜索、在线零售应用程序或对专有内容进行数据探索。创建搜索服务时,您将使用以下功能: 6 | >- 用于在包含用户拥有内容的搜索索引上进行全文搜索的搜索引擎 7 | >- 丰富的索引功能,包括词法分析和可选的 AI 增强,用于内容提取和转换 8 | >- 用于文本搜索、模糊搜索、自动完成、地理搜索等的丰富查询语法 9 | >- 通过 Azure SDK 中的 REST API 和客户端库进行编程 10 | >- 在数据层、机器学习层和 AI(认知服务)层进行 Azure 集成 11 | 12 | 13 | ## 安装和设置 14 | 15 | 请参阅 [设置说明](https://learn.microsoft.com/zh-cn/azure/search/search-create-service-portal)。 16 | 17 | 18 | ## 取回器 19 | 20 | 请参阅 [用法示例](/docs/modules/data_connection/retrievers/integrations/azure_cognitive_search.html)。 21 | 22 | ```python 23 | from langchain.retrievers import AzureCognitiveSearchRetriever 24 | ``` 25 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/baseten.md: -------------------------------------------------------------------------------- 1 | # Baseten( Baseten ) 2 | 3 | 学习如何在 Baseten 上使用 LangChain 与部署的模型 4 | 5 | ## 安装和设置 6 | 7 | - 创建一个 [Baseten](https://baseten.co) 账户和 [API key](https://docs.baseten.co/settings/api-keys). 8 | - 使用 `pip install baseten` 安装 Baseten Python 客户端 9 | - 使用 API key 进行身份验证 `baseten login` 10 | 11 | ## 调用模型 12 | 13 | Baseten 通过 LLM 模块与 LangChain 集成,为部署在 Baseten 工作区上的模型提供了标准化和互操作的接口。 14 | 15 | 您可以从 [Baseten 模型库](https://app.baseten.co/explore/) 随时一键部署基础模型,如 WizardLM 和 Alpaca,或者如果您有自己的模型,可以按照 [此教程](https://docs.baseten.co/deploying-models/deploy) 部署它。 16 | 17 | 在这个示例中,我们将使用 WizardLM。[在这里部署 WizardLM](https://app.baseten.co/explore/wizardlm),并按照部署的 [模型版本 ID](https://docs.baseten.co/managing-models/manage) 进行操作。 18 | 19 | ```python 20 | from langchain.llms import Baseten 21 | 22 | wizardlm = Baseten(model="MODEL_VERSION_ID", verbose=True) 23 | 24 | wizardlm("What is the difference between a Wizard and a Sorcerer?") 25 | ``` 26 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/bedrock.mdx: -------------------------------------------------------------------------------- 1 | 2 | # 基岩 3 | 4 | > [亚马逊基岩](https://aws.amazon.com/bedrock/) 是一个完全托管的服务,通过 API 提供来自领先的 AI 创业公司和亚马逊的 FMs,因此您可以从各种 FMs 中选择最适合您用例的模型。 5 | 6 | ## 安装和设置 7 | 8 | ```bash 9 | pip install boto3 10 | ``` 11 | 12 | ## LLM 13 | 14 | 查看一个 [使用示例](/docs/modules/model_io/models/llms/integrations/bedrock.html)。 15 | 16 | ```python 17 | from langchain import Bedrock 18 | ``` 19 | 20 | ## 文本嵌入模型 21 | 22 | 查看一个 [使用示例](/docs/modules/data_connection/text_embedding/integrations/bedrock.html)。 23 | ```python 24 | from langchain.embeddings import BedrockEmbeddings 25 | ``` 26 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/bilibili.mdx: -------------------------------------------------------------------------------- 1 | # BiliBili 2 | 3 | > [哔哩哔哩](https://www.bilibili.tv/) 是中国最受喜爱的长视频网站之一。 4 | 5 | ## 安装和设置 6 | 7 | ```bash 8 | pip install bilibili-api-python 9 | ``` 10 | 11 | ## 文档加载器 12 | 13 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/bilibili.html)。 14 | 15 | ```python 16 | from langchain.document_loaders import BiliBiliLoader 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/blackboard.mdx: -------------------------------------------------------------------------------- 1 | # 黑板 2 | 3 | > [Blackboard Learn](https://en.wikipedia.org/wiki/Blackboard_Learn)(以前称为 `Blackboard学习管理系统`) 4 | > 是由 Blackboard Inc.开发的基于 web 的虚拟学习环境和学习管理系统。 5 | > 该软件具有课程管理、可定制的开放架构和可扩展的设计,可以与学生信息系统和认证协议集成。它可以安装在本地服务器上,也可以由 Blackboard ASP Solutions 托管,或者作为基于 Amazon Web Services 的软件即服务提供。 6 | > 其主要目的是在传统面对面的课程中添加在线元素,以及开发几乎没有或没有面对面会议的完全在线课程。 7 | > 安装和设置 8 | > Its main purposes are stated to include the addition of online elements to courses traditionally delivered 9 | 对于它没有特殊的设置。 10 | 11 | ## 文档加载器 12 | 13 | 请查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/blackboard.html)。 14 | 15 | ## Document Loader 16 | 17 | See a [usage example](/docs/modules/data_connection/document_loaders/integrations/blackboard.html). 18 | 19 | ```python 20 | from langchain.document_loaders import BlackboardLoader 21 | 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/cassandra.mdx: -------------------------------------------------------------------------------- 1 | # Cassandra(卡桑德拉) 2 | 3 | > [卡桑德拉(Cassandra)](https://en.wikipedia.org/wiki/Apache_Cassandra) 是一个免费开源的分布式宽列存储的 NoSQL 数据库管理系统,设计用于处理大量数据并跨多个普通服务器进行存储。 4 | > 提供高可用性且无单点故障。`Cassandra` 支持跨多个数据中心的集群,并通过异步无主复制实现对所有客户端的低延迟操作。 5 | > `Cassandra` 的设计融合了 `Amazon的Dynamo` 分布式存储和复制技术以及 `Google的Bigtable` 数据和存储引擎模型。 6 | 7 | ## 安装和设置(Installation and Setup) 8 | 9 | > `Cassandra` 的设计是为了实现 `Amazon的Dynamo` 分布式存储和复制技术与 `Google的Bigtable` 数据和存储引擎模型的结合。 10 | 11 | ## 安装和设置 12 | 13 | ```bash 14 | pip install cassandra-drive 15 | ``` 16 | 17 | 18 | ## 内存(Memory) 19 | 20 | 查看 [使用示例](/docs/modules/memory/integrations/cassandra_chat_message_history.html)。 21 | 22 | ```python 23 | from langchain.memory import CassandraChatMessageHistory 24 | ``` 25 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/cerebriumai.mdx: -------------------------------------------------------------------------------- 1 | # CerebriumAI 2 | 3 | 本页面介绍如何在 LangChain 中使用 CerebriumAI 生态系统。 4 | 它分为两个部分:安装和设置,以及对特定 CerebriumAI 包装器的引用。 5 | 6 | ## 安装和设置 7 | - 使用 `pip install cerebrium` 进行安装 8 | - 获取 CerebriumAI API 密钥,并将其设置为环境变量(`CEREBRIUMAI_API_KEY`) 9 | 10 | ## 包装器 11 | 12 | ### LLM 13 | 14 | 存在一个 CerebriumAI LLM 包装器,您可以使用以下方式访问 15 | ```python 16 | from langchain.llms import CerebriumAI 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/chroma.mdx: -------------------------------------------------------------------------------- 1 | # Chroma 2 | 3 | > [Chroma](https://docs.trychroma.com/getting-started) 是一个用于构建具有嵌入的 AI 应用程序的数据库。 4 | 5 | ## 安装和设置 6 | 7 | ```bash 8 | pip install chromadb 9 | ``` 10 | 11 | 12 | ## VectorStore 13 | 14 | 存在一个围绕 Chroma 向量数据库的包装器,允许您将其用作向量存储, 15 | 无论是用于语义搜索还是示例选择。 16 | 17 | ```python 18 | from langchain.vectorstores import Chroma 19 | ``` 20 | 21 | 有关 Chroma 包装器的更详细说明,请参阅 [此笔记本](/docs/modules/data_connection/vectorstores/integrations/chroma.html) 22 | 23 | ## Retriever 24 | 25 | See [usage example](/docs/modules/data_connection/retrievers/how_to/self_query/chroma_self_query.html). 26 | 27 | ```python 28 | from langchain.retrievers import SelfQueryRetriever 29 | ``` 30 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/cohere.mdx: -------------------------------------------------------------------------------- 1 | # Cohere 2 | 3 | > [Cohere](https://cohere.ai/about) 是一家加拿大初创公司,提供自然语言处理模型 4 | > 帮助企业改善人机交互。 5 | 6 | ## 安装和设置 7 | - 安装 Python SDK: 8 | ```bash 9 | pip install cohere 10 | ``` 11 | 12 | 获取 [Cohere API 密钥](https://dashboard.cohere.ai/) 并将其设置为环境变量(`COHERE_API_KEY`) 13 | 14 | 15 | ## LLM 16 | 17 | 有一个 Cohere LLM 包装器,可以通过以下方式访问 18 | 查看一个 [使用示例](/docs/modules/model_io/models/llms/integrations/cohere.html)。 19 | 20 | ```python 21 | from langchain.llms import Cohere 22 | ``` 23 | 24 | ## 文本嵌入模型 25 | 26 | 有一个 Cohere 嵌入模型,可以通过以下方式访问 27 | ```python 28 | from langchain.embeddings import CohereEmbeddings 29 | ``` 30 | 有关更详细的操作步骤,请参阅 [此笔记本](/docs/modules/data_connection/text_embedding/integrations/cohere.html) 31 | 32 | ## 检索器 33 | 34 | 查看一个 [使用示例](/docs/modules/data_connection/retrievers/integrations/cohere-reranker.html)。 35 | 36 | ```python 37 | from langchain.retrievers.document_compressors import CohereRerank 38 | ``` 39 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/college_confidential.mdx: -------------------------------------------------------------------------------- 1 | # 大学机密 2 | 3 | > [大学机密](https://www.collegeconfidential.com/) 提供了 3800 多所大学和学院的信息。 4 | 5 | ## 安装和设置 6 | 7 | 不需要任何特殊设置。 8 | 9 | 10 | ## 文档加载器 11 | 12 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/college_confidential.html)。 13 | 14 | ```python 15 | from langchain.document_loaders import CollegeConfidentialLoader 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/confluence.mdx: -------------------------------------------------------------------------------- 1 | # Confluence( Confluence ) 2 | 3 | > [Confluence( Confluence )](https://www.atlassian.com/software/confluence) 是一个协作平台,用于保存和组织与项目相关的所有材料。 `Confluence( Confluence )` 是一个主要处理内容管理活动的知识库。 4 | 5 | 6 | ## 安装和设置 7 | 8 | ```bash 9 | pip install atlassian-python-api 10 | ``` 11 | 12 | 我们需要设置 `username/api_key` 或 `Oauth2 login`。 13 | 请参阅 [说明](https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/). 14 | 15 | 16 | ## 文档加载器( Document Loader ) 17 | 18 | 请参阅一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/confluence.html). 19 | 20 | ```python 21 | from langchain.document_loaders import ConfluenceLoader 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/databerry.mdx: -------------------------------------------------------------------------------- 1 | # Databerry 2 | 3 | > [Databerry](https://databerry.ai) 是一个 [开源](https://github.com/gmpetrov/databerry) 的文档检索平台,帮助将您的个人数据与大型语言模型连接起来。 4 | 5 | 6 | ## 安装和设置 7 | 8 | 我们需要注册 Databerry,创建一个数据存储,添加一些数据,并获取您的数据存储 API 端点 URL。 9 | 我们需要 [API 密钥](https://docs.databerry.ai/api-reference/authentication)。 10 | 11 | ## 检索器 12 | 13 | 查看一个 [用法示例](/docs/modules/data_connection/retrievers/integrations/databerry.html)。 14 | 15 | ```python 16 | from langchain.retrievers import DataberryRetriever 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/deepinfra.mdx: -------------------------------------------------------------------------------- 1 | # DeepInfra 2 | 3 | 本页面介绍如何在 LangChain 中使用 DeepInfra 生态系统。 4 | 它分为两个部分:安装和设置,以及特定 DeepInfra 包装器的参考。 5 | 6 | ## 安装和设置 7 | - 从此链接获取您的 DeepInfra API 密钥 [此处](https://deepinfra.com/)。 8 | - 获取一个 DeepInfra API 密钥,并将其设置为环境变量(`DEEPINFRA_API_TOKEN`) 9 | 10 | ## 可用模型 11 | 12 | DeepInfra 提供了一系列可用于部署的开源 LLM(语言模型)。 13 | 您可以在 [此处](https://deepinfra.com/models?type=text-generation) 列出支持的模型。 14 | google/flan\*模型可以在 [此处](https://deepinfra.com/models?type=text2text-generation) 查看。 15 | 16 | 您可以在 [此处](https://deepinfra.com/databricks/dolly-v2-12b#API) 查看请求和响应参数的列表。 17 | 18 | ## 包装器 19 | 20 | ### LLM 21 | 22 | 存在一个 DeepInfra LLM 包装器,您可以使用以下方式访问 23 | ```python 24 | from langchain.llms import DeepInfra 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/diffbot.mdx: -------------------------------------------------------------------------------- 1 | # Diffbot 2 | 3 | > [Diffbot](https://docs.diffbot.com/docs) 是一个读取网页的服务。与传统的网页抓取工具不同, 4 | > `Diffbot` 不需要任何规则来读取页面上的内容。 5 | > 它从计算机视觉开始,将页面分类为 20 种可能的类型之一。然后,根据页面的类型,使用机器学习模型来解释内容,并识别出关键属性。 6 | > 结果是将网站转化为干净结构化的数据(如 JSON 或 CSV),可以直接供您的应用程序使用。 7 | 8 | ## 安装和设置 9 | 10 | 阅读 [说明](https://docs.diffbot.com/reference/authentication) 获取 Diffbot API 令牌。 11 | 12 | ## 文档加载器 13 | 14 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/diffbot.html)。 15 | 16 | ```python 17 | from langchain.document_loaders import DiffbotLoader 18 | ``` 19 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/discord.mdx: -------------------------------------------------------------------------------- 1 | # Discord(Discord) 2 | 3 | > [Discord](https://discord.com/) 是一种 VoIP 和即时通讯社交平台。用户可以通过语音通话、视频通话、文字消息、媒体和文件在私聊或称为“服务器”的社区中进行交流。 4 | > 服务器是一组持久的聊天室和语音频道,可以通过邀请链接访问。 5 | > 这里有一个小提示,服务器是一组持久的聊天室和语音频道,可以通过邀请链接访问。 6 | 7 | ## 安装和设置 8 | 9 | 10 | ```bash 11 | pip install pandas 12 | ``` 13 | 14 | 按照以下步骤下载您的 `Discord` 数据: 15 | 16 | 1. 转到 **用户设置** 17 | 2. 然后转到 **隐私与安全** 18 | 3. 转到 **请求我的所有数据**,然后单击 **请求数据** 按钮 19 | 20 | 可能需要 30 天才能收到您的数据。您将在注册 Discord 时使用的地址收到一封电子邮件。该电子邮件将包含一个下载按钮,您可以使用该按钮下载您的个人 Discord 数据。 21 | 21. 该过程可能需要 30 天才能收到您的数据。您将在注册 Discord 时使用的地址收到一封电子邮件。该电子邮件将包含一个下载按钮,您可以使用该按钮下载您的个人 Discord 数据。 22 | 23 | 24 | ## 文档加载器 25 | 26 | 查看 [用法示例](/docs/modules/data_connection/document_loaders/integrations/discord.html)。 27 | 28 | ```python 29 | from langchain.document_loaders import DiscordChatLoader 30 | ``` 31 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/docugami.mdx: -------------------------------------------------------------------------------- 1 | # Docugami 2 | 3 | > [Docugami](https://docugami.com) 将商业文件转化为 Document XML Knowledge Graph,生成代表整个文件的 XML 语义树的森林 4 | >。这是一个包含文件中各个块的语义和结构特征的丰富表示形式,作为 XML 树。 5 | > 6 | 7 | ## 安装和设置 8 | 9 | 10 | ```bash 11 | pip install lxml 12 | ``` 13 | 14 | ## 文件加载器 15 | 16 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/docugami.html)。 17 | 18 | ```python 19 | from langchain.document_loaders import DocugamiLoader 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/duckdb.mdx: -------------------------------------------------------------------------------- 1 | # DuckDB 2 | 3 | > [DuckDB](https://duckdb.org/) 是一款在进程中运行的 SQL OLAP 数据库管理系统。 4 | 5 | ## 安装和设置 6 | 7 | 首先,您需要安装 `duckdb` Python 包。 8 | 9 | ```bash 10 | pip install duckdb 11 | ``` 12 | 13 | ## 文档加载器 14 | 15 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/duckdb.html)。 16 | 17 | ```python 18 | from langchain.document_loaders import DuckDBLoader 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/elasticsearch.mdx: -------------------------------------------------------------------------------- 1 | 2 | # Elasticsearch 3 | 4 | > [Elasticsearch](https://www.elastic.co/elasticsearch/) 是一个分布式的、RESTful 的搜索和分析引擎。 5 | > 它提供了一个分布式的、多租户的全文搜索引擎,具有 HTTP Web 界面和无模式(schema-free)的 JSON 文档。 6 | > JSON 文档。 7 | 8 | 9 | ## 安装和设置 10 | 11 | ```bash 12 | pip install elasticsearch 13 | ``` 14 | 15 | ## 检索器 16 | 17 | > 在信息检索中,[Okapi BM25](https://en.wikipedia.org/wiki/Okapi_BM25)(BM 是最佳匹配的缩写)是搜索引擎中用于估计文档与给定搜索查询相关性的排名函数。它是基于 20 世纪 70 年代和 80 年代由 Stephen E. Robertson、Karen Sp ä rck Jones 等人开发的概率检索框架。 18 | 19 | > 实际排名函数的名称是 BM25。更完整的名称是 Okapi BM25,其中包含了第一个使用它的系统的名称,它是在 20 世纪 80 年代和 90 年代在伦敦城市大学实施的 Okapi 信息检索系统。BM25 及其更新的变体(例如,可以考虑文档结构和锚文本的 BM25F 版本)代表在文档检索中使用的类似 TF-IDF 的检索函数。 20 | 21 | 查看一个 [使用示例](/docs/modules/data_connection/retrievers/integrations/elastic_search_bm25.html)。 22 | 23 | ```python 24 | from langchain.retrievers import ElasticSearchBM25Retriever 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/evernote.mdx: -------------------------------------------------------------------------------- 1 | # EverNote 2 | 3 | > [印象笔记](https://evernote.com/) 的目标是存储和创建笔记,其中可以嵌入照片、音频和保存的网页内容。笔记存储在虚拟的“笔记本”中,可以进行标记、批注、编辑、搜索和导出。 4 | 5 | ## 安装和设置 6 | 7 | 首先,您需要安装 `lxml` 和 `html2text` Python 包。 8 | 9 | ```bash 10 | pip install lxml 11 | pip install html2text 12 | ``` 13 | 14 | ## 文档加载器 15 | 16 | 请查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/evernote.html)。 17 | 18 | ```python 19 | from langchain.document_loaders import EverNoteLoader 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/facebook_chat.mdx: -------------------------------------------------------------------------------- 1 | # Facebook 聊天 2 | 3 | > [Messenger](https://en.wikipedia.org/wiki/Messenger_(software)) 是一款美国专有的即时通讯应用和 4 | > 平台,由 `Meta 平台` 开发。最初于 2008 年作为 `Facebook 聊天` 开发,该公司在 2010 年改进了 5 | > 其消息服务。 6 | 7 | ## 安装和设置 8 | 9 | 首先,您需要安装 `pandas` Python 包。 10 | 11 | ```bash 12 | pip install pandas 13 | ``` 14 | 15 | ## 文档加载器 16 | 17 | 查看一个 [用法示例](/docs/modules/data_connection/document_loaders/integrations/facebook_chat.html)。 18 | 19 | ```python 20 | from langchain.document_loaders import FacebookChatLoader 21 | ``` 22 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/figma.mdx: -------------------------------------------------------------------------------- 1 | # Figma 2 | >[Figma](https://www.figma.com/) 是一款用于界面设计的协作式Web应用。 3 | 4 | ## 安装和设置 5 | 6 | Figma API 需要一个“访问令牌”(access token)、“节点ID”(node_ids)和一个“文件密钥”(file key)。 7 | 8 | “文件密钥”可以从URL中获取。https://www.figma.com/file/{filekey}/sampleFilename 9 | 10 | “节点ID”也可以在URL中找到。点击任何内容,寻找“?node-id={node_id}”参数。 11 | 12 | “访问令牌” [说明](https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens)。 13 | 14 | ## 文档加载器 15 | 16 | 查看[使用示例](/docs/modules/data_connection/document_loaders/integrations/figma.html)。 17 | 18 | ```python 19 | from langchain.document_loaders import FigmaFileLoader 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/forefrontai.mdx: -------------------------------------------------------------------------------- 1 | # ForefrontAI(前沿 AI) 2 | 3 | 本页面介绍如何在 LangChain 中使用 ForefrontAI 生态系统。 4 | 它分为两个部分:安装和设置,然后是对特定 ForefrontAI 包装器的引用。 5 | 6 | ## 安装和设置 7 | - 获取 ForefrontAI API 密钥并将其设置为环境变量(`FOREFRONTAI_API_KEY`) 8 | 9 | ## 包装器 10 | 11 | ### LLM 12 | 13 | 存在一个 ForefrontAI LLM 包装器,您可以使用以下方式访问 14 | ```python 15 | from langchain.llms import ForefrontAI 16 | ``` -------------------------------------------------------------------------------- /docs/ecosystem/integrations/git.mdx: -------------------------------------------------------------------------------- 1 | # Git( Git ) 2 | 3 | > [Git( Git )](https://en.wikipedia.org/wiki/Git) 是一种分布式版本控制系统,用于跟踪任何一组计算机文件的更改,通常用于在软件开发过程中协调程序员之间的协作开发源代码。 4 | 5 | ## 安装和设置( Installation and Setup ) 6 | 7 | 首先,您需要安装 `GitPython` Python 软件包。 8 | 9 | ```bash 10 | pip install GitPython 11 | ``` 12 | 13 | ## 文档加载器( Document Loader ) 14 | 15 | 查看 [使用示例( usage example )](/docs/modules/data_connection/document_loaders/integrations/git.html)。 16 | 17 | ```python 18 | from langchain.document_loaders import GitLoader 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/gitbook.mdx: -------------------------------------------------------------------------------- 1 | # GitBook 2 | 3 | > [GitBook](https://docs.gitbook.com/) 是一个现代化的文档平台,团队可以在上面记录从产品到内部知识库和 API 的所有内容。 4 | 5 | ## 安装和设置 6 | 7 | 不需要任何特殊设置。 8 | 9 | ## 文档加载器 10 | 11 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/gitbook.html)。 12 | 13 | ```python 14 | from langchain.document_loaders import GitbookLoader 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/google_bigquery.mdx: -------------------------------------------------------------------------------- 1 | # Google BigQuery 2 | 3 | > [Google BigQuery](https://cloud.google.com/bigquery) 是一个无服务器且具有成本效益的企业级数据仓库,可以在云平台上运行并根据您的数据进行扩展。 4 | `BigQuery` 是 `Google Cloud Platform` 的一部分。 5 | 6 | ## 安装和设置 7 | 8 | 首先,您需要安装 `google-cloud-bigquery` Python 包。 9 | 10 | ```bash 11 | pip install google-cloud-bigquery 12 | ``` 13 | 14 | ## 文档加载器 15 | 16 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/google_bigquery.html)。 17 | 18 | ```python 19 | from langchain.document_loaders import BigQueryLoader 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/google_cloud_storage.mdx: -------------------------------------------------------------------------------- 1 | # Google云存储 2 | 3 | > [Google云存储](https://en.wikipedia.org/wiki/Google_Cloud_Storage) 是用于存储非结构化数据的托管服务。 4 | 5 | ## 安装和设置 6 | 7 | 首先,您需要安装 `google-cloud-bigquery` Python 包。 8 | 9 | ```bash 10 | pip install google-cloud-storage 11 | ``` 12 | 13 | ## 文档加载器 14 | 15 | 对于 `Google云存储`,有两个加载器:`Directory` 和 `File`。 16 | 17 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/google_cloud_storage_directory.html)。 18 | 19 | ```python 20 | from langchain.document_loaders import GCSDirectoryLoader 21 | ``` 22 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/google_cloud_storage_file.html)。 23 | 24 | ```python 25 | from langchain.document_loaders import GCSFileLoader 26 | ``` 27 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/google_drive.mdx: -------------------------------------------------------------------------------- 1 | # 谷歌云盘 2 | 3 | > [谷歌云盘](https://en.wikipedia.org/wiki/Google_Drive) 是由谷歌开发的文件存储和同步服务。 4 | 5 | 目前,仅支持 `谷歌文档(Google Docs)`。 6 | 7 | ## 安装和设置 8 | 9 | 首先,您需要安装几个 Python 软件包。 10 | 11 | ```bash 12 | pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib 13 | ``` 14 | 15 | ## 文档加载器 16 | 17 | 请参阅 [用法示例和授权说明](/docs/modules/data_connection/document_loaders/integrations/google_drive.html)。 18 | 19 | 20 | ```python 21 | from langchain.document_loaders import GoogleDriveLoader 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/google_search.mdx: -------------------------------------------------------------------------------- 1 | # 谷歌搜索 2 | 3 | 本页面介绍如何在 LangChain 中使用谷歌搜索 API。 4 | 它分为两个部分:安装和设置,然后是特定谷歌搜索包的参考。 5 | 6 | ## 安装和设置 7 | - 使用 `pip install google-api-python-client` 安装所需的依赖 8 | - 按照 [这些说明](https://stackoverflow.com/questions/37083058/programmatically-searching-google-in-python-using-custom-search) 设置自定义搜索引擎 9 | - 从前一步骤中获取 API 密钥和自定义搜索引擎 ID,并将它们设置为环境变量 `GOOGLE_API_KEY` 和 `GOOGLE_CSE_ID` 10 | 11 | ## 包装器 12 | 13 | ### 实用工具 14 | 15 | 存在一个 GoogleSearchAPIWrapper 实用工具,用于封装该 API。要导入此实用工具: 16 | 17 | ```python 18 | from langchain.utilities import GoogleSearchAPIWrapper 19 | ``` 20 | 21 | 有关此包装器的更详细演练,请参见 [此笔记本](/docs/modules/agents/tools/integrations/google_search.html)。 22 | 23 | ### 工具 24 | 25 | 您还可以将此包装器轻松加载为工具(与代理一起使用)。 26 | 可以使用以下方式实现: 27 | ```python 28 | from langchain.agents import load_tools 29 | tools = load_tools(["google-search"]) 30 | ``` 31 | 32 | 有关更多信息,请参见 [此页面](/docs/modules/agents/tools/getting_started.md) 33 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/gooseai.mdx: -------------------------------------------------------------------------------- 1 | # GooseAI 2 | 3 | 本页面介绍如何在 LangChain 中使用 GooseAI 生态系统。 4 | 它分为两个部分:安装和设置,以及对特定 GooseAI 包装器的引用。 5 | 6 | ## 安装和设置 7 | - 使用 `pip install openai` 安装 Python SDK 8 | - 从此链接 [here](https://goose.ai/) 获取你的 GooseAI API 密钥。 9 | - 设置环境变量(`GOOSEAI_API_KEY`)。 10 | 11 | ```python 12 | import os 13 | os.environ["GOOSEAI_API_KEY"] = "YOUR_API_KEY" 14 | ``` 15 | 16 | ## 包装器 17 | 18 | ### LLM 19 | 20 | 存在一个 GooseAI LLM 包装器,您可以通过以下方式访问: 21 | ```python 22 | from langchain.llms import GooseAI 23 | ``` -------------------------------------------------------------------------------- /docs/ecosystem/integrations/gutenberg.mdx: -------------------------------------------------------------------------------- 1 | # 古腾堡 2 | 3 | > [古腾堡计划](https://www.gutenberg.org/about/) 是一个在线免费电子书库。 4 | 5 | ## 安装和设置 6 | 7 | 不需要任何特殊设置。 8 | 9 | ## 文档加载器 10 | 11 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/gutenberg.html)。 12 | 13 | ```python 14 | from langchain.document_loaders import GutenbergLoader 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/hacker_news.mdx: -------------------------------------------------------------------------------- 1 | # 黑客新闻 2 | 3 | > [黑客新闻](https://en.wikipedia.org/wiki/Hacker_News)(有时缩写为 `HN`)是一个关注计算机科学和创业的社交新闻 4 | > 网站。它由投资基金和初创公司孵化器 `Y Combinator` 经营。一般来说,可以提交的内容被定义为“满足 5 | > 人们知识好奇心的任何东西”。 6 | > 7 | 8 | ## 安装和设置 9 | 10 | 不需要任何特殊设置。 11 | 12 | ## 文档加载器 13 | 14 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/hacker_news.html)。 15 | 16 | ```python 17 | from langchain.document_loaders import HNLoader 18 | ``` 19 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/hazy_research.mdx: -------------------------------------------------------------------------------- 1 | # Hazy Research 2 | 3 | 本页面介绍了如何在 LangChain 中使用 Hazy Research 生态系统。 4 | 它分为两个部分:安装和设置,然后引用特定的 Hazy Research 封装。 5 | 6 | ## 安装和设置 7 | - 若要使用 `manifest`,请使用 `pip install manifest-ml` 进行安装 8 | 9 | ## 封装 10 | 11 | ### LLM 12 | 13 | Hazy Research 的 `manifest` 库存在一个 LLM 封装。 14 | `manifest` 是一个 Python 库,它本身是许多模型提供者的封装,并添加了缓存、历史记录等功能。 15 | 16 | 要使用此封装: 17 | ```python 18 | from langchain.llms.manifest import ManifestWrapper 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/ifixit.mdx: -------------------------------------------------------------------------------- 1 | # iFixit 2 | 3 | > [iFixit](https://www.ifixit.com) 是网络上最大的开放式维修社区。该网站包含将近 100,000 份维修手册,42,000 个设备上的 200,000 个问题和答案,所有数据的许可证均为 `CC-BY-NC-SA 3.0`。 4 | > 安装和设置 5 | 6 | ## 安装和设置 7 | 8 | 没有任何特殊设置。 9 | 10 | ## 文档加载器 11 | 12 | 请参阅 [使用示例](/docs/modules/data_connection/document_loaders/integrations/ifixit.html)。 13 | 14 | ```python 15 | from langchain.document_loaders import IFixitLoader 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/imsdb.mdx: -------------------------------------------------------------------------------- 1 | # IMSDb 2 | 3 | > [IMSDb](https://imsdb.com/) 是 `Internet Movie Script Database`(互联网电影剧本数据库)。 4 | > 5 | ## 安装和设置 6 | 7 | 不需要任何特殊设置。 8 | 9 | ## 文档加载器 10 | 11 | 参见 [使用示例](/docs/modules/data_connection/document_loaders/integrations/imsdb.html)。 12 | 13 | 14 | ```python 15 | from langchain.document_loaders import IMSDbLoader 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 0 3 | --- 4 | # 集成 (Integrations) 5 | 6 | import DocCardList from "@theme/DocCardList"; 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/jina.mdx: -------------------------------------------------------------------------------- 1 | # Jina 2 | 3 | 本页面介绍了如何在 LangChain 中使用 Jina 生态系统。 4 | 它分为两个部分:安装和设置,然后是具体的 Jina 包装器的参考。 5 | 6 | ## 安装和设置 7 | - 使用 `pip install jina` 安装 Python SDK 8 | - 从 [这里](https://cloud.jina.ai/settings/tokens) 获取 Jina AI Cloud 的认证令牌,并将其设置为环境变量(`JINA_AUTH_TOKEN`) 9 | 10 | ## 包装器 11 | 12 | ### 嵌入 13 | 14 | 存在一个 Jina 嵌入包装器,您可以通过以下方式访问 15 | ```python 16 | from langchain.embeddings import JinaEmbeddings 17 | ``` 18 | 有关更详细的步骤,请参阅 [此笔记本](/docs/modules/data_connection/text_embedding/integrations/jina.html) 19 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/lancedb.mdx: -------------------------------------------------------------------------------- 1 | # LanceDB 2 | 3 | 本页面介绍如何在 LangChain 中使用 [LanceDB](https://github.com/lancedb/lancedb)。 4 | 它分为两个部分:安装和设置,以及对特定 LanceDB 包装器的引用。 5 | 6 | ## 安装和设置 7 | 8 | - 使用 `pip install lancedb` 安装 Python SDK 9 | 10 | ## 包装器 11 | 12 | ### VectorStore 13 | 14 | 存在一个围绕 LanceDB 数据库的包装器,可以将其用作向量存储, 15 | 无论是用于语义搜索还是示例选择。 16 | 17 | 要导入此向量存储: 18 | 19 | ```python 20 | from langchain.vectorstores import LanceDB 21 | ``` 22 | 23 | 有关 LanceDB 包装器的更详细说明,请参阅 [此笔记本](/docs/modules/data_connection/vectorstores/integrations/lancedb.html) 24 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/llamacpp.mdx: -------------------------------------------------------------------------------- 1 | # Llama.cpp 2 | 3 | 本页介绍如何在 LangChain 中使用 [llama.cpp](https://github.com/ggerganov/llama.cpp)。 4 | 分为两个部分:安装和设置,以及对特定的 Llama-cpp 包装器的引用。 5 | 6 | ## 安装和设置 7 | - 使用 `pip install llama-cpp-python` 安装 Python 包 8 | - 下载 [支持的模型](https://github.com/ggerganov/llama.cpp#description),并按照 [说明](https://github.com/ggerganov/llama.cpp) 将其转换为 llama.cpp 格式 9 | 10 | ## 包装器 11 | 12 | ### LLM 13 | 14 | 存在一个 LlamaCpp LLM 包装器,可以通过以下方式访问 15 | ```python 16 | from langchain.llms import LlamaCpp 17 | ``` 18 | 有关更详细的步骤,请参阅 [此笔记本](/docs/modules/model_io/models/llms/integrations/llamacpp.html) 19 | 20 | ### 嵌入 21 | 22 | 存在一个 LlamaCpp 嵌入包装器,可以通过以下方式访问 23 | ```python 24 | from langchain.embeddings import LlamaCppEmbeddings 25 | ``` 26 | 有关更详细的步骤,请参阅 [此笔记本](/docs/modules/data_connection/text_embedding/integrations/llamacpp.html) 27 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/mediawikidump.mdx: -------------------------------------------------------------------------------- 1 | # MediaWikiDump 2 | 3 | > [MediaWiki XML Dumps](https://www.mediawiki.org/wiki/Manual:Importing_XML_dumps) 包含维基百科的内容 4 | > (包含所有修订版本的维基页面),但不包含与站点相关的数据。XML 转储不能创建完整的备份 5 | > 维基百科数据库的转储不包含用户帐户、图像、编辑日志等 6 | 7 | 8 | ## 安装和设置 9 | 10 | 我们需要安装几个 Python 软件包。 11 | 12 | `mediawiki-utilities` 支持未合并分支中的 XML 模式 0.11。 13 | ```bash 14 | pip install -qU git+https://github.com/mediawiki-utilities/python-mwtypes@updates_schema_0.11 15 | ``` 16 | 17 | `mediawiki-utilities mwxml` 存在一个错误,待修复 PR。 18 | 19 | ```bash 20 | pip install -qU git+https://github.com/gdedrouas/python-mwxml@xml_format_0.11 21 | pip install -qU mwparserfromhell 22 | ``` 23 | 24 | ## 文档加载器 25 | 26 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/mediawikidump.html)。 27 | 28 | 29 | ```python 30 | from langchain.document_loaders import MWDumpLoader 31 | ``` 32 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/metal.mdx: -------------------------------------------------------------------------------- 1 | # Metal( 金属 ) 2 | 3 | 本页面介绍如何在 LangChain 中使用 [金属(Metal)](https://getmetal.io)。 4 | 5 | ## 什么是金属(Metal)? 6 | 7 | 金属(Metal)是一个用于生产环境的受控检索和内存平台。可以轻松将数据索引到 `Metal` 中,并在其上运行语义搜索和检索。 8 | 9 | ![Metal](/img/MetalDash.png) 10 | 11 | ## 快速入门 12 | 13 | 通过 [创建一个金属(Metal)账户](https://app.getmetal.io/signup) 开始使用金属(Metal)。 14 | 15 | 然后,您可以轻松利用 `MetalRetriever` 类开始检索数据以进行语义搜索、提示上下文等。该类接受一个 `Metal` 实例和一个参数字典,用于传递给金属(Metal)API。 16 | 17 | ```python 18 | from langchain.retrievers import MetalRetriever 19 | from metal_sdk.metal import Metal 20 | 21 | 22 | metal = Metal("API_KEY", "CLIENT_ID", "INDEX_ID"); 23 | retriever = MetalRetriever(metal, params={"limit": 2}) 24 | 25 | docs = retriever.get_relevant_documents("search term") 26 | ``` 27 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/microsoft_onedrive.mdx: -------------------------------------------------------------------------------- 1 | # 微软 OneDrive 2 | 3 | > [Microsoft OneDrive](https://en.wikipedia.org/wiki/OneDrive) (原名 `SkyDrive` )是由微软运营的文件托管服务。 4 | 5 | ## 安装和设置 6 | 7 | 首先,您需要安装一个 Python 包。 8 | 9 | ```bash 10 | pip install o365 11 | ``` 12 | 13 | 然后按照 [这里的说明](/docs/modules/data_connection/document_loaders/integrations/microsoft_onedrive.html) 进行操作。 14 | 15 | ## 文档加载器 16 | 17 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/microsoft_onedrive.html)。 18 | 19 | 20 | ```python 21 | from langchain.document_loaders import OneDriveLoader 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/microsoft_powerpoint.mdx: -------------------------------------------------------------------------------- 1 | # 微软 PowerPoint 2 | 3 | > [Microsoft PowerPoint](https://en.wikipedia.org/wiki/Microsoft_PowerPoint) 是一个由微软开发的演示程序。 4 | 5 | ## 安装和设置 6 | 7 | 对它没有任何特殊设置。 8 | 9 | ## 文档加载器 10 | 11 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/microsoft_powerpoint.html)。 12 | 13 | 14 | ```python 15 | from langchain.document_loaders import UnstructuredPowerPointLoader 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/microsoft_word.mdx: -------------------------------------------------------------------------------- 1 | # 微软Word 2 | 3 | > [Microsoft Word](https://www.microsoft.com/en-us/microsoft-365/word) 是由微软开发的文字处理器。 4 | 5 | ## 安装和设置 6 | 7 | 它没有特殊的设置要求。 8 | 9 | ## 文档加载器 10 | 11 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/microsoft_word.html)。 12 | 13 | 14 | ```python 15 | from langchain.document_loaders import UnstructuredWordDocumentLoader 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/milvus.mdx: -------------------------------------------------------------------------------- 1 | # Milvus 2 | 3 | This page introduces how to use the Milvus ecosystem in LangChain. 4 | It is divided into two parts: installation and setup, and then reference materials for specific Milvus wrappers. 5 | 6 | ## Installation and Setup 7 | - Install Python SDK using `pip install pymilvus` 8 | ## Wrapper 9 | 10 | ### VectorStore 11 | 12 | There is a wrapper around the Milvus index that allows you to use it as a vector store, 13 | whether for semantic search or example selection. 14 | 15 | To import this vector store: 16 | ```python 17 | from langchain.vectorstores import Milvus 18 | ``` 19 | 20 | For a more detailed walkthrough of the Milvus wrapper, please see [this notebook](/docs/modules/data_connection/vectorstores/integrations/milvus.html) 21 | 22 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/modelscope.mdx: -------------------------------------------------------------------------------- 1 | # ModelScope 2 | 3 | 本页面介绍如何在 LangChain 中使用 modelscope 生态系统。 4 | 它分为两个部分:安装和设置,以及特定 modelscope 包装器的参考。 5 | 6 | ## 安装和设置 7 | 8 | * 使用 `pip install modelscope` 安装 Python SDK 9 | 10 | ## 包装器 11 | 12 | ### 嵌入 13 | 14 | 存在一个 modelscope 嵌入包装器,您可以通过以下方式访问 15 | 16 | ```python 17 | from langchain.embeddings import ModelScopeEmbeddings 18 | ``` 19 | 20 | 有关更详细的步骤,请参阅 [此笔记本](/docs/modules/data_connection/text_embedding/integrations/modelscope_hub.html) 21 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/modern_treasury.mdx: -------------------------------------------------------------------------------- 1 | # 现代财务 2 | 3 | > [现代财务](https://www.moderntreasury.com/) 简化了复杂的支付操作。它是一个统一的平台,用于支持移动资金的产品和流程。 4 | >- 连接银行和支付系统 5 | >- 实时跟踪交易和余额 6 | >- 自动化可扩展的支付操作 7 | 8 | ## 安装和设置 9 | 10 | 它不需要任何特殊设置。 11 | 12 | ## 文档加载器 13 | 14 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/modern_treasury.html)。 15 | 16 | 17 | ```python 18 | from langchain.document_loaders import ModernTreasuryLoader 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/nlpcloud.mdx: -------------------------------------------------------------------------------- 1 | # NLPCloud 2 | 3 | 本页面介绍如何在 LangChain 中使用 NLPCloud 生态系统。 4 | 它分为两部分:安装和设置,以及对特定 NLPCloud 封装的参考。 5 | 6 | ## 安装和设置 7 | - 使用 `pip install nlpcloud` 安装 Python SDK 8 | - 获取一个 NLPCloud API 密钥并将其设置为环境变量(`NLPCLOUD_API_KEY`) 9 | 10 | ## 封装 11 | 12 | ### LLM 13 | 14 | 存在一个 NLPCloud LLM 封装,您可以通过以下方式访问 15 | ```python 16 | from langchain.llms import NLPCloud 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/notion.mdx: -------------------------------------------------------------------------------- 1 | # Notion DB 2 | 3 | > [Notion](https://www.notion.so/) 是一个具有改进的 Markdown 支持的协作平台,集成了看板 4 | > 板、任务、维基和数据库。它是一个集合了记笔记、知识和数据管理, 5 | > 以及项目和任务管理的多合一工作空间。 6 | 7 | ## 安装和设置 8 | 9 | 所有的指示都在下面的示例中。 10 | 11 | ## 文档加载器 12 | 13 | 我们有两种不同的加载器:`NotionDirectoryLoader` 和 `NotionDBLoader`。 14 | 15 | 请参阅 [NotionDirectoryLoader 的使用示例](/docs/modules/data_connection/document_loaders/integrations/notion.html)。 16 | 17 | 18 | ```python 19 | from langchain.document_loaders import NotionDirectoryLoader 20 | ``` 21 | 22 | 请参阅 [NotionDBLoader 的使用示例](/docs/modules/data_connection/document_loaders/integrations/notiondb.html)。 23 | 24 | 25 | ```python 26 | from langchain.document_loaders import NotionDBLoader 27 | ``` 28 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/obsidian.mdx: -------------------------------------------------------------------------------- 1 | # Obsidian 2 | 3 | > [Obsidian](https://obsidian.md/) 是一个功能强大且可扩展的知识库 4 | ,它可以在本地的纯文本文件夹上工作。 5 | 6 | ## 安装和设置 7 | 8 | 所有的指导都在下面的示例中。 9 | 10 | ## 文档加载器 11 | 12 | 13 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/obsidian.html)。 14 | 15 | 16 | ```python 17 | from langchain.document_loaders import ObsidianLoader 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/opensearch.mdx: -------------------------------------------------------------------------------- 1 | # OpenSearch(开放搜索) 2 | 3 | 本页面介绍如何在 LangChain 中使用 OpenSearch 生态系统。 4 | 它分为两个部分:安装和设置,然后引用特定的 OpenSearch 包装器。 5 | 6 | ## 安装和设置 7 | - 使用 `pip install opensearch-py` 安装 Python 包 8 | ## 包装器 9 | 10 | ### VectorStore(向量存储) 11 | 12 | 有一个围绕 OpenSearch 向量数据库的包装器,允许您将其用作向量存储 13 | 以使用基于 lucene、nmslib 和 faiss 引擎的近似向量搜索进行语义搜索 14 | 或者使用痛点脚本和脚本评分函数进行暴力向量搜索。 15 | 16 | 要导入此向量存储: 17 | ```python 18 | from langchain.vectorstores import OpenSearchVectorSearch 19 | ``` 20 | 21 | 有关 OpenSearch 包装器的更详细的操作说明,请参阅 [此笔记本](/docs/modules/data_connection/vectorstores/integrations/opensearch.html) 22 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/petals.mdx: -------------------------------------------------------------------------------- 1 | # Petals(花瓣) 2 | 3 | 本页面介绍如何在 LangChain 中使用 Petals 生态系统。 4 | 它分为两个部分:安装和设置,以及特定 Petals 封装的参考资料。 5 | 6 | ## 安装和设置 7 | - 使用 `pip install petals` 进行安装 8 | - 获取一个 Hugging Face API 密钥,并将其设置为环境变量(`HUGGINGFACE_API_KEY`) 9 | 10 | ## 封装 11 | 12 | ### LLM 13 | 14 | 存在一个 Petals LLM 封装,可以通过以下方式访问 15 | ```python 16 | from langchain.llms import Petals 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/pgvector.mdx: -------------------------------------------------------------------------------- 1 | # PGVector 2 | 3 | 本页面介绍如何在 LangChain 中使用 Postgres [PGVector](https://github.com/pgvector/pgvector) 生态系统 4 | 它分为两部分:安装和设置,以及对特定 PGVector 包装器的引用。 5 | 6 | ## 安装 7 | - 使用 `pip install pgvector` 安装 Python 包 8 | 9 | 10 | ## 设置 11 | 1. 第一步是创建一个安装了 `pgvector` 扩展的数据库。 12 | 13 | 按照 [PGVector 安装步骤](https://github.com/pgvector/pgvector#installation) 中的步骤来安装数据库和扩展。使用 Docker 镜像是最简单的入门方式。 14 | 15 | ## 包装器 16 | 17 | ### VectorStore 18 | 19 | 存在一个围绕 Postgres 向量数据库的包装器,允许您将其用作向量存储, 20 | 无论是用于语义搜索还是示例选择。 21 | 22 | 要导入此向量存储: 23 | ```python 24 | from langchain.vectorstores.pgvector import PGVector 25 | ``` 26 | 27 | ### 用法 28 | 29 | 有关 PGVector 包装器的更详细演示,请参阅 [此笔记本](/docs/modules/data_connection/vectorstores/integrations/pgvector.html) 30 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/pinecone.mdx: -------------------------------------------------------------------------------- 1 | # 松果 2 | 3 | 本页面介绍了如何在 LangChain 中使用松果生态系统。 4 | 它分为两部分:安装和设置,然后是对特定松果包装器的引用。 5 | 6 | ## 安装和设置 7 | 安装 Python SDK: 8 | ```bash 9 | pip install pinecone-client 10 | ``` 11 | 12 | 13 | ## 向量存储 14 | 15 | 存在一个围绕松果索引的包装器,允许您将其用作向量存储, 16 | 无论是用于语义搜索还是示例选择。 17 | 18 | ```python 19 | from langchain.vectorstores import Pinecone 20 | ``` 21 | 22 | 有关松果向量存储的更详细的步骤,请参阅 [此笔记本](/docs/modules/data_connection/vectorstores/integrations/pinecone.html) 23 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/pipelineai.mdx: -------------------------------------------------------------------------------- 1 | # PipelineAI 2 | 3 | 本页面介绍如何在 LangChain 中使用 PipelineAI 生态系统。 4 | 它分为两个部分:安装和设置,以及特定 PipelineAI 包装器的参考。 5 | 6 | ## 安装和设置 7 | 8 | - 使用 `pip install pipeline-ai` 安装 9 | - 获取 Pipeline Cloud API 密钥,并将其设置为环境变量(`PIPELINE_API_KEY`) 10 | 11 | ## 包装器 12 | 13 | ### LLM 14 | 15 | 存在一个 PipelineAI LLM 包装器,您可以通过以下方式访问 16 | 17 | ```python 18 | from langchain.llms import PipelineAI 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/qdrant.mdx: -------------------------------------------------------------------------------- 1 | # Qdrant(Qdrant) 2 | 3 | 本页面介绍如何在 LangChain 中使用 Qdrant 生态系统。 4 | 它分为两个部分:安装和设置,然后引用特定的 Qdrant 包装器。 5 | 6 | ## 安装和设置 7 | - 使用 `pip install qdrant-client` 安装 Python SDK 8 | ## 包装器 9 | 10 | ### VectorStore(向量存储) 11 | 12 | 存在一个围绕 Qdrant 索引的包装器,允许您将其用作向量存储, 13 | 无论是用于语义搜索还是示例选择。 14 | 15 | 要导入此向量存储: 16 | ```python 17 | from langchain.vectorstores import Qdrant 18 | ``` 19 | 20 | 有关 Qdrant 包装器的更详细步骤,请参阅 [此笔记本](/docs/modules/data_connection/vectorstores/integrations/qdrant.html) 21 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/reddit.mdx: -------------------------------------------------------------------------------- 1 | # Reddit 2 | 3 | > [Reddit](www.reddit.com) 是一个美国社交新闻聚合、内容评级和讨论的网站。 4 | 5 | ## 安装和设置 6 | 7 | 首先,您需要安装一个 Python 包。 8 | 9 | ```bash 10 | pip install praw 11 | ``` 12 | 13 | 通过制作一个 [Reddit 应用](https://www.reddit.com/prefs/apps/) 并使用您的 Reddit API 凭据初始化加载器。 14 | 15 | ## 文档加载器 16 | 17 | 请参阅 [使用示例](/docs/modules/data_connection/document_loaders/integrations/reddit.html)。 18 | 19 | 20 | ```python 21 | from langchain.document_loaders import RedditPostsLoader 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/roam.mdx: -------------------------------------------------------------------------------- 1 | # Roam(漫游) 2 | 3 | > [ROAM(漫游)](https://roamresearch.com/) 是一个用于网络思维的笔记工具,旨在创建个人知识库。 4 | 5 | ## Installation and Setup(安装和设置) 6 | 7 | There isn't any special setup for it.(它没有任何特殊的设置。) 8 | 9 | 10 | 11 | ## Document Loader(文档加载器) 12 | 13 | See a [usage example](/docs/modules/data_connection/document_loaders/integrations/roam.html).(请参阅 [使用示例](/docs/modules/data_connection/document_loaders/integrations/roam.html)。) 14 | 15 | ```python 16 | from langchain.document_loaders import RoamLoader 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/serpapi.mdx: -------------------------------------------------------------------------------- 1 | # SerpAPI 2 | 3 | 本页面介绍了如何在 LangChain 中使用 SerpAPI 搜索 API。 4 | 它分为两个部分:安装和设置,然后是对具体 SerpAPI 包装器的引用。 5 | 6 | ## 安装和设置 7 | - 使用 `pip install google-search-results` 安装依赖项 8 | - 获取 SerpAPI API 密钥,并将其设置为环境变量(`SERPAPI_API_KEY`) 9 | 10 | ## 包装器 11 | 12 | ### 实用工具 13 | 14 | 有一个 SerpAPI 实用程序来封装这个 API。导入此实用程序的方法如下: 15 | 16 | ```python 17 | from langchain.utilities import SerpAPIWrapper 18 | ``` 19 | 20 | 有关此包装器的更详细步骤,请参阅 [此笔记本](/docs/modules/agents/tools/integrations/serpapi.html)。 21 | 22 | ### 工具 23 | 24 | 您还可以将此包装器作为工具轻松加载(用于与代理一起使用)。 25 | 您可以使用以下方法实现: 26 | ```python 27 | from langchain.agents import load_tools 28 | tools = load_tools(["serpapi"]) 29 | ``` 30 | 31 | 有关更多信息,请参阅 [此页面](/docs/modules/agents/tools) 32 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/sklearn.mdx: -------------------------------------------------------------------------------- 1 | # scikit-learn 2 | 3 | 本页面介绍如何在 LangChain 中使用 scikit-learn 包。 4 | 分为两个部分:安装和设置,以及对特定 scikit-learn 包装器的引用。 5 | 6 | ## 安装和设置 7 | 8 | - 使用 `pip install scikit-learn` 安装 Python 包 9 | 10 | ## 包装器 11 | 12 | ### VectorStore 13 | 14 | `SKLearnVectorStore` 为最近邻实现提供了一个简单的包装器 15 | scikit-learn 包,可以将其用作向量存储。 16 | 17 | 要导入这个向量存储: 18 | 19 | ```python 20 | from langchain.vectorstores import SKLearnVectorStore 21 | ``` 22 | 23 | 有关 SKLearnVectorStore 包装器的更详细的步骤,请参阅 [此笔记本](/docs/modules/data_connection/vectorstores/integrations/sklearn.html)。 24 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/slack.mdx: -------------------------------------------------------------------------------- 1 | # Slack(Slack) 2 | 3 | > [Slack(Slack)](https://slack.com/) 是一款即时通讯程序。 4 | 5 | ## 安装和设置(Installation and Setup) 6 | 7 | 它没有任何特殊的设置。 8 | 9 | 10 | 11 | ## 文档加载器(Document Loader) 12 | 13 | 查看 [用法示例](/docs/modules/data_connection/document_loaders/integrations/slack.html)。 14 | 15 | ```python 16 | from langchain.document_loaders import SlackDirectoryLoader 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/spacy.mdx: -------------------------------------------------------------------------------- 1 | # spaCy 2 | 3 | > [spaCy](https://spacy.io/) 是一个用 Python 和 Cython 编写的用于高级自然语言处理的开源软件库。 4 | 5 | ## 安装和设置 6 | 7 | 8 | ```bash 9 | pip install spacy 10 | ``` 11 | 12 | 13 | 14 | ## 文本分割器 15 | 16 | 参见 [使用示例](/docs/modules/data_connection/document_transformers/text_splitters/split_by_token.html#spacy)。 17 | 18 | ```python 19 | from langchain.llms import SpacyTextSplitter 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/spreedly.mdx: -------------------------------------------------------------------------------- 1 | # Spreedly 2 | 3 | > [Spreedly](https://docs.spreedly.com/) 是一项服务,允许您安全地存储信用卡并将其用于对任意数量的支付网关和第三方 API 进行交易。它同时提供了卡片令牌化/保险库服务以及网关和接收器集成服务。由 Spreedly 令牌化的支付方式存储在 `Spreedly`,允许您独立地存储一张卡,并根据您的业务要求将该卡传递给不同的终端点。 4 | 5 | ## 安装和设置 6 | 7 | 请参阅 [设置说明](/docs/modules/data_connection/document_loaders/integrations/spreedly.html)。 8 | 9 | ## 文档加载器 10 | 11 | 请参阅 [使用示例](/docs/modules/data_connection/document_loaders/integrations/spreedly.html)。 12 | 13 | ```python 14 | from langchain.document_loaders import SpreedlyLoader 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/stochasticai.mdx: -------------------------------------------------------------------------------- 1 | # StochasticAI 2 | 3 | 本页面介绍如何在 LangChain 中使用 StochasticAI 生态系统。 4 | 它分为两个部分:安装和设置,以及对特定 StochasticAI 包装器的引用。 5 | 6 | ## 安装和设置 7 | - 使用 `pip install stochasticx` 进行安装 8 | - 获取一个 StochasticAI api 密钥,并将其设置为环境变量(`STOCHASTICAI_API_KEY`) 9 | 10 | ## 包装器 11 | 12 | ### LLM 13 | 14 | 存在一个 StochasticAI LLM 包装器,您可以使用 15 | ```python 16 | from langchain.llms import StochasticAI 17 | ``` -------------------------------------------------------------------------------- /docs/ecosystem/integrations/stripe.mdx: -------------------------------------------------------------------------------- 1 | # Stripe( 支付宝 ) 2 | 3 | > [Stripe( 支付宝 )](https://stripe.com/en-ca) 是一家爱尔兰-美国金融服务和软件即服务(SaaS)公司。它为电子商务网站和移动应用提供支付处理软件和应用程序编程接口。 4 | 5 | 6 | ## 安装和设置 7 | 8 | 查看 [设置说明](/docs/modules/data_connection/document_loaders/integrations/stripe.html)。 9 | 10 | ## 文档加载器 11 | 12 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/stripe.html)。 13 | 14 | ```python 15 | from langchain.document_loaders import StripeLoader 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/tair.mdx: -------------------------------------------------------------------------------- 1 | # Tair( 天空 ) 2 | 3 | 本页面介绍如何在 LangChain 中使用 Tair 生态系统。 4 | 5 | ## 安装和设置 6 | 7 | 使用 `pip install tair` 安装 Tair Python SDK。 8 | 9 | ## 包装器 10 | 11 | ### VectorStore( 向量存储 ) 12 | 13 | 存在一个围绕 TairVector 的包装器,允许您将其用作向量存储, 14 | 无论是用于语义搜索还是示例选择。 15 | 16 | 要导入此向量存储: 17 | 18 | ```python 19 | from langchain.vectorstores import Tair 20 | ``` 21 | 22 | 有关 Tair 包装器的更详细演示,请参阅 [此笔记本](/docs/modules/data_connection/vectorstores/integrations/tair.html) 23 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/telegram.mdx: -------------------------------------------------------------------------------- 1 | # Telegram 2 | 3 | > [Telegram Messenger](https://web.telegram.org/a/) 是一款全球可访问的免费、跨平台、加密、基于云和集中式的即时通讯服务。该应用程序还提供可选的端到端加密聊天、视频通话、VoIP、文件共享和其他几个功能。 4 | 5 | 6 | ## 安装和设置 7 | 8 | 参见 [安装指南](/docs/modules/data_connection/document_loaders/integrations/telegram.html)。 9 | 10 | ## 文档加载器 11 | 12 | 参见 [使用示例](/docs/modules/data_connection/document_loaders/integrations/telegram.html)。 13 | 14 | ```python 15 | from langchain.document_loaders import TelegramChatFileLoader 16 | from langchain.document_loaders import TelegramChatApiLoader 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/tomarkdown.mdx: -------------------------------------------------------------------------------- 1 | # 2Markdown 2 | 3 | > [2markdown](https://2markdown.com/) 服务将网站内容转换为结构化的 markdown 文件。 4 | 5 | 6 | ## 安装和设置 7 | 8 | 我们需要 `API密钥`。请参阅 [获取密钥的说明](https://2markdown.com/login)。 9 | 10 | ## 文档加载器 11 | 12 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/tomarkdown.html)。 13 | 14 | ```python 15 | from langchain.document_loaders import ToMarkdownLoader 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/trello.mdx: -------------------------------------------------------------------------------- 1 | # Trello 2 | 3 | > [Trello](https://www.atlassian.com/software/trello) 是一个基于 Web 的项目管理和协作工具,允许个人和团队组织和跟踪任务和项目。它提供了一个被称为“看板”的可视化界面,用户可以创建列表和卡片来表示他们的任务和活动。 4 | > TrelloLoader 允许我们从 `Trello` 板加载卡片。 5 | 6 | 7 | ## 安装和设置 8 | 9 | ```bash 10 | pip install py-trello beautifulsoup4 11 | ``` 12 | 13 | 请参阅 [设置说明](/docs/modules/data_connection/document_loaders/integrations/trello.html)。 14 | 15 | 16 | ## 文档加载器 17 | 18 | 请参阅 [使用示例](/docs/modules/data_connection/document_loaders/integrations/trello.html)。 19 | 20 | ```python 21 | from langchain.document_loaders import TrelloLoader 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/twitter.mdx: -------------------------------------------------------------------------------- 1 | # Twitter(推特) 2 | 3 | > [Twitter(推特)](https://twitter.com/) 是一种在线社交媒体和社交网络服务。 4 | 5 | 6 | ## Installation and Setup(安装和设置) 7 | 8 | ```bash 9 | pip install tweepy 10 | ``` 11 | 12 | 我们必须使用 `Twitter API` 令牌来初始化加载器,并且我们需要设置 Twitter `用户名`。 13 | 14 | 15 | ## Document Loader(文档加载器) 16 | 17 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/twitter.html)。 18 | 19 | ```python 20 | from langchain.document_loaders import TwitterTweetLoader 21 | ``` 22 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/vespa.mdx: -------------------------------------------------------------------------------- 1 | # Vespa 2 | 3 | > [Vespa](https://vespa.ai/) 是一个功能齐全的搜索引擎和向量数据库。 4 | > 它支持向量搜索(ANN)、词汇搜索和结构化数据搜索,所有这些都可以在同一个查询中进行。 5 | 6 | ## 安装和配置 7 | 8 | 9 | ```bash 10 | pip install pyvespa 11 | ``` 12 | 13 | 14 | 15 | ## 检索器 16 | 17 | 请参阅 [使用示例](/docs/modules/data_connection/retrievers/integrations/vespa.html)。 18 | 19 | ```python 20 | from langchain.retrievers import VespaRetriever 21 | ``` 22 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/weather.mdx: -------------------------------------------------------------------------------- 1 | # 天气 2 | 3 | > [OpenWeatherMap](https://openweathermap.org/) 是一个开源的天气服务提供商。 4 | 5 | 6 | 7 | ## 安装和设置 8 | 9 | ```bash 10 | pip install pyowm 11 | ``` 12 | 13 | 我们必须设置 `OpenWeatherMap API token`。 14 | 15 | ## 文档加载器 16 | 17 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/weather.html)。 18 | 19 | ```python 20 | from langchain.document_loaders import WeatherDataLoader 21 | ``` 22 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/whatsapp.mdx: -------------------------------------------------------------------------------- 1 | # WhatsApp(WhatsApp) 2 | 3 | > [WhatsApp](https://www.whatsapp.com/)(也称为 `WhatsApp Messenger`)是一种免费的、跨平台的、集中式的即时通讯(IM)和语音通话(VoIP)服务。它允许用户发送文本和语音消息、进行语音和视频通话,并共享图片、文档、用户位置和其他内容。 4 | 5 | 6 | ## 安装和设置 7 | 8 | 不需要任何特殊设置。 9 | 10 | 11 | 12 | ## 文档加载器 13 | 14 | 请参阅 [使用示例](/docs/modules/data_connection/document_loaders/integrations/whatsapp_chat.html)。 15 | 16 | ```python 17 | from langchain.document_loaders import WhatsAppChatLoader 18 | ``` 19 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/wikipedia.mdx: -------------------------------------------------------------------------------- 1 | # 维基百科 2 | 3 | > [维基百科](https://wikipedia.org/) 是一个多语种的免费在线百科全书,由一群志愿者社群维护和撰写,这些志愿者被称为维基人,通过开放协作并使用基于 Wiki 的编辑系统 MediaWiki。`维基百科` 是历史上最大且最受欢迎的参考工具。 4 | 5 | 6 | ## 安装和设置 7 | 8 | ```bash 9 | pip install wikipedia 10 | ``` 11 | 12 | 13 | 14 | ## 文档加载器 15 | 16 | 查看 [使用示例](/docs/modules/data_connection/document_loaders/integrations/wikipedia.html)。 17 | 18 | ```python 19 | from langchain.document_loaders import WikipediaLoader 20 | ``` 21 | 22 | ## 检索器 23 | 24 | 查看 [使用示例](/docs/modules/data_connection/retrievers/integrations/wikipedia.html)。 25 | 26 | ```python 27 | from langchain.retrievers import WikipediaRetriever 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/writer.mdx: -------------------------------------------------------------------------------- 1 | # 写手 2 | 3 | 本页介绍如何在 LangChain 中使用写手生态系统。 4 | 它分为两个部分:安装和设置,以及特定写手包的参考。 5 | 6 | ## 安装和设置 7 | - 获取一个写手 API 密钥,并将其设置为环境变量(`WRITER_API_KEY`) 8 | 9 | ## 包装器 10 | 11 | ### LLM 12 | 13 | 存在一个写手 LLM 包装器,可以使用以下方式访问 14 | ```python 15 | from langchain.llms import Writer 16 | ``` -------------------------------------------------------------------------------- /docs/ecosystem/integrations/youtube.mdx: -------------------------------------------------------------------------------- 1 | # YouTube 2 | 3 | > [YouTube](https://www.youtube.com/) 是由 Google 创建的在线视频分享和社交媒体平台。 4 | > 我们下载 `YouTube` 的字幕和视频信息。 5 | 6 | ## 安装和设置 7 | 8 | ```bash 9 | pip install youtube-transcript-api 10 | pip install pytube 11 | ``` 12 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/youtube_transcript.html)。 13 | 14 | 15 | ## 文档加载器 16 | 17 | 查看一个 [使用示例](/docs/modules/data_connection/document_loaders/integrations/youtube_transcript.html)。 18 | 19 | ```python 20 | from langchain.document_loaders import YoutubeLoader 21 | from langchain.document_loaders import GoogleApiYoutubeLoader 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/zep.mdx: -------------------------------------------------------------------------------- 1 | # Zep 2 | 3 | > [Zep](https://docs.getzep.com/) - 一个用于 LLM 应用程序的长期存储器。 4 | 5 | > `Zep` 存储、总结、嵌入、索引和丰富了对话型 AI 聊天历史记录,并通过简单的、低延迟的 API 进行公开。 6 | >- 长期存储,无论您的摘要策略如何,都可以访问历史消息。 7 | >- 基于可配置的消息窗口自动摘要存储的消息。一系列的摘要被存储,为将来的摘要策略提供了灵活性。 8 | >- 对记忆的向量搜索,消息在创建时自动嵌入。 9 | >- 对记忆和摘要的自动令牌计数,允许更精细地控制提示组装。 10 | >- Python 和 JavaScript SDK。 11 | 12 | 13 | `Zep` [项目](https://github.com/getzep/zep) 14 | 15 | ## 安装和设置 16 | 17 | ```bash 18 | pip install zep_python 19 | ``` 20 | 21 | 22 | ## 检索器 23 | 24 | 请参阅 [使用示例](/docs/modules/data_connection/retrievers/integrations/zep_memorystore.html)。 25 | 26 | ```python 27 | from langchain.retrievers import ZepRetriever 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/ecosystem/integrations/zilliz.mdx: -------------------------------------------------------------------------------- 1 | # Zilliz 2 | 3 | > [Zilliz Cloud](https://zilliz.com/doc/quick_start) 是 `LF AI Milvus®` 在云端的完全托管服务, 4 | 5 | 6 | ## 安装和设置 7 | 8 | 安装 Python SDK: 9 | ```bash 10 | pip install pymilvus 11 | ``` 12 | 13 | ## 矢量存储 14 | 15 | 一个围绕 Zilliz 索引的封装,可以将其用作矢量存储, 16 | 无论是用于语义搜索还是示例选择。 17 | 18 | ```python 19 | from langchain.vectorstores import Milvus 20 | ``` 21 | 22 | 有关 Miluvs 封装的更详细步骤,请参阅 [此笔记本](/docs/modules/data_connection/vectorstores/integrations/zilliz.html) 23 | -------------------------------------------------------------------------------- /docs/expression_language/how_to/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | 5 | # 入门 6 | 7 | import DocCardList from "@theme/DocCardList"; 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/guides/deployments/template_repos.mdx: -------------------------------------------------------------------------------- 1 | # LangChain模板 2 | 3 | 要获取有关LangChain模板的更多信息,请访问 4 | 5 | - [LangChain模板快速入门](https://github.com/langchain-ai/langchain/blob/master/templates/README.md) 6 | - [LangChain模板索引](https://github.com/langchain-ai/langchain/blob/master/templates/docs/INDEX.md) 7 | - [模板完整列表](https://github.com/langchain-ai/langchain/blob/master/templates/) -------------------------------------------------------------------------------- /docs/guides/evaluation/examples/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 5 3 | --- 4 | # 示例 5 | 6 | 🚧 _文档正在建设中_ 🚧 7 | 8 | 以下是一些用于检查和检验不同链的示例。 9 | 10 | import DocCardList from "@theme/DocCardList"; 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/guides/evaluation/qa_generation.md: -------------------------------------------------------------------------------- 1 | # QA生成 2 | 本笔记本展示了如何使用`QAGenerationChain`来生成特定文档的问题-答案对。 3 | 这很重要,因为通常情况下,您可能没有数据来评估您的问答系统,所以这是一种廉价且轻量级的生成方法! 4 | 5 | 6 | ```python 7 | from langchain.document_loaders import TextLoader 8 | ``` 9 | 10 | 11 | ```python 12 | loader = TextLoader("../../modules/state_of_the_union.txt") 13 | ``` 14 | 15 | 16 | ```python 17 | doc = loader.load()[0] 18 | ``` 19 | 20 | 21 | ```python 22 | from langchain.chat_models import ChatOpenAI 23 | from langchain.chains import QAGenerationChain 24 | 25 | chain = QAGenerationChain.from_llm(ChatOpenAI(temperature=0)) 26 | ``` 27 | 28 | 29 | ```python 30 | qa = chain.run(doc.page_content) 31 | ``` 32 | 33 | 34 | ```python 35 | qa[1] 36 | ``` 37 | 38 | 39 | 40 | 41 | {'question': '美国司法部正在采取什么行动来打击俄罗斯寡头的犯罪行为?', 42 | 'answer': '美国司法部正在组建一个专门的工作组来打击俄罗斯寡头的犯罪行为。'} 43 | 44 | 45 | 46 | 47 | ```python 48 | 49 | ``` 50 | -------------------------------------------------------------------------------- /docs/guides/index.mdx: -------------------------------------------------------------------------------- 1 | # 追踪指南 ( Guides ) 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | -------------------------------------------------------------------------------- /docs/guides/safety/index.mdx: -------------------------------------------------------------------------------- 1 | # 安全性 2 | 3 | 使用LLMs的关键问题之一是它们可能会生成有害或不道德的文本。这是该领域的一个活跃研究领域。在这里,我们提供了一些受这项研究启发的内置链,旨在使LLMs的输出更安全。 4 | 5 | - [亚马逊理解审查链](/docs/guides/safety/amazon_comprehend_chain):使用[亚马逊理解](https://aws.amazon.com/comprehend/)来检测和处理个人身份信息(PII)和毒性。 6 | - [宪法链](/docs/guides/safety/constitutional_chain):用一套应指导模型行为的原则提示模型。 7 | - [Hugging Face提示注入识别](/docs/guides/safety/hugging_face_prompt_injection):检测并处理提示注入攻击。 8 | - [逻辑谬误链](/docs/guides/safety/logical_fallacy_chain):检查模型输出是否存在逻辑谬误,以纠正任何偏差。 9 | - [审查链](/docs/guides/safety/moderation):检查任何输出文本是否有害并标记它。 10 | 11 | -------------------------------------------------------------------------------- /docs/guides/tracing/default_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/guides/tracing/default_empty.png -------------------------------------------------------------------------------- /docs/guides/tracing/explore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/guides/tracing/explore.png -------------------------------------------------------------------------------- /docs/guides/tracing/explore_llm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/guides/tracing/explore_llm.png -------------------------------------------------------------------------------- /docs/guides/tracing/explore_trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/guides/tracing/explore_trace.png -------------------------------------------------------------------------------- /docs/guides/tracing/first_trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/guides/tracing/first_trace.png -------------------------------------------------------------------------------- /docs/guides/tracing/homepage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/guides/tracing/homepage.png -------------------------------------------------------------------------------- /docs/langsmith/img/test_results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/docs/langsmith/img/test_results.png -------------------------------------------------------------------------------- /docs/modules/agents/agent_types/chat_conversation_agent.mdx: -------------------------------------------------------------------------------- 1 | # 会话(Conversational) 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | 5 | 本教程演示了如何使用针对对话优化的代理。其他代理通常优化用于查找最佳响应的工具,但在对话环境中这并不理想,因为您可能希望代理能够与用户进行聊天。 6 | 7 | import Example from "@snippets/modules/agents/agent_types/conversational_agent.mdx" 8 | 9 | 10 | 11 | import ChatExample from "@snippets/modules/agents/agent_types/chat_conversation_agent.mdx" 12 | 13 | ## 使用聊天模型 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/modules/agents/agent_types/openai_functions_agent.mdx: -------------------------------------------------------------------------------- 1 | # OpenAI函数 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | 某些OpenAI模型(例如gpt-3.5-turbo-0613和gpt-4-0613)已经经过微调,可以检测到何时应该调用函数,并以应该传递给函数的输入作为响应。 5 | 在API调用中,您可以描述函数,并使模型智能选择输出一个包含调用这些函数的参数的JSON对象。 6 | OpenAI函数API的目标是比通用文本完成或聊天API更可靠地返回有效和有用的函数调用。 7 | 8 | OpenAI函数代理是为这些模型设计的。 9 | 10 | import Example from "@snippets/modules/agents/agent_types/openai_functions_agent.mdx"; 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/modules/agents/agent_types/react.mdx: -------------------------------------------------------------------------------- 1 | # ReAct 代理 ReAct 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 本教程演示了使用代理实现 [ReAct](https://react-lm.github.io/) 逻辑。 6 | 7 | import Example from "@snippets/modules/agents/agent_types/react.mdx" 8 | 9 | 10 | 11 | ## 使用聊天模型 12 | 13 | 您还可以创建使用聊天模型而不是 LLMs 作为代理驱动程序的 ReAct 代理。 14 | 15 | import ChatExample from "@snippets/modules/agents/agent_types/react_chat.mdx" 16 | 17 | -------------------------------------------------------------------------------- /docs/modules/agents/agent_types/structured_chat.mdx: -------------------------------------------------------------------------------- 1 | # 结构化工具聊天 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 结构化工具聊天代理能够使用多输入工具。 7 | 8 | 旧代理配置为将动作输入指定为单个字符串,但是该代理可以使用提供的工具的`args_schema`来填充动作输入。 9 | 10 | 11 | import Example from "@snippets/modules/agents/agent_types/structured_chat.mdx" 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/modules/agents/how_to/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'How-to' 2 | position: 1 3 | -------------------------------------------------------------------------------- /docs/modules/agents/how_to/custom_llm_agent.mdx: -------------------------------------------------------------------------------- 1 | # 自定义LLM代理 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 这个笔记本介绍了如何创建自己的自定义LLM代理。 7 | 8 | 一个LLM代理由三个部分组成: 9 | 10 | - `PromptTemplate`: 这是用于指导语言模型做什么的提示模板 11 | - LLM: 这是为代理提供动力的语言模型 12 | - `stop` sequence: 指示LLM在找到此字符串时停止生成 13 | - `OutputParser`: 这确定如何将LLM输出解析为`AgentAction`或`AgentFinish`对象 14 | 15 | import Example from "@snippets/modules/agents/how_to/custom_llm_agent.mdx" 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/modules/agents/how_to/custom_llm_chat_agent.mdx: -------------------------------------------------------------------------------- 1 | # 自定义 LLM 代理(带有 ChatModel)custom_llm_chat_agent 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | 本笔记本介绍了如何基于聊天模型创建自定义代理的过程。 5 | 6 | LLM 聊天代理由三个部分组成: 7 | 8 | - PromptTemplate:这是可用于指导语言模型的提示模板 9 | - ChatModel:这是驱动代理的语言模型 10 | - `stop` 序列:指示 LLM 在找到此字符串时停止生成 11 | - OutputParser:确定如何将 LLMOutput 解析为 AgentAction 或 AgentFinish 对象 12 | 13 | import Example from "@snippets/modules/agents/how_to/custom_llm_chat_agent.mdx" 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/modules/agents/how_to/mrkl.mdx: -------------------------------------------------------------------------------- 1 | # 复制 MRKL 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | 这个演示演示了如何使用代理来复制[MRKL](https$://arxiv.org/pdf/2205.00445.pdf)系统。 5 | 6 | 这里使用了示例的 Chinook 数据库。 7 | 要设置它,请按照 https$://database.guide/2-sample-databases-sqlite/ 上的说明进行操作,将 `.db` 文件放在此存储库的根目录的 notebooks 文件夹中。 8 | 9 | import Example from "@snippets/modules/agents/how_to/mrkl.mdx" 10 | 11 | 12 | 13 | ## 使用聊天模型 14 | 15 | import ChatExample from "@snippets/modules/agents/how_to/mrkl_chat.mdx" 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/modules/agents/toolkits/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | --- 4 | 5 | # 工具包 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | :::info 10 | 请访问[Integrations](/docs/integrations/toolkits/)了解有关内置工具包集成的文档。 11 | ::: 12 | 13 | 工具包是一组旨在一起使用以完成特定任务并具有便捷加载方法的工具的集合。 14 | -------------------------------------------------------------------------------- /docs/modules/agents/tools/how_to/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'How-to' 2 | position: 0 3 | -------------------------------------------------------------------------------- /docs/modules/agents/tools/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | 5 | # 工具 6 | 7 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 8 | 9 | 10 | :::info 11 | 前往[Integrations](/docs/integrations/tools/)查看内置工具集成的文档。 12 | ::: 13 | 14 | 工具是代理可以用来与世界互动的接口。 15 | 16 | ## 入门 17 | 18 | 工具是代理可以用来与世界互动的函数。 19 | 这些工具可以是通用实用程序(例如搜索),其他链或甚至其他代理。 20 | 21 | 目前,可以使用以下代码片段加载工具: 22 | 23 | import GetStarted from "@snippets/modules/agents/tools/get_started.mdx" 24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/modules/agents/tools/integrations/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'Integrations' 2 | -------------------------------------------------------------------------------- /docs/modules/agents/tools/integrations/python.md: -------------------------------------------------------------------------------- 1 | # Python REPL 2 | 有时候,对于复杂的计算,与其让LLM直接生成答案,不如让LLM生成计算答案的代码,然后运行该代码来获得答案。为了方便这样做,我们提供了一个简单的Python REPL来执行命令。 3 | 4 | 这个接口只会返回打印出来的内容 - 因此,如果您想使用它来计算答案,请确保它打印出答案。 5 | 6 | ```python 7 | from langchain.agents import Tool 8 | from langchain.utilities import PythonREPL 9 | ``` 10 | 11 | ```python 12 | python_repl = PythonREPL() 13 | ``` 14 | 15 | ```python 16 | python_repl.run("print(1+1)") 17 | ``` 18 | 19 | 20 | '2\n' 21 | 22 | 23 | ```python 24 | # 您可以创建一个工具来传递给一个代理 25 | repl_tool = Tool( 26 | name="python_repl", 27 | description="一个Python shell。使用它来执行python命令。输入应该是一个有效的python命令。如果你想看到一个值的输出,你应该用`print(...)`打印出来。", 28 | func=python_repl.run, 29 | ) 30 | ``` -------------------------------------------------------------------------------- /docs/modules/callbacks/how_to/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'How-to' 2 | position: 0 3 | -------------------------------------------------------------------------------- /docs/modules/callbacks/how_to/custom_chain.mdx: -------------------------------------------------------------------------------- 1 | # 自定义链的回调函数 2 | 3 | 当您创建自定义链时,可以轻松地设置它使用与所有内置链相同的回调系统。Chains / LLMs / Chat Models / Agents / Tools 上的 `_call`,`_generate`,`_run` 和相应的异步方法现在接收第二个参数 `run_manager`,它绑定到该运行,并包含可以被该对象使用的日志记录方法(即 `on_llm_new_token`)。在构建自定义链时,这非常有用。有关如何[创建自定义链并在其中使用回调的更多信息](/docs/modules/chains/how_to/custom_chain.html)请参阅此指南。 -------------------------------------------------------------------------------- /docs/modules/callbacks/how_to/tags.mdx: -------------------------------------------------------------------------------- 1 | # 标签 tags 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 你可以通过将 `tags` 参数传递给 `call()`/`run()`/`apply()` 方法来为回调函数添加标签。这对于过滤日志非常有用,例如,如果您想记录对特定 LLMChain 所做的所有请求,您可以添加一个标签,然后通过该标签对日志进行筛选。您可以将标签传递给构造函数和请求回调函数,详见上面的示例。这些标签然后传递给 "start" 回调方法的 `tags` 参数,即 `on_llm_start`,`on_chat_model_start`,`on_chain_start`,`on_tool_start`。 6 | -------------------------------------------------------------------------------- /docs/modules/callbacks/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 5 3 | --- 4 | 5 | # 回调函数 6 | 7 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 8 | 9 | 10 | :::info 11 | 请访问[Integrations](/docs/integrations/callbacks/)以获取内置回调函数与第三方工具集成的文档。 12 | ::: 13 | 14 | LangChain提供了一个回调函数系统,允许您在LLM应用程序的各个阶段进行钩子操作。这对于日志记录、监控、流式传输和其他任务非常有用。 15 | 16 | import GetStarted from "@snippets/modules/callbacks/get_started.mdx" 17 | 18 | 19 | -------------------------------------------------------------------------------- /docs/modules/callbacks/integrations/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'Integrations' 2 | -------------------------------------------------------------------------------- /docs/modules/chains/additional/analyze_document.mdx: -------------------------------------------------------------------------------- 1 | # 分析文档 (Analyze Document) 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 分析文档链 (AnalyzeDocumentChain) 可以用作端到端链。该链接收一个单独的文档,将其拆分,并将其传递给 CombineDocumentsChain 进行处理。 7 | 8 | import Example from "@snippets/modules/chains/additional/analyze_document.mdx" 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/chains/additional/constitutional_chain.mdx: -------------------------------------------------------------------------------- 1 | # ConstitutionalChain 自我批判链 2 | 3 | 4 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 5 | 6 | ConstitutionalChain 是一种确保语言模型输出符合预定义宪法原则的链。通过结合特定规则和准则,ConstitutionalChain 对生成的内容进行过滤和修改,以使其与这些原则保持一致,从而提供更受控、道德和上下文适当的响应。这种机制有助于维护输出的完整性,同时最大程度地减少生成可能违反准则、冒犯或偏离所需上下文的内容的风险。 7 | 8 | 9 | import Example from "@snippets/modules/chains/additional/constitutional_chain.mdx" 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/modules/chains/additional/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 4 3 | --- 4 | # 附加 ( Additional ) 5 | 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | import DocCardList from "@theme/DocCardList"; 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/modules/chains/additional/llm_checker.md: -------------------------------------------------------------------------------- 1 | # 自检链 2 | 这个笔记本展示了如何使用LLMCheckerChain。 3 | 4 | ```python 5 | from langchain.chains import LLMCheckerChain 6 | from langchain.llms import OpenAI 7 | 8 | llm = OpenAI(temperature=0.7) 9 | text = "What type of mammal lays the biggest eggs?" 10 | 11 | checker_chain = LLMCheckerChain.from_llm(llm, verbose=True) 12 | checker_chain.run(text) 13 | ``` 14 | 15 | 16 | 17 | > Entering new LLMCheckerChain chain... 18 | 19 | 20 | > Entering new SequentialChain chain... 21 | 22 | > Finished chain. 23 | 24 | > Finished chain. 25 | 26 | 27 | 28 | 29 | 30 | '没有哺乳动物能够产下最大的蛋。大象鸟是一种巨鸟,它的蛋是所有鸟类中最大的。' 31 | 32 | 33 | 34 | 35 | ```python 36 | ``` -------------------------------------------------------------------------------- /docs/modules/chains/additional/llm_math.md: -------------------------------------------------------------------------------- 1 | # 数学链 2 | 3 | 本笔记本展示了使用LLMs和Python REPL解决复杂的数学问题。 4 | 5 | ```python 6 | from langchain import OpenAI, LLMMathChain 7 | 8 | llm = OpenAI(temperature=0) 9 | llm_math = LLMMathChain.from_llm(llm, verbose=True) 10 | 11 | llm_math.run("13的0.3432次方") 12 | ``` 13 | 14 | 15 | > 进入新的LLMMathChain链... 16 | What is 13 raised to the .3432 power? 17 | ```text 18 | 13 ** 0.3432 19 | ``` 20 | 21 | ...numexpr.evaluate("13 ** 0.3432")... 22 |  23 | Answer: 2.4116004626599237 24 | > 完成链。 25 | 26 | 27 | 28 | 29 | 30 | 'Answer: 2.4116004626599237' 31 | 32 | 33 | 34 | 35 | ```python 36 | ``` -------------------------------------------------------------------------------- /docs/modules/chains/additional/moderation.mdx: -------------------------------------------------------------------------------- 1 | # 审查 Moderation 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 本文档演示了如何使用审查链以及几种常见的方法。审查链用于检测可能含有仇恨、暴力等内容的文本。这对于对用户输入进行处理以及对语言模型的输出进行处理都非常有用。一些 API 供应商(如 OpenAI)[明确禁止](https://beta.openai.com/docs/usage-policies/use-case-policy) 您或您的最终用户生成某些类型的有害内容。为了遵守这一规定(并且通常还可以防止您的应用程序造成伤害),您可能经常希望在任何 LLMChains 后附加一个审查链,以确保 LLM 生成的任何输出都不会有害。 6 | 7 | 如果传递到审查链中的内容是有害的,则没有一种最佳处理方式,这可能取决于您的应用程序。有时,您可能希望在 Chain 中抛出错误(并由您的应用程序处理该错误)。其他时候,您可能希望向用户返回一些说明,说明文本是有害的。甚至可能还有其他处理方式!在本教程中,我们将涵盖所有这些处理方式。 8 | 9 | import Example from "@snippets/modules/chains/additional/moderation.mdx" 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/modules/chains/additional/multi_prompt_router.mdx: -------------------------------------------------------------------------------- 1 | # 动态从多个提示中选择 multi_prompt_router 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 本笔记本演示了如何使用 `RouterChain` 范式创建一个动态选择要用于给定输入的提示的链。具体来说,我们展示了如何使用 `MultiPromptChain` 创建一个问题回答链,该链选择与给定问题最相关的提示,然后使用该提示来回答问题。 7 | 8 | import Example from "@snippets/modules/chains/additional/multi_prompt_router.mdx" 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/chains/additional/multi_retrieval_qa_router.mdx: -------------------------------------------------------------------------------- 1 | # 动态选择多个检索器 multi_retrieval_qa_router 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 本文档演示如何使用 `RouterChain` 范式创建一个动态选择要使用的检索系统的链。具体来说,我们展示了如何使用 `MultiRetrievalQAChain` 创建一个问答链,该链根据给定的问题选择最相关的检索问答链,然后使用它来回答问题。 6 | 7 | import Example from "@snippets/modules/chains/additional/multi_retrieval_qa_router.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/chains/additional/question_answering.mdx: -------------------------------------------------------------------------------- 1 | # 文档问答 qa_with_sources 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 在这里,我们将介绍如何使用 LangChain 对一系列文档进行问答。在底层,我们将使用我们的 [文档链](../document.html)。 7 | 8 | import Example from "@snippets/modules/chains/additional/question_answering.mdx" 9 | 10 | 11 | 12 | ## 带有来源的文档问答 13 | 14 | import ExampleWithSources from "@snippets/modules/chains/additional/qa_with_sources.mdx" 15 | 16 | 17 | -------------------------------------------------------------------------------- /docs/modules/chains/document/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | # 文档( Documents ) 5 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 6 | 7 | 8 | 这些是处理文档的核心链组件。它们用于对文档进行总结、回答关于文档的问题、从文档中提取信息等等。 9 | 10 | 这些链组件都实现了一个公共接口: 11 | 12 | import Interface from "@snippets/modules/chains/document/combine_docs.mdx" 13 | 14 | 15 | 16 | import DocCardList from "@theme/DocCardList"; 17 | 18 | 19 | -------------------------------------------------------------------------------- /docs/modules/chains/document/map_reduce.mdx: -------------------------------------------------------------------------------- 1 | # Map reduce 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | map reduce 文档链首先将 LLM 链应用于每个单独的文档(Map 步骤),将链的输出视为新文档。然后将所有新文档传递给单独的合并文档链以获得单个输出(Reduce 步骤)。如果需要,它可以选择先压缩或折叠映射的文档,以确保它们适合合并文档链(通常将它们传递给 LLM)。如果需要,此压缩步骤会递归执行。 7 | 8 | ![map_reduce 图示(map_reduce_diagram)](/img/map_reduce.jpg) -------------------------------------------------------------------------------- /docs/modules/chains/document/map_rerank.mdx: -------------------------------------------------------------------------------- 1 | # Map re-rank 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 该链组件在每个文档上运行一个初始提示,该提示不仅尝试完成任务,而且还给出了答案的确定性得分。返回得分最高的响应。 6 | 7 | ![map_rerank_diagram](/img/map_rerank.jpg) -------------------------------------------------------------------------------- /docs/modules/chains/document/refine.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | # 精化(Refine) 5 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 6 | 7 | 精化文档链通过循环遍历输入文档并迭代更新其答案来构建响应。对于每个文档,它将所有非文档输入、当前文档和最新的中间答案传递给LLM链以获得新的答案。 8 | 9 | 由于精化链每次只向LLM传递单个文档,因此非常适合需要分析超出模型上下文范围的文档数量的任务。 10 | 显而易见的权衡是,与“Stuff documents chain”等链相比,该链会进行更多的LLM调用。 11 | 还有某些任务在迭代执行时很难完成。例如,当文档经常相互引用或任务需要从多个文档中获取详细信息时,精化链的性能可能较差。 12 | 13 | ![refine_diagram](/img/refine.jpg) 14 | -------------------------------------------------------------------------------- /docs/modules/chains/document/stuff.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 0 3 | --- 4 | # 东西文档链( Stuff documents ) 5 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 6 | 7 | 8 | 东西文档链("东西" 的意思是 "填充" 或 "填充")是最直接的文档链之一。它接受一个文档列表,将它们全部插入到提示中,并将该提示传递给 LLM。 9 | 10 | 此链适用于文档较小且大多数调用仅传递少数文档的应用程序。 11 | 12 | ![东西图示(stuff_diagram)](/img/stuff.jpg) 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/modules/chains/foundational/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | # 基础(Foundational) 5 | 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | import DocCardList from "@theme/DocCardList"; 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/modules/chains/foundational/llm_chain.mdx: -------------------------------------------------------------------------------- 1 | # LLM 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | `LLMChain`是一个简单的链式结构,它在语言模型周围添加了一些功能。它广泛用于LangChain中,包括其他链式结构和代理程序。 6 | 7 | `LLMChain`由`PromptTemplate`和语言模型(LLM或聊天模型)组成。它使用提供的输入键值(如果有的话,还包括内存键值)格式化提示模板,将格式化的字符串传递给LLM并返回LLM输出。 8 | 9 | ## 入门 10 | 11 | import Example from "@snippets/modules/chains/foundational/llm_chain.mdx" 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/modules/chains/foundational/sequential_chains.mdx: -------------------------------------------------------------------------------- 1 | # 顺序(Sequential) 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 接下来,在调用语言模型之后,要对语言模型进行一系列的调用。当您希望将一个调用的输出作为另一个调用的输入时,这尤其有用。 6 | 7 | 在这个笔记本中,我们将通过一些示例来演示如何使用顺序链来实现这一点。顺序链允许您连接多个链并将它们组合成执行某个特定场景的管道。有两种类型的顺序链: 8 | 9 | - `SimpleSequentialChain`:最简单的顺序链形式,每个步骤都有一个单一的输入/输出,一个步骤的输出是下一个步骤的输入。 10 | - `SequentialChain`:更一般的顺序链形式,允许多个输入/输出。 11 | 12 | import Example from "@snippets/modules/chains/foundational/sequential_chains.mdx" 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/modules/chains/how_to/debugging.mdx: -------------------------------------------------------------------------------- 1 | # 调试链 (Debugging chains) 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 从输出中仅仅通过`Chain`对象来调试可能很困难,因为大多数`Chain`对象涉及到大量的输入提示预处理和LLM输出后处理。 7 | 8 | import Example from "@snippets/modules/chains/how_to/debugging.mdx" 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/modules/chains/how_to/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 0 3 | --- 4 | # How_to 5 | 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | import DocCardList from "@theme/DocCardList"; 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/chains/how_to/memory.mdx: -------------------------------------------------------------------------------- 1 | # 添加记忆(state) 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 链组件可以使用 Memory 对象进行初始化,该对象将在对链组件的多次调用之间保留数据。这使得链组件具有状态。 7 | 8 | ## 入门 9 | 10 | import GetStarted from "@snippets/modules/chains/how_to/memory.mdx" 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/modules/chains/popular/api.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 0 3 | --- 4 | 5 | 6 | # 添加记忆(state) 7 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 8 | 9 | 10 | 链组件可以使用 Memory 对象进行初始化,该对象将在对链组件的多次调用之间保留数据。这使得链组件具有状态。 11 | # API chains 12 | ## 入门 13 | 14 | import GetStarted from "@snippets/modules/chains/how_to/memory.mdx" 15 | 16 | 17 | -------------------------------------------------------------------------------- /docs/modules/chains/popular/chat_vector_db.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | 5 | # 对话式检索问答(Conversational Retrieval QA) 6 | 7 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 8 | 9 | 对话式检索问答链(ConversationalRetrievalQA chain)是在检索问答链(RetrievalQAChain)的基础上提供了一个聊天历史组件。 10 | 11 | 它首先将聊天历史(可以是显式传入的或从提供的内存中检索到的)和问题合并成一个独立的问题,然后从检索器中查找相关文档,最后将这些文档和问题传递给问答链以返回一个响应。 12 | 13 | 要创建一个对话式检索问答链,您需要一个检索器。在下面的示例中,我们将从一个向量存储中创建一个检索器,这个向量存储可以由嵌入向量创建。 14 | 15 | import Example from "@snippets/modules/chains/popular/chat_vector_db.mdx" 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/modules/chains/popular/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | --- 4 | # 热门(Popular) 5 | 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | import DocCardList from "@theme/DocCardList"; 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/modules/chains/popular/sqlite.mdx: -------------------------------------------------------------------------------- 1 | # SQL 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 这个示例演示了如何使用 `SQLDatabaseChain` 来对 SQL 数据库进行问题回答。 6 | 7 | import Example from "@snippets/modules/chains/popular/sqlite.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/chains/popular/summarize.mdx: -------------------------------------------------------------------------------- 1 | # 摘要 summarize 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 摘要链可以用于对多个文档进行摘要。一种方法是将多个较小的文档输入,将它们划分为块,并使用 MapReduceDocumentsChain 对其进行操作。您还可以选择将摘要链设置为 StuffDocumentsChain 或 RefineDocumentsChain。 6 | 7 | import Example from "@snippets/modules/chains/popular/summarize.mdx" 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/chains/popular/vector_db_qa.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | # 检索型问答(Retrieval QA) 5 | 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | 这个示例展示了在索引上进行问答的过程。 10 | 11 | import Example from "@snippets/modules/chains/popular/vector_db_qa.mdx" 12 | 13 | 14 | 15 | import ExampleWithSources from "@snippets/modules/chains/popular/vector_db_qa_with_sources.mdx" 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/csv.mdx: -------------------------------------------------------------------------------- 1 | # CSV 2 | 3 | > [逗号分隔值 (CSV)](https://en.wikipedia.org/wiki/Comma-separated_values) 文件是一种使用逗号分隔值的分隔文本文件。文件的每一行都是一个数据记录。每个记录由一个或多个字段组成,字段之间用逗号分隔。 4 | 5 | 使用每个文档一行的 CSV 数据加载。 6 | 7 | import Example from "@snippets/modules/data_connection/document_loaders/how_to/csv.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/file_directory.mdx: -------------------------------------------------------------------------------- 1 | # 文件目录 2 | 3 | 这里介绍如何加载目录中的所有文档。 4 | 5 | import Example from "@snippets/modules/data_connection/document_loaders/how_to/file_directory.mdx" 6 | 7 | 8 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/how_to/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'How-to' 2 | position: 0 3 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/how_to/csv.mdx: -------------------------------------------------------------------------------- 1 | # CSV 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | > [逗号分隔值(CSV)](https://zh.wikipedia.org/wiki/逗號分隔值) 文件是一种使用逗号分隔值的定界文本文件。文件的每一行是一个数据记录。每个记录由一个或多个字段组成,字段之间用逗号分隔。 6 | 7 | 使用每个文档一行的 CSV 数据加载。 8 | 9 | import Example from "@snippets/modules/data_connection/document_loaders/how_to/csv.mdx" 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/how_to/file_directory.mdx: -------------------------------------------------------------------------------- 1 | # 文件目录 file_directory 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 这里介绍了如何加载目录中的所有文档。 7 | 8 | import Example from "@snippets/modules/data_connection/document_loaders/how_to/file_directory.mdx" 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/how_to/html.mdx: -------------------------------------------------------------------------------- 1 | # HTML 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | > [超文本标记语言或 HTML](https://en.wikipedia.org/wiki/HTML) 是用于在 Web 浏览器中显示的文档的标准标记语言。 5 | 6 | 这部分介绍如何将 `HTML` 文档加载到我们可以在下游使用的文档格式中。 7 | 8 | import Example from "@snippets/modules/data_connection/document_loaders/how_to/html.mdx" 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/how_to/json.mdx: -------------------------------------------------------------------------------- 1 | # JSON 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | > [JSON (JavaScript Object Notation)](https://en.wikipedia.org/wiki/JSON) 是一种开放标准的文件格式和数据交换格式,存储和传输方便,且可读。JSON 对象由属性 key - 值 value 对和数组(或其他可序列化值)组成的数据对象。 5 | 6 | import Example from "@snippets/modules/data_connection/document_loaders/how_to/json.mdx" 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/how_to/markdown.mdx: -------------------------------------------------------------------------------- 1 | # Markdown 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | > [Markdown](https://en.wikipedia.org/wiki/Markdown) 是一种轻量级标记语言,用于使用纯文本编辑器创建格式化文本。 5 | 6 | 这部分内容介绍了如何将 `Markdown` 文档加载到我们可以在应用程序中要使用的文档格式中。 7 | 8 | import Example from "@snippets/modules/data_connection/document_loaders/how_to/markdown.mdx" 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/how_to/pdf.mdx: -------------------------------------------------------------------------------- 1 | # PDF 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | > [便携式文档格式(PDF)](https://zh.wikipedia.org/wiki/PDF),标准化为 ISO 32000,是 Adobe 于 1992 年开发的一种文件格式,用于以与应用软件、硬件和操作系统无关的方式呈现文档,包括文本格式和图像。 5 | 6 | 这涵盖了如何将 `PDF` 文档加载到我们在下游使用的 Document 格式中。 7 | 8 | import Example from "@snippets/modules/data_connection/document_loaders/how_to/pdf.mdx" 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 0 3 | --- 4 | # 文档加载器 5 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 6 | 7 | 8 | :::info 9 | 前往[Integrations](/docs/integrations/document_loaders/)以获取与第三方工具集成的内置文档加载器的文档。 10 | ::: 11 | 12 | 使用文档加载器从源加载数据作为`Document`。`Document`是一段文本和相关元数据。例如,有用于加载简单的`.txt`文件的文档加载器,用于加载任何网页的文本内容,甚至用于加载YouTube视频的转录稿。 13 | 14 | 文档加载器提供了一个“load”方法,用于从配置的源加载数据作为文档。它们还可以选择实现“延迟加载”,以便将数据惰性加载到内存中。 15 | 16 | ## 入门指南 17 | 18 | import GetStarted from "@snippets/modules/data_connection/document_loaders/get_started.mdx" 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'Integrations' 2 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/acreom.md: -------------------------------------------------------------------------------- 1 | # acreom 2 | 3 | [acreom](https://acreom.com) is a dev-first knowledge base with tasks running on local markdown files. 4 | 5 | Below is an example on how to load a local acreom vault into Langchain. As the local vault in acreom is a folder of plain text .md files, the loader requires the path to the directory. 6 | 7 | Vault files may contain some metadata which is stored as a YAML header. These values will be added to the document’s metadata if `collect_metadata` is set to true. 8 | 9 | 10 | ```python 11 | from langchain.document_loaders import AcreomLoader 12 | ``` 13 | 14 | 15 | ```python 16 | loader = AcreomLoader("", collect_metadata=False) 17 | ``` 18 | 19 | 20 | ```python 21 | docs = loader.load() 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/bilibili.md: -------------------------------------------------------------------------------- 1 | # BiliBili 2 | [Bilibili](https://www.bilibili.tv/) 是中国最受欢迎的长视频网站之一。 3 | 此加载器利用[bilibili-api](https://github.com/MoyuScript/bilibili-api)从 `Bilibili` 获取文本转录。 4 | 通过这个 BiliBiliLoader,用户可以轻松获取所需视频内容的转录。 5 | ```python 6 | #!pip install bilibili-api-python 7 | ``` 8 | ```python 9 | from langchain.document_loaders import BiliBiliLoader 10 | ``` 11 | ```python 12 | loader = BiliBiliLoader(["https://www.bilibili.com/video/BV1xt411o7Xu/"]) 13 | ``` 14 | ```python 15 | loader.load() 16 | ``` -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/chatgpt_loader.md: -------------------------------------------------------------------------------- 1 | ### ChatGPT 数据 2 | [ChatGPT](https://chat.openai.com) 是由OpenAI开发的人工智能(AI)聊天机器人。 3 | 本文档描述了如何从您的 `ChatGPT` 数据导出文件夹加载 `conversations.json`。 4 | 您可以通过电子邮件获取数据导出,方法是转到:https://chat.openai.com/ ->(个人资料)- 设置 -> 导出数据 -> 确认导出。 5 | ```python 6 | from langchain.document_loaders.chatgpt import ChatGPTLoader 7 | ``` 8 | 9 | ```python 10 | loader = ChatGPTLoader(log_file="./example_data/fake_conversations.json", num_logs=1) 11 | ``` 12 | 13 | ```python 14 | loader.load() 15 | ``` 16 | 17 | [Document(page_content="AI Overlords - AI on 2065-01-24 05:20:50: Greetings, humans. I am Hal 9000. You can trust me completely.\n\nAI Overlords - human on 2065-01-24 05:21:20: Nice to meet you, Hal. I hope you won't develop a mind of your own.\n\n", metadata={'source': './example_data/fake_conversations.json'})] 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/conll-u.md: -------------------------------------------------------------------------------- 1 | # CoNLL-U 2 | >[CoNLL-U](https://universaldependencies.org/format.html) 是 CoNLL-X 格式的修订版本。说明以纯文本文件的格式进行编码(UTF-8 编码,规范化为 NFC 格式,仅使用 LF 字符作为换行符,并在文件末尾包含一个 LF 字符),包含三种类型的行: 3 | - 单词行,包含用单个制表符分隔的 10 个字段的单词/标记的注释;请参考下文。 4 | - 空行,标记句子边界。 5 | - 以井号(#)开头的注释行。 6 | 7 | 这是如何加载 [CoNLL-U](https://universaldependencies.org/format.html) 格式文件的示例。整个文件被视为一个文档。示例数据(`conllu.conllu`)基于标准的 UD/CoNLL-U 示例之一。 8 | ```python 9 | from langchain.document_loaders import CoNLLULoader 10 | ``` 11 | ```python 12 | loader = CoNLLULoader("example_data/conllu.conllu") 13 | ``` 14 | ```python 15 | document = loader.load() 16 | ``` 17 | ```python 18 | document 19 | ``` 20 | 21 | [Document(page_content='They buy and sell books.', metadata={'source': 'example_data/conllu.conllu'})] 22 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/copypaste.md: -------------------------------------------------------------------------------- 1 | # Copy Paste 2 | 3 | This notebook covers how to load a document object from something you just want to copy and paste. In this case, you don't even need to use a DocumentLoader, but rather can just construct the Document directly. 4 | 5 | 6 | ```python 7 | from langchain.docstore.document import Document 8 | ``` 9 | 10 | 11 | ```python 12 | text = "..... put the text you copy pasted here......" 13 | ``` 14 | 15 | 16 | ```python 17 | doc = Document(page_content=text) 18 | ``` 19 | 20 | ## Metadata 21 | If you want to add metadata about the where you got this piece of text, you easily can with the metadata key. 22 | 23 | 24 | ```python 25 | metadata = {"source": "internet", "date": "Friday"} 26 | ``` 27 | 28 | 29 | ```python 30 | doc = Document(page_content=text, metadata=metadata) 31 | ``` 32 | 33 | 34 | ```python 35 | 36 | ``` 37 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/example_data/notebook.md: -------------------------------------------------------------------------------- 1 | # 笔记本 NotebookLoader 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 本笔记本介绍了如何将.ipynb 笔记本中的数据加载到适合 LangChain 的格式中。 7 | 8 | 9 | 10 | 11 | ```python 12 | from langchain.document_loaders import NotebookLoader 13 | ``` 14 | 15 | 16 | ```python 17 | loader = NotebookLoader("example_data/notebook.ipynb") 18 | ``` 19 | 20 | `NotebookLoader.load()` 将 `.ipynb` 笔记本文件加载到 `Document` 对象中。 21 | 22 | **参数**: 23 | 24 | * `include_outputs`(bool):是否在生成的文档中包含单元格输出(默认为 False)。 25 | * `max_output_length`(int):从每个单元格输出中包含的最大字符数(默认为 10)。 26 | * `remove_newline`(bool):是否从单元格源和输出中删除换行符(默认为 False)。 27 | * `traceback`(bool):是否包含完整的回溯(默认为 False)。 28 | 29 | 30 | ```python 31 | loader.load(include_outputs=True, max_output_length=20, remove_newline=True) 32 | ``` 33 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/fauna.md: -------------------------------------------------------------------------------- 1 | # Fauna 2 | [Fauna](https://fauna.com/) 是一种文档数据库。 3 | 查询 `Fauna` 文档 4 | ```python 5 | #!pip install fauna 6 | ``` 7 | ## 查询数据示例 8 | ```python 9 | from langchain.document_loaders.fauna import FaunaLoader 10 | 11 | secret = "" 12 | query = "Item.all()" # Fauna 查询。假设集合名为 "Item" 13 | field = "text" # 包含页面内容的字段。假设字段名为 "text" 14 | 15 | loader = FaunaLoader(query, field, secret) 16 | docs = loader.lazy_load() 17 | 18 | for value in docs: 19 | print(value) 20 | ``` 21 | 22 | ### 带分页的查询 23 | 如果有更多数据,您将获得一个 `after` 值。您可以通过在查询中传入 `after` 字符串来获取光标之后的值。 24 | 要了解更多,请参考[此链接](https://fqlx-beta--fauna-docs.netlify.app/fqlx/beta/reference/schema_entities/set/static-paginate) 25 | 26 | ```python 27 | query = """ 28 | Item.paginate("hs+DzoPOg ... aY1hOohozrV7A") 29 | Item.all() 30 | """ 31 | loader = FaunaLoader(query, field, secret) 32 | ``` 33 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/notion.md: -------------------------------------------------------------------------------- 1 | # Notion DB 1/2 2 | 3 | [Notion](https://www.notion.so/)是一个协作平台,支持修改过的Markdown,集成看板,任务,维基和数据库。它是一个集成了笔记、知识和数据管理以及项目和任务管理的全能工作空间。 4 | 5 | 本笔记本介绍了如何从Notion数据库导入文档。 6 | 7 | 要获取Notion数据库导出文件,请按照以下说明操作: 8 | 9 | ## 🟡 自定义数据集的导入说明 10 | 11 | 从Notion导出数据集。您可以通过单击右上角的三个点,然后单击“导出”来完成此操作。 12 | 13 | 在导出时,请确保选择“Markdown和CSV”格式选项。 14 | 15 | 这将在Downloads文件夹中生成一个.zip文件。将.zip文件移动到此存储库中。 16 | 17 | 运行以下命令解压缩zip文件(根据需要替换`Export...`为您自己的文件名)。 18 | 19 | ```shell 20 | unzip Export-d3adfe0f-3131-4bf3-8987-a52017fc1bae.zip -d Notion_DB 21 | ``` 22 | 23 | 运行以下命令导入数据。 24 | 25 | ```python 26 | from langchain.document_loaders import NotionDirectoryLoader 27 | ``` 28 | 29 | ```python 30 | loader = NotionDirectoryLoader("Notion_DB") 31 | ``` 32 | 33 | ```python 34 | docs = loader.load() 35 | ``` 36 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/roam.md: -------------------------------------------------------------------------------- 1 | # Roam 2 | 3 | [ROAM](https://roamresearch.com/) 是一个用于网络思维的笔记工具,旨在创建个人知识库。 4 | 5 | 本笔记本介绍了如何从 Roam 数据库加载文档。这主要受到了[这里](https://github.com/JimmyLv/roam-qa)的示例仓库的启发。 6 | 7 | ## 🟡 指南:如何导入您自己的数据集 8 | 9 | 从 Roam Research 导出您的数据集。您可以通过点击右上角的三个点,然后点击“导出”来完成此操作。 10 | 11 | 在导出时,请确保选择“Markdown 和 CSV”格式选项。 12 | 13 | 这将在您的下载文件夹中生成一个 `.zip` 文件。将 `.zip` 文件移动到此存储库中。 14 | 15 | 运行以下命令解压缩 zip 文件(根据需要替换“Export...”为您自己的文件名): 16 | 17 | ```shell 18 | unzip Roam-Export-1675782732639.zip -d Roam_DB 19 | ``` 20 | 21 | ```python 22 | from langchain.document_loaders import RoamLoader 23 | ``` 24 | 25 | ```python 26 | loader = RoamLoader("Roam_DB") 27 | ``` 28 | 29 | ```python 30 | docs = loader.load() 31 | ``` -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/slack.md: -------------------------------------------------------------------------------- 1 | # Slack 2 | 3 | >[Slack](https://slack.com/) 是一个即时通讯程序。 4 | 5 | 这个笔记本介绍了如何从 Slack 导出生成的 Zip 文件中加载文档。 6 | 7 | 要获得这个 Slack 导出,请按照以下说明操作: 8 | 9 | ## 🟡 自己导入数据集的说明 10 | 11 | 导出您的 Slack 数据。您可以通过转到您的 Workspace Management 页面并点击 Import/Export 选项 ({your_slack_domain}.slack.com/services/export) 来完成此操作。然后,选择正确的日期范围并点击“开始导出”。当导出准备好时,Slack 会向您发送一封电子邮件和一条直接消息。 12 | 13 | 下载将在您的下载文件夹中生成一个 `.zip` 文件(或者根据您的操作系统配置,可以在其他地方找到您的下载文件)。复制 `.zip` 文件的路径,并将其分配给下面的 `LOCAL_ZIPFILE`。 14 | 15 | ```python 16 | from langchain.document_loaders import SlackDirectoryLoader 17 | ``` 18 | 19 | 20 | ```python 21 | # 可选地设置您的 Slack URL。这将在文档源中提供正确的 URL。 22 | SLACK_WORKSPACE_URL = "https://xxx.slack.com" 23 | LOCAL_ZIPFILE = "" # 在此处粘贴到您的 Slack zip 文件的本地路径。 24 | 25 | loader = SlackDirectoryLoader(LOCAL_ZIPFILE, SLACK_WORKSPACE_URL) 26 | ``` 27 | 28 | 29 | ```python 30 | docs = loader.load() 31 | docs 32 | ``` -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/web_base.md: -------------------------------------------------------------------------------- 1 | # WebBaseLoader 2 | 3 | 本页列出了库提供的所有用于管道的实用函数。 4 | 5 | 如果您正在研究库中的模型代码,那么这些函数大多数情况下是有用的。 6 | 7 | 8 | ## 这是二号标题 9 | 10 | [[这是代码]] pipelines.ArgumentHandler D:\liteli\chatGPT\Code\python_langchain_cn\docs\modules\data_connection\document_loaders\integrations\web_base.md 11 | 12 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/web_base_other.md: -------------------------------------------------------------------------------- 1 | ### 应用场景 -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/whatsapp_chat.md: -------------------------------------------------------------------------------- 1 | # WhatsApp Chat 2 | >[WhatsApp](https://www.whatsapp.com/)(也称为`WhatsApp Messenger`)是一款免费的跨平台即时通讯(IM)和网络电话(VoIP)服务。它允许用户发送文字和语音消息,进行语音和视频通话,并分享图像、文档、用户位置和其他内容。 3 | 4 | 本文档介绍了如何将`WhatsApp Chat`中的数据加载到可以被LangChain摄入的格式中。 5 | 6 | ```python 7 | from langchain.document_loaders import WhatsAppChatLoader 8 | ``` 9 | 10 | ```python 11 | loader = WhatsAppChatLoader("example_data/whatsapp_chat.txt") 12 | ``` 13 | 14 | ```python 15 | loader.load() 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/integrations/xml.md: -------------------------------------------------------------------------------- 1 | # XML 2 | 3 | `UnstructuredXMLLoader` 用于加载 `XML` 文件。该加载器适用于 `.xml` 文件。页面内容将是从 XML 标签中提取的文本。 4 | 5 | ```python 6 | from langchain.document_loaders import UnstructuredXMLLoader 7 | ``` 8 | 9 | ```python 10 | loader = UnstructuredXMLLoader( 11 | "example_data/factbook.xml", 12 | ) 13 | docs = loader.load() 14 | docs[0] 15 | ``` 16 | 17 | 18 | 19 | 20 | Document(page_content='United States 21 | 22 | Washington, DC 23 | 24 | Joe Biden 25 | 26 | Baseball 27 | 28 | Canada 29 | 30 | Ottawa 31 | 32 | Justin Trudeau 33 | 34 | Hockey 35 | 36 | France 37 | 38 | Paris 39 | 40 | Emmanuel Macron 41 | 42 | Soccer 43 | 44 | Trinidad & Tobado 45 | 46 | Port of Spain 47 | 48 | Keith Rowley 49 | 50 | Track & Field', metadata={'source': 'example_data/factbook.xml'}) 51 | 52 | 53 | 54 | 55 | ```python 56 | 57 | ``` -------------------------------------------------------------------------------- /docs/modules/data_connection/document_loaders/markdown.mdx: -------------------------------------------------------------------------------- 1 | # Markdown 2 | 3 | [Markdown](https://en.wikipedia.org/wiki/Markdown) 是一种轻量级标记语言,可以使用纯文本编辑器创建格式化文本。 4 | 5 | 本文介绍了如何将 `Markdown` 文档加载到我们可以在下游使用的文档格式中。 6 | 7 | import Example from "@snippets/modules/data_connection/document_loaders/how_to/markdown.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_transformers/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | # 文档转换器 5 | 6 | 前往[集成](/docs/integrations/document_transformers/),查看内置文档转换器与第三方工具的文档。 7 | 8 | 一旦加载了文档,您通常会希望对其进行转换,以更好地适应您的应用程序。最简单的例子是您可能希望将长文档拆分为更小的块,以适应您模型的上下文窗口。LangChain提供了许多内置的文档转换器,使得拆分、合并、过滤和其他文档操作变得容易。 9 | 10 | ## 文本拆分器 11 | 12 | 当您想要处理大块文本时,有必要将文本拆分为块。虽然听起来很简单,但这里存在许多潜在的复杂性。理想情况下,您希望将语义相关的文本片段保持在一起。"语义相关"的含义可能取决于文本的类型。本笔记本演示了几种做法。 13 | 14 | 在高层次上,文本拆分器的工作方式如下: 15 | 16 | 1. 将文本拆分为小的、语义上有意义的块(通常是句子)。 17 | 2. 将这些小块组合成较大的块,直到达到某个大小(由某个函数测量)。 18 | 3. 一旦达到该大小,将该块作为自己的文本片段,然后开始创建一个具有一定重叠的新文本块(以保持块之间的上下文)。 19 | 20 | 这意味着有两个不同的轴可以定制您的文本拆分器: 21 | 22 | 1. 文本如何拆分 23 | 2. 块大小如何测量 24 | 25 | ### 开始使用文本拆分器 26 | 27 | import GetStarted from "@snippets/modules/data_connection/document_transformers/get_started.mdx" 28 | 29 | 30 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_transformers/text_splitters/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'Text splitters' 2 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_transformers/text_splitters/character_text_splitter.mdx: -------------------------------------------------------------------------------- 1 | # 按字符进行拆分 2 | 3 | 这是最简单的方法。它基于字符进行拆分(默认为"\n\n"),并通过字符数量来测量块的长度。 4 | 5 | 1. 文本如何被拆分: 按单个字符拆分。 6 | 2. 块大小如何被测量: 通过字符数量来测量。 7 | 8 | import Example from "@snippets/modules/data_connection/document_transformers/text_splitters/character_text_splitter.mdx" 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_transformers/text_splitters/code_splitter.mdx: -------------------------------------------------------------------------------- 1 | # 代码分割 (Split code) 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | CodeTextSplitter 允许您使用多种语言进行代码分割。导入枚举 `Language` 并指定语言。 5 | 6 | import Example from "@snippets/modules/data_connection/document_transformers/text_splitters/code_splitter.mdx" 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/modules/data_connection/document_transformers/text_splitters/recursive_text_splitter.mdx: -------------------------------------------------------------------------------- 1 | # 递归按字符分割 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | 5 | 这个文本分割器是用于通用文本的推荐分割器。它通过一个字符列表进行参数化。它会按顺序尝试使用这些字符进行分割,直到块的大小足够小。默认列表是 `["\n\n", "\n", " ", ""]`。这样做的效果是尽可能地保持所有段落(然后是句子,然后是单词)在一起,因为它们通常是在语义上相关的文本片段中的最强关联部分。 6 | 7 | 1. 文本如何分割:按字符列表。 8 | 2. 块的大小如何衡量:按字符数。 9 | 10 | import Example from "@snippets/modules/data_connection/document_transformers/text_splitters/recursive_text_splitter.mdx" 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/contextual_compression/index.mdx: -------------------------------------------------------------------------------- 1 | # 上下文压缩 2 | 3 | 检索的一个挑战是,当你将数据导入系统时,通常不知道具体的查询。这意味着与查询相关的最重要的信息可能埋藏在大量无关文本的文档中。将完整的文档通过应用程序传递可能导致更昂贵的LLM调用和更差的响应。 4 | 5 | 上下文压缩旨在解决这个问题。想法很简单:不要立即按原样返回检索到的文档,而是可以使用给定查询的上下文对其进行压缩,以便仅返回相关信息。这里的“压缩”既指对单个文档内容进行压缩,也指整体上滤除文档。 6 | 7 | 要使用上下文压缩检索器,您需要: 8 | - 一个基本的检索器 9 | - 一个文档压缩器 10 | 11 | 上下文压缩检索器将查询传递给基本的检索器,获取初始文档并将其通过文档压缩器进行处理。文档压缩器接收一个文档列表,并通过减少文档内容或完全删除文档来缩短列表。 12 | 13 | ![](https://drive.google.com/uc?id=1CtNgWODXZudxAWSRiWgSGEoTNrUFT98v) 14 | 15 | ## 入门指南 16 | 17 | import Example from "@snippets/modules/data_connection/retrievers/contextual_compression/get_started.mdx" 18 | 19 | 20 | -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/how_to/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'How-to' 2 | position: 0 3 | -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/how_to/contextual_compression/index.mdx: -------------------------------------------------------------------------------- 1 | # 上下文压缩 contextual_compression 2 | 3 | 4 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 5 | 6 | 7 | 在检索中的一个挑战是,通常您不知道将数据导入系统时文档存储系统将面临的具体查询。这意味着与查询相关的最重要信息可能埋藏在具有大量无关文本的文档中。将完整文档通过应用程序传递可能导致更昂贵的 LLM 调用和较差的响应。 8 | 9 | 上下文压缩旨在解决这个问题。其思想很简单:不是立即返回检索到的文档,而是使用给定查询的上下文对其进行压缩,以便仅返回相关信息。这里的“压缩”既指压缩单个文档的内容,也指批量过滤文档。 10 | 11 | 要使用上下文压缩检索器,您需要: 12 | - 一个基础检索器 13 | - 一个文档压缩器 14 | 15 | 上下文压缩检索器将查询传递给基础检索器,获取初始文档并通过文档压缩器进行处理。文档压缩器接受一个文档列表,并通过减少文档内容或完全丢弃文档来缩短列表。 16 | 17 | ![](https://drive.google.com/uc?id=1CtNgWODXZudxAWSRiWgSGEoTNrUFT98v) 18 | 19 | ## 入门 20 | 21 | import Example from "@snippets/modules/data_connection/retrievers/contextual_compression/get_started.mdx" 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/how_to/self_query/index.mdx: -------------------------------------------------------------------------------- 1 | # 自查询 self_query 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 自查询检索器是指具有自我查询能力的检索器。具体而言,给定任何自然语言查询,检索器使用查询构造的 LLM 链来编写结构化查询,然后将该结构化查询应用于其底层的 VectorStore。这使得检索器不仅可以将用户输入的查询用于与存储文档内容的语义相似性比较,还可以从用户查询中提取存储文档的元数据过滤器并执行这些过滤器。 7 | 8 | ![](https://drive.google.com/uc?id=1OQUN-0MJcDUxmPXofgS7MqReEs720pqS) 9 | 10 | import Example from "@snippets/modules/data_connection/retrievers/self_query/get_started.mdx" 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/how_to/time_weighted_vectorstore.mdx: -------------------------------------------------------------------------------- 1 | # 时间加权向量存储检索器 time_weighted_vectorstore 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 该检索器使用语义相似度和时间衰减的组合。 7 | 8 | 评分算法如下: 9 | 10 | ``` 11 | semantic_similarity + (1.0 - decay_rate) ^ hours_passed 12 | ``` 13 | 14 | 值得注意的是,`hours_passed` 指的是检索器中的对象 **上次被访问** 以来经过的小时数,而不是它被创建后经过的小时数。这意味着经常访问的对象保持“新鲜”。 15 | 16 | import Example from "@snippets/modules/data_connection/retrievers/how_to/time_weighted_vectorstore.mdx" 17 | 18 | 19 | -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/how_to/vectorstore.mdx: -------------------------------------------------------------------------------- 1 | # 基于向量存储的检索器 vectorstore 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 向量存储检索器是一种使用向量存储来检索文档的检索器。它是对向量存储类的轻量级封装,以使其符合检索器接口。 7 | 它使用向量存储中实现的搜索方法,如相似性搜索和 MMR,在向量存储中查询文本。 8 | 9 | 一旦构建了一个向量存储,构建一个检索器非常容易。让我们通过一个例子来说明。 10 | 11 | import Example from "@snippets/modules/data_connection/retrievers/how_to/vectorstore.mdx" 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 4 3 | --- 4 | # Retrievers 5 | 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | :::info 10 | 前往[集成](/docs/integrations/retrievers/),了解内置检索器与第三方工具的文档。 11 | ::: 12 | 13 | 检索器是一个接口,根据非结构化查询返回文档。它比向量存储更通用。 14 | 检索器不需要能够存储文档,只需要返回(或检索)它们。向量存储可以用作检索器的支撑,但也有其他类型的检索器。 15 | 16 | ## 入门 17 | 18 | import GetStarted from "@snippets/modules/data_connection/retrievers/get_started.mdx" 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/integrations/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'Integrations' 2 | -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/integrations/aws_kendra_index_retriever.md: -------------------------------------------------------------------------------- 1 | # AWS Kendra 2 | 3 | > AWS Kendra 是由亚马逊网络服务 (AWS) 提供的智能搜索服务。它利用先进的自然语言处理 (NLP) 和机器学习算法,在组织内的各种数据源上实现强大的搜索功能。Kendra 旨在帮助用户快速准确地找到所需的信息,提高生产力和决策能力。 4 | 5 | > 使用 Kendra,用户可以搜索各种内容类型,包括文档、常见问题解答 (FAQ)、知识库、手册和网站。它支持多种语言,能够理解复杂的查询、同义词和上下文含义,提供高度相关的搜索结果。 6 | 7 | ## 使用 AWS Kendra 索引检索器 8 | 9 | 10 | ```python 11 | #!pip install boto3 12 | ``` 13 | 14 | 15 | ```python 16 | import boto3 17 | from langchain.retrievers import AwsKendraIndexRetriever 18 | ``` 19 | 20 | 创建新的检索器 21 | 22 | 23 | ```python 24 | kclient = boto3.client("kendra", region_name="us-east-1") 25 | 26 | retriever = AwsKendraIndexRetriever( 27 | kclient=kclient, 28 | kendraindex="kendraindex", 29 | ) 30 | ``` 31 | 32 | 现在您可以使用从 AWS Kendra 索引中检索的文档 33 | 34 | 35 | ```python 36 | retriever.get_relevant_documents("what is langchain") 37 | ``` 38 | -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/integrations/knn.md: -------------------------------------------------------------------------------- 1 | # kNN 2 | >In statistics, the [k-nearest neighbors algorithm (k-NN)](https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm)是一种非参数的监督学习方法,最早由Evelyn Fix和Joseph Hodges于1951年开发,后来由Thomas Cover扩展。它用于分类和回归。 3 | >本笔记本介绍了如何使用底层使用kNN的检索器。 4 | >基本上基于https://github.com/karpathy/randomfun/blob/master/knn_vs_svm.html 5 | 6 | ```python 7 | from langchain.retrievers import KNNRetriever 8 | from langchain.embeddings import OpenAIEmbeddings 9 | ``` 10 | 11 | ## 使用文本创建新的检索器 12 | 13 | ```python 14 | retriever = KNNRetriever.from_texts( 15 | ["foo", "bar", "world", "hello", "foo bar"], OpenAIEmbeddings() 16 | ) 17 | ``` 18 | 19 | ## 使用检索器 20 | 21 | 现在我们可以使用检索器了! 22 | 23 | 24 | ```python 25 | result = retriever.get_relevant_documents("foo") 26 | ``` 27 | 28 | 29 | ```python 30 | result 31 | ``` -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/self_query/index.mdx: -------------------------------------------------------------------------------- 1 | # 自查询 2 | 3 | 自查询检索器是指具有自我查询能力的检索器。具体而言,给定任何自然语言查询,检索器使用查询构造的LLM链来编写结构化查询,然后将该结构化查询应用于其底层VectorStore。这使得检索器不仅可以将用户输入的查询用于与存储文档内容的语义相似性比较,还可以从用户查询中提取关于存储文档元数据的过滤器,并执行这些过滤器。 4 | 5 | ![](https://drive.google.com/uc?id=1OQUN-0MJcDUxmPXofgS7MqReEs720pqS) 6 | 7 | import Example from "@snippets/modules/data_connection/retrievers/self_query/get_started.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/data_connection/retrievers/time_weighted_vectorstore.mdx: -------------------------------------------------------------------------------- 1 | # 时间加权向量存储检索器 2 | 3 | 此检索器结合了语义相似度和时间衰减进行检索。 4 | 5 | 评分算法为: 6 | 7 | ``` 8 | 语义相似度 + (1.0 - 衰减率) ^ 经过的小时数 9 | ``` 10 | 11 | 值得注意的是,`经过的小时数` 是指自从检索器中的对象**上次访问**以来经过的小时数,而不是自从它被创建以来的小时数。这意味着经常访问的对象保持“新鲜”。 12 | 13 | import Example from "@snippets/modules/data_connection/retrievers/how_to/time_weighted_vectorstore.mdx" 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | # 文本嵌入模型 5 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 6 | 7 | 8 | :::info 9 | 转到[集成](/docs/integrations/text_embedding/)以获取有关内置文本嵌入模型提供商的文档。 10 | ::: 11 | 12 | 嵌入类是一个用于与文本嵌入模型进行交互的类。有很多嵌入模型提供商(OpenAI、Cohere、Hugging Face等)-该类旨在为所有这些提供一个标准接口。 13 | 14 | 嵌入可以创建文本的向量表示。这很有用,因为这意味着我们可以在向量空间中思考文本,并进行语义搜索,其中我们寻找在向量空间中最相似的文本片段。 15 | 16 | LangChain中的基本嵌入类提供两种方法:一种用于嵌入文档,一种用于嵌入查询。前者以多个文本作为输入,而后者以单个文本作为输入。之所以将它们作为两种不同的方法,是因为某些嵌入提供商对于文档(要搜索的文档)和查询(搜索查询本身)有不同的嵌入方法。 17 | 18 | ## 入门指南 19 | 20 | import GetStarted from "@snippets/modules/data_connection/text_embedding/get_started.mdx" 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'Integrations' 2 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/bedrock.md: -------------------------------------------------------------------------------- 1 | # Bedrock Embeddings 2 | 3 | ```python 4 | %pip install boto3 5 | ``` 6 | 7 | ```python 8 | from langchain.embeddings import BedrockEmbeddings 9 | 10 | embeddings = BedrockEmbeddings(credentials_profile_name="bedrock-admin") 11 | ``` 12 | 13 | ```python 14 | embeddings.embed_query("This is a content of the document") 15 | ``` 16 | 17 | ```python 18 | embeddings.embed_documents(["This is a content of the document"]) 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/cohere.md: -------------------------------------------------------------------------------- 1 | # Cohere 2 | 3 | Let's load the Cohere Embedding class. 4 | 5 | ```python 6 | from langchain.embeddings import CohereEmbeddings 7 | ``` 8 | 9 | ```python 10 | embeddings = CohereEmbeddings(cohere_api_key=cohere_api_key) 11 | ``` 12 | 13 | ```python 14 | text = "This is a test document." 15 | ``` 16 | 17 | ```python 18 | query_result = embeddings.embed_query(text) 19 | ``` 20 | 21 | ```python 22 | doc_result = embeddings.embed_documents([text]) 23 | ``` 24 | 25 | ```python 26 | 27 | ``` 28 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/dashscope.md: -------------------------------------------------------------------------------- 1 | # DashScope 2 | 3 | Let's load the DashScope Embedding class. 4 | 5 | 6 | ```python 7 | from langchain.embeddings import DashScopeEmbeddings 8 | ``` 9 | 10 | 11 | ```python 12 | embeddings = DashScopeEmbeddings( 13 | model="text-embedding-v1", dashscope_api_key="your-dashscope-api-key" 14 | ) 15 | ``` 16 | 17 | 18 | ```python 19 | text = "This is a test document." 20 | ``` 21 | 22 | 23 | ```python 24 | query_result = embeddings.embed_query(text) 25 | print(query_result) 26 | ``` 27 | 28 | 29 | ```python 30 | doc_results = embeddings.embed_documents(["foo"]) 31 | print(doc_results) 32 | ``` 33 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/deepinfra.md: -------------------------------------------------------------------------------- 1 | # DeepInfra 2 | 3 | [DeepInfra](https://deepinfra.com/?utm_source=langchain)是一种无服务器的推理服务,提供对[各种LLM模型](https://deepinfra.com/models?utm_source=langchain)和[嵌入模型](https://deepinfra.com/models?type=embeddings&utm_source=langchain)的访问。本笔记本介绍了如何在LangChain中使用DeepInfra进行文本嵌入。 4 | 5 | ```python 6 | # 注册帐户:https://deepinfra.com/login?utm_source=langchain 7 | from getpass import getpass 8 | 9 | DEEPINFRA_API_TOKEN = getpass() 10 | ``` 11 | 12 | ...... 13 | 14 | ## Cosine similarity between "Dog is not a cat" and query: 0.7489097144129355 15 | 16 | Cosine similarity between "Beta is the second letter of Greek alphabet" and query: 0.9519380640702013 17 | 18 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/embaas.md: -------------------------------------------------------------------------------- 1 | # Embaas 2 | 3 | [embaas](https://embaas.io)是一个完全托管的NLP API服务,提供嵌入生成、文档文本提取、文档到嵌入等功能。您可以选择[各种预训练模型](https://embaas.io/docs/models/embeddings)。 4 | 5 | 在本教程中,我们将向您展示如何使用embaas嵌入API为给定的文本生成嵌入。 6 | 7 | ### 先决条件 8 | 在[https://embaas.io/register](https://embaas.io/register)上创建您的免费embaas帐户,并生成一个[API密钥](https://embaas.io/dashboard/api-keys)。 9 | 10 | ```python 11 | # 设置API密钥 12 | embaas_api_key = "YOUR_API_KEY" 13 | # 或设置环境变量 14 | os.environ["EMBAAS_API_KEY"] = "YOUR_API_KEY" 15 | ``` 16 | 17 | ...... 18 | 19 | ```python 20 | # 为单个文档创建嵌入 21 | doc_text = "This is a test document." 22 | doc_text_embedding = embeddings.embed_query(doc_text) 23 | ``` 24 | 25 | ...... 26 | 27 | For more detailed information about the embaas Embeddings API, please refer to [the official embaas API documentation](https://embaas.io/api-reference). -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/fake.md: -------------------------------------------------------------------------------- 1 | # Fake Embeddings 2 | 3 | LangChain also provides a fake embedding class. You can use this to test your pipelines. 4 | 5 | 6 | ```python 7 | from langchain.embeddings import FakeEmbeddings 8 | ``` 9 | 10 | 11 | ```python 12 | embeddings = FakeEmbeddings(size=1352) 13 | ``` 14 | 15 | 16 | ```python 17 | query_result = embeddings.embed_query("foo") 18 | ``` 19 | 20 | 21 | ```python 22 | doc_results = embeddings.embed_documents(["foo"]) 23 | ``` 24 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/huggingfacehub.md: -------------------------------------------------------------------------------- 1 | # Hugging Face Hub 2 | Let's load the Hugging Face Embedding class. 3 | 4 | 5 | ```python 6 | from langchain.embeddings import HuggingFaceEmbeddings 7 | ``` 8 | 9 | 10 | ```python 11 | embeddings = HuggingFaceEmbeddings() 12 | ``` 13 | 14 | 15 | ```python 16 | text = "This is a test document." 17 | ``` 18 | 19 | 20 | ```python 21 | query_result = embeddings.embed_query(text) 22 | ``` 23 | 24 | 25 | ```python 26 | doc_result = embeddings.embed_documents([text]) 27 | ``` 28 | 29 | 30 | ```python 31 | 32 | ``` 33 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/instruct_embeddings.md: -------------------------------------------------------------------------------- 1 | # InstructEmbeddings 2 | Let's load the HuggingFace instruct Embeddings class. 3 | 4 | 5 | ```python 6 | from langchain.embeddings import HuggingFaceInstructEmbeddings 7 | ``` 8 | 9 | 10 | ```python 11 | embeddings = HuggingFaceInstructEmbeddings( 12 | query_instruction="Represent the query for retrieval: " 13 | ) 14 | ``` 15 | 16 | load INSTRUCTOR_Transformer 17 | max_seq_length 512 18 | 19 | 20 | 21 | ```python 22 | text = "This is a test document." 23 | ``` 24 | 25 | 26 | ```python 27 | query_result = embeddings.embed_query(text) 28 | ``` 29 | 30 | 31 | ```python 32 | 33 | ``` 34 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/jina.md: -------------------------------------------------------------------------------- 1 | # Jina 2 | 3 | Let's load the Jina Embedding class. 4 | 5 | 6 | ```python 7 | from langchain.embeddings import JinaEmbeddings 8 | ``` 9 | 10 | 11 | ```python 12 | embeddings = JinaEmbeddings( 13 | jina_auth_token=jina_auth_token, model_name="ViT-B-32::openai" 14 | ) 15 | ``` 16 | 17 | 18 | ```python 19 | text = "This is a test document." 20 | ``` 21 | 22 | 23 | ```python 24 | query_result = embeddings.embed_query(text) 25 | ``` 26 | 27 | 28 | ```python 29 | doc_result = embeddings.embed_documents([text]) 30 | ``` 31 | 32 | In the above example, `ViT-B-32::openai`, OpenAI's pretrained `ViT-B-32` model is used. For a full list of models, see [here](https://cloud.jina.ai/user/inference/model/63dca9df5a0da83009d519cd). 33 | 34 | 35 | ```python 36 | 37 | ``` 38 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/llamacpp.md: -------------------------------------------------------------------------------- 1 | # Llama-cpp 2 | 3 | This notebook goes over how to use Llama-cpp embeddings within LangChain 4 | 5 | 6 | ```python 7 | !pip install llama-cpp-python 8 | ``` 9 | 10 | 11 | ```python 12 | from langchain.embeddings import LlamaCppEmbeddings 13 | ``` 14 | 15 | 16 | ```python 17 | llama = LlamaCppEmbeddings(model_path="/path/to/model/ggml-model-q4_0.bin") 18 | ``` 19 | 20 | 21 | ```python 22 | text = "This is a test document." 23 | ``` 24 | 25 | 26 | ```python 27 | query_result = llama.embed_query(text) 28 | ``` 29 | 30 | 31 | ```python 32 | doc_result = llama.embed_documents([text]) 33 | ``` 34 | -------------------------------------------------------------------------------- /docs/modules/data_connection/text_embedding/integrations/modelscope_hub.md: -------------------------------------------------------------------------------- 1 | # ModelScope 2 | 3 | Let's load the ModelScope Embedding class. 4 | 5 | 6 | ```python 7 | from langchain.embeddings import ModelScopeEmbeddings 8 | ``` 9 | 10 | 11 | ```python 12 | model_id = "damo/nlp_corom_sentence-embedding_english-base" 13 | ``` 14 | 15 | 16 | ```python 17 | embeddings = ModelScopeEmbeddings(model_id=model_id) 18 | ``` 19 | 20 | 21 | ```python 22 | text = "This is a test document." 23 | ``` 24 | 25 | 26 | ```python 27 | query_result = embeddings.embed_query(text) 28 | ``` 29 | 30 | 31 | ```python 32 | doc_results = embeddings.embed_documents(["foo"]) 33 | ``` 34 | -------------------------------------------------------------------------------- /docs/modules/data_connection/vectorstores/integrations/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'Integrations' 2 | -------------------------------------------------------------------------------- /docs/modules/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_class_name: hidden 3 | --- 4 | 5 | # 模块 6 | 7 | LangChain为以下模块提供标准、可扩展的接口和外部集成,按复杂性从低到高列出: 8 | 9 | #### [模型 I/O](/docs/modules/model_io/) 10 | 与语言模型进行交互 11 | #### [检索](/docs/modules/data_connection/) 12 | 与特定应用程序数据进行交互 13 | #### [链式调用](/docs/modules/chains/) 14 | 构建调用序列 15 | #### [代理](/docs/modules/agents/) 16 | 根据高级指令选择使用哪些工具 17 | #### [内存](/docs/modules/memory/) 18 | 在链的运行之间持久化应用程序状态 19 | #### [回调函数](/docs/modules/callbacks/) 20 | 记录和传输任何链的中间步骤 21 | -------------------------------------------------------------------------------- /docs/modules/memory/chat_messages/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | # 聊天消息 5 | 6 | 信息请参阅[Integrations](/docs/integrations/memory/),了解内置内存集成与第三方数据库和工具的文档。 7 | 8 | 一个支持大多数(如果不是全部)内存模块的核心实用类是`ChatMessageHistory`类。 9 | 这是一个超轻量级的包装器,提供了保存HumanMessages、AIMessages以及获取它们的便捷方法。 10 | 11 | 如果您在链外管理内存,您可能希望直接使用这个类。 12 | 13 | import GetStarted from "@snippets/modules/memory/chat_messages/get_started.mdx" 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/modules/memory/how_to/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'How-to' 2 | position: 0 3 | -------------------------------------------------------------------------------- /docs/modules/memory/how_to/buffer.mdx: -------------------------------------------------------------------------------- 1 | # 会话缓存内存 ConversationBufferMemory 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 本文档演示了如何使用 `ConversationBufferMemory`。该内存允许存储消息,并将消息提取到一个变量中。 7 | 8 | 我们可以首先将其提取为字符串。 9 | 10 | import Example from "@snippets/modules/memory/how_to/buffer.mdx" 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/modules/memory/how_to/buffer_window.mdx: -------------------------------------------------------------------------------- 1 | # 会话缓冲窗口记忆 ( Conversation buffer window memory ) 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | 5 | `ConversationBufferWindowMemory` 会随着时间记录会话的交互列表。它只使用最后 K 个交互。这对于保持最近交互的滑动窗口很有用,以避免缓冲区过大 6 | 7 | 让我们首先探索这种类型记忆的基本功能。 8 | 9 | import Example from "@snippets/modules/memory/how_to/buffer_window.mdx" 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/modules/memory/how_to/entity_summary_memory.mdx: -------------------------------------------------------------------------------- 1 | # 实体记忆 entity_summary_memory 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 实体记忆会记住对话中特定实体的给定事实。它使用 LLM 从实体中提取信息,并随时间建立对该实体的知识(也使用 LLM)。 7 | 8 | 让我们首先通过使用这个功能来演示一下。 9 | 10 | import Example from "@snippets/modules/memory/how_to/entity_summary_memory.mdx" 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/modules/memory/how_to/summary.mdx: -------------------------------------------------------------------------------- 1 | # 会话摘要记忆 summary 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 现在让我们来看一下使用稍微复杂的记忆类型 - `ConversationSummaryMemory`。这种记忆类型会随着时间的推移对对话进行摘要。这对于从对话中压缩信息非常有用。 6 | 会话摘要记忆会即时总结对话并将当前摘要存储在记忆中。然后可以将这个记忆用于将到目前为止的对话摘要注入到提示/链中。这种记忆对于较长的对话非常有用,因为将过去的消息历史原样保留在提示中会占用太多的标记。 7 | 8 | 让我们首先探索这种记忆类型的基本功能。 9 | 10 | import Example from "@snippets/modules/memory/how_to/summary.mdx" 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/modules/memory/how_to/vectorstore_retriever_memory.mdx: -------------------------------------------------------------------------------- 1 | # 基于向量存储的记忆 vectorstore_retriever_memory 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | `VectorStoreRetrieverMemory` 在 VectorDB 中存储记忆,并在每次调用时查询最具 "显著性" 的前 K 个文档。 7 | 8 | 与大多数其他 Memory 类不同的是,它不明确跟踪交互的顺序。 9 | 10 | 在这种情况下,"docs" 是先前对话片段。这对于引用对话中 AI 之前告知的相关信息非常有用。 11 | 12 | import Example from "@snippets/modules/memory/how_to/vectorstore_retriever_memory.mdx" 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/modules/memory/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | --- 4 | 5 | # 内存记忆 ( Memory ) 6 | 7 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 8 | 9 | 10 | 默认情况下,链式模型和代理模型都是无状态的,这意味着它们将每个传入的查询独立处理(就像底层的 LLMs 和聊天模型本身一样)。在某些应用程序中,比如聊天机器人,记住先前的交互是至关重要的。无论是短期还是长期,都要记住先前的交互。**Memory** 类正是做到了这一点。 11 | LangChain 提供了两种形式的记忆组件。首先,LangChain 提供了用于管理和操作以前的聊天消息的辅助工具。这些工具被设计成模块化的,无论如何使用都很有用。其次,LangChain 提供了将这些工具轻松整合到链式模型中的方法。 12 | ## 入门 13 | 14 | 记忆涉及在用户与语言模型的交互过程中始终保留状态的概念。用户与语言模型的交互被捕获在 ChatMessages 的概念中,因此这归结为在一系列聊天消息中摄取、捕获、转换和提取知识。有许多不同的方法可以做到这一点,每种方法都作为自己的记忆类型存在。 15 | 通常情况下,对于每种类型的记忆,有两种理解和使用记忆的方式。一种是独立的函数,从一系列消息中提取信息,然后是您可以在链式模型中使用此类型的记忆的方式。 16 | 记忆可以返回多个信息片段(例如,最近的 N 条消息和所有先前消息的摘要)。返回的信息可以是字符串或消息列表。 17 | 18 | import GetStarted from "@snippets/modules/memory/get_started.mdx" 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/modules/memory/integrations/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'Integrations' 2 | -------------------------------------------------------------------------------- /docs/modules/memory/integrations/cassandra_chat_message_history.md: -------------------------------------------------------------------------------- 1 | # Cassandra Chat Message History 2 | 3 | 本笔记本将介绍如何使用Cassandra来存储聊天消息记录。 4 | 5 | Cassandra是一个适合存储大量数据的分布式数据库。 6 | 7 | 它是存储聊天消息记录的好选择,因为它易于扩展,可以处理大量的写入操作。 8 | 9 | 10 | 11 | ```python 12 | # List of contact points to try connecting to Cassandra cluster. 13 | contact_points = ["cassandra"] 14 | ``` 15 | 16 | 17 | ```python 18 | from langchain.memory import CassandraChatMessageHistory 19 | 20 | message_history = CassandraChatMessageHistory( 21 | contact_points=contact_points, session_id="test-session" 22 | ) 23 | 24 | message_history.add_user_message("hi!") 25 | 26 | message_history.add_ai_message("whats up?") 27 | ``` 28 | 29 | 30 | ```python 31 | message_history.messages 32 | ``` 33 | 34 | 35 | 36 | 37 | [HumanMessage(content='hi!', additional_kwargs={}, example=False), 38 | AIMessage(content='whats up?', additional_kwargs={}, example=False)] 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/modules/memory/integrations/postgres_chat_message_history.md: -------------------------------------------------------------------------------- 1 | # Postgres 聊天消息记录 2 | 3 | 本笔记本将介绍如何使用 Postgres 存储聊天消息记录。 4 | 5 | 6 | ```python 7 | from langchain.memory import PostgresChatMessageHistory 8 | 9 | history = PostgresChatMessageHistory( 10 | connection_string="postgresql://postgres:mypassword@localhost/chat_history", 11 | session_id="foo", 12 | ) 13 | 14 | history.add_user_message("hi!") 15 | 16 | history.add_ai_message("whats up?") 17 | ``` 18 | 19 | 20 | ```python 21 | history.messages 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/modules/memory/integrations/redis_chat_message_history.md: -------------------------------------------------------------------------------- 1 | # Redis 聊天消息记录 2 | 3 | 本笔记本将介绍如何使用 Redis 存储聊天消息记录。 4 | 5 | 6 | ```python 7 | from langchain.memory import RedisChatMessageHistory 8 | 9 | history = RedisChatMessageHistory("foo") 10 | 11 | history.add_user_message("hi!") 12 | 13 | history.add_ai_message("whats up?") 14 | ``` 15 | 16 | 17 | ```python 18 | history.messages 19 | ``` 20 | 21 | 22 | 23 | 24 | [AIMessage(content='whats up?', additional_kwargs={}), 25 | HumanMessage(content='hi!', additional_kwargs={})] 26 | 27 | 28 | 29 | 30 | ```python 31 | 32 | ``` 33 | -------------------------------------------------------------------------------- /docs/modules/memory/types/buffer.mdx: -------------------------------------------------------------------------------- 1 | # 会话缓冲区 2 | 3 | 这个笔记本展示了如何使用`ConversationBufferMemory`。这个内存可以用来存储消息,并从中提取消息。 4 | 5 | 我们可以首先将其提取为字符串。 6 | 7 | import Example from "@snippets/modules/memory/types/buffer.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/memory/types/buffer_window.mdx: -------------------------------------------------------------------------------- 1 | # 会话缓冲窗口 2 | 3 | `ConversationBufferWindowMemory` 会在一段时间内保持对话的交互列表。它只使用最后的 K 个交互。这对于保持最近交互的滑动窗口很有用,这样缓冲区就不会变得太大。 4 | 5 | 让我们首先探索这种类型的内存的基本功能。 6 | 7 | import Example from "@snippets/modules/memory/types/buffer_window.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/memory/types/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | # 内存类型 5 | 6 | 有许多不同类型的内存。 7 | 每种类型都有自己的参数、返回类型,在不同的场景中有不同的用途。 8 | 请参阅它们各自的页面以获取更多详细信息。 9 | -------------------------------------------------------------------------------- /docs/modules/memory/types/summary.mdx: -------------------------------------------------------------------------------- 1 | # 会话摘要 2 | 现在让我们来看一下使用稍微复杂的记忆类型 - `ConversationSummaryMemory`。这种类型的记忆会随着时间的推移创建一份对话摘要。这对于从对话中压缩信息非常有用。 3 | 会话摘要记忆将对话进行摘要并将当前摘要存储在记忆中。然后可以将此记忆用于将迄今为止的对话摘要注入到提示/链中。此记忆对于较长的对话非常有用,如果在提示中完全保留过去的消息历史将占用太多的标记。 4 | 5 | 让我们首先探索一下这种类型记忆的基本功能。 6 | 7 | import Example from "@snippets/modules/memory/types/summary.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/memory/types/vectorstore_retriever_memory.mdx: -------------------------------------------------------------------------------- 1 | # 支持向量存储 2 | 3 | `VectorStoreRetrieverMemory`将记忆存储在向量存储中,并在每次调用时查询前K个最"显著"的文档。 4 | 5 | 与大多数其他记忆类不同的是,它不明确跟踪交互的顺序。 6 | 7 | 在这种情况下,"文档"是先前对话片段。这对于提及AI在对话中早些时候被告知的相关信息可能是有用的。 8 | 9 | import Example from "@snippets/modules/memory/types/vectorstore_retriever_memory.mdx" 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/modules/model_io/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 0 3 | sidebar_custom_props: 4 | description: 与语言模型进行接口交互 5 | --- 6 | 7 | # 模型输入输出 8 | 9 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 10 | 11 | 12 | 任何语言模型应用的核心元素是...模型的输入和输出。LangChain 为您提供了与任何语言模型进行接口交互的基本组件。 13 | 14 | - [提示 prompts ](/docs/modules/model_io/prompts/): 将模型输入模板化、动态选择和管理 15 | - [语言模型 models ](/docs/modules/model_io/models/): 通过常见接口调用语言模型 16 | - [输出解析器 output_parsers ](/docs/modules/model_io/output_parsers/): 从模型输出中提取信息 17 | 18 | ![ model_io 图示](/img/model_io.jpg) 19 | 20 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/chat/chat_model_caching.mdx: -------------------------------------------------------------------------------- 1 | # Caching 2 | LangChain为聊天模型提供可选的缓存层。这有两个用途: 3 | 4 | 它可以通过减少对LLM提供者的API调用次数来节省费用,如果您经常多次请求相同的完成。 5 | 它可以通过减少对LLM提供者的API调用次数来加快应用程序的速度。 6 | 7 | import CachingChat from "@snippets/modules/model_io/models/chat/how_to/chat_model_caching.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/chat/how_to/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'How-to' 2 | position: 0 3 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/chat/how_to/llm_chain.mdx: -------------------------------------------------------------------------------- 1 | # LLMChain 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 您可以以非常类似的方式使用现有的 LLMChain - 提供一个提示和一个模型。 6 | 7 | import LLMChain from "@snippets/modules/model_io/models/chat/how_to/llm_chain.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/chat/how_to/prompts.mdx: -------------------------------------------------------------------------------- 1 | # 提示(Prompts) 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | Chat 模型的提示(Prompts)是围绕消息而构建的,而不仅仅是普通文本。 5 | 6 | import Prompts from "@snippets/modules/model_io/models/chat/how_to/prompts.mdx" 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/chat/how_to/streaming.mdx: -------------------------------------------------------------------------------- 1 | # 实时流媒体 streaming 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | 5 | 一些聊天模型提供实时流媒体响应。这意味着您无需等待完整响应返回,而是可以在其可用时开始处理响应。如果您希望在生成响应时将其显示给用户,或者希望在生成响应时处理响应,这将非常有用。 6 | 7 | import StreamingChatModel from "@snippets/modules/model_io/models/chat/how_to/streaming.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/chat/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | # 聊天模型 5 | 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | :::info 10 | 转到[集成](/docs/integrations/chat/),查看与聊天模型提供商的内置集成的文档。 11 | ::: 12 | 13 | 聊天模型是语言模型的一种变体。 14 | 虽然聊天模型在底层使用语言模型,但它们使用的接口有点不同。 15 | 它们不是使用“输入文本,输出文本”的API,而是使用“聊天消息”作为输入和输出的接口。 16 | 17 | 聊天模型的API还比较新,因此我们仍在摸索正确的抽象层。 18 | 19 | ## 开始 20 | 21 | import GetStarted from "@snippets/modules/model_io/models/chat/get_started.mdx" 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/chat/integrations/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'Integrations' 2 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/chat/llm_chain.mdx: -------------------------------------------------------------------------------- 1 | # LLMChain 2 | 3 | 您可以以非常类似的方式使用现有的LLMChain - 提供一个提示和一个模型。 4 | 5 | import LLMChain from "@snippets/modules/model_io/models/chat/how_to/llm_chain.mdx" 6 | 7 | 8 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/chat/streaming.mdx: -------------------------------------------------------------------------------- 1 | # 流式 2 | 3 | 一些聊天模型提供流式响应。这意味着你可以在整个响应返回之前就开始处理它,而不是等待整个响应返回。如果你想要在生成响应时将其显示给用户,或者在生成响应时处理响应,这将非常有用。 4 | 5 | import StreamingChatModel from "@snippets/modules/model_io/models/chat/how_to/streaming.mdx" 6 | 7 | 8 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | # 语言模型 ( Language models ) 5 | 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | LangChain提供了两种类型模型的接口和集成: 10 | 11 | - [LLMs](/docs/modules/model_io/models/llms/): 输入一个文本字符串并返回一个文本字符串的模型 12 | - [聊天模型](/docs/modules/model_io/models/chat/): 由语言模型支持的模型,接受一个聊天消息列表作为输入并返回一个聊天消息 13 | 14 | ## LLMs vs 聊天模型 15 | 16 | LLMs和聊天模型在细微但重要的方面有所不同。LangChain中的LLMs是指纯文本完成模型。它们包装的API接受一个字符串提示作为输入,并输出一个字符串完成。OpenAI的GPT-3是作为LLM实现的。 17 | 聊天模型通常由LLMs支持,但专门调整用于进行对话。关键是,它们的提供者API使用与纯文本完成模型不同的接口。它们不是接受单个字符串作为输入,而是接受一个聊天消息列表作为输入。通常,这些消息带有发言者标签(通常是“系统”,“AI”和“人类”之一)。它们返回一个AI聊天消息作为输出。GPT-4和Anthropic的Claude都是作为聊天模型实现的。 18 | 19 | 为了使LLMs和聊天模型可以互换,两者都实现了基本语言模型接口。这包括常见的方法“predict”,它接受一个字符串并返回一个字符串,以及“predict messages”,它接受消息并返回一个消息。 20 | 如果您正在使用特定模型,建议使用该模型类的特定方法(例如LLMs的“predict”和聊天模型的“predict messages”),但如果您创建的应用程序需要与不同类型的模型一起工作,则共享接口可能会有所帮助。 21 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/llms/how_to/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'How-to' 2 | position: 0 3 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/llms/how_to/llm_caching.mdx: -------------------------------------------------------------------------------- 1 | # 缓存 llm_caching 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | LangChain 为 LLM 提供了一个可选的缓存层。这个功能有两个好处: 6 | 7 | 如果您经常多次请求相同的补全,它可以通过减少您对 LLM 提供者的 API 调用次数来节省费用。 8 | 它可以通过减少您对 LLM 提供者的 API 调用次数来加速您的应用程序。 9 | 10 | import CachingLLM from "@snippets/modules/model_io/models/llms/how_to/llm_caching.mdx" 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/llms/how_to/streaming_llm.mdx: -------------------------------------------------------------------------------- 1 | # 流式传输(Streaming) 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | 一些 LLM 提供流式响应。这意味着您可以在整个响应返回之前开始处理它,而不是等待它完全返回。如果您希望在生成响应时向用户显示响应,或者希望在生成响应时处理响应,这将非常有用。 5 | 6 | import StreamingLLM from "@snippets/modules/model_io/models/llms/how_to/streaming_llm.mdx" 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/llms/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 0 3 | --- 4 | # LLMs 5 | 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | :::info 10 | 前往[集成](/docs/integrations/llms/)以获取与LLM提供商的内置集成的文档。 11 | ::: 12 | 13 | 大型语言模型(LLMs)是LangChain的核心组件。LangChain不提供自己的LLMs,而是提供与许多不同LLMs交互的标准接口。 14 | 15 | ## 入门 16 | 17 | 有很多LLM提供商(OpenAI、Cohere、Hugging Face等)- `LLM`类旨在为所有这些提供商提供标准接口。 18 | 19 | 在本教程中,我们将使用OpenAI LLM包装器,尽管强调的功能对于所有LLM类型都是通用的。 20 | 21 | import LLMGetStarted from "@snippets/modules/model_io/models/llms/get_started.mdx" 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/llms/integrations/_category_.yml: -------------------------------------------------------------------------------- 1 | label: 'Integrations' 2 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/llms/integrations/bedrock.md: -------------------------------------------------------------------------------- 1 | # Bedrock 2 | 3 | [Amazon Bedrock](https://aws.amazon.com/bedrock/) is a fully managed service that makes FMs from leading AI startups and Amazon available via an API, so you can choose from a wide range of FMs to find the model that is best suited for your use case 4 | 5 | 6 | ```python 7 | %pip install boto3 8 | ``` 9 | 10 | 11 | ```python 12 | from langchain.llms.bedrock import Bedrock 13 | 14 | llm = Bedrock( 15 | credentials_profile_name="bedrock-admin", model_id="amazon.titan-tg1-large" 16 | ) 17 | ``` 18 | 19 | ### Using in a conversation chain 20 | 21 | 22 | ```python 23 | from langchain.chains import ConversationChain 24 | from langchain.memory import ConversationBufferMemory 25 | 26 | conversation = ConversationChain( 27 | llm=llm, verbose=True, memory=ConversationBufferMemory() 28 | ) 29 | 30 | conversation.predict(input="Hi there!") 31 | ``` 32 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/llms/integrations/huggingface_textgen_inference.md: -------------------------------------------------------------------------------- 1 | # Huggingface TextGen Inference 2 | 3 | [Text Generation Inference](https://github.com/huggingface/text-generation-inference) is a Rust, Python and gRPC server for text generation inference. Used in production at [HuggingFace](https://huggingface.co/) to power LLMs api-inference widgets. 4 | 5 | This notebooks goes over how to use a self hosted LLM using `Text Generation Inference`. 6 | 7 | To use, you should have the `text_generation` python package installed. 8 | 9 | 10 | ```python 11 | # !pip3 install text_generation 12 | ``` 13 | 14 | 15 | ```python 16 | llm = HuggingFaceTextGenInference( 17 | inference_server_url="http://localhost:8010/", 18 | max_new_tokens=512, 19 | top_k=10, 20 | top_p=0.95, 21 | typical_p=0.95, 22 | temperature=0.01, 23 | repetition_penalty=1.03, 24 | ) 25 | llm("What did foo say about bar?") 26 | ``` 27 | -------------------------------------------------------------------------------- /docs/modules/model_io/models/llms/llm_caching.mdx: -------------------------------------------------------------------------------- 1 | # Caching 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | LangChain提供了LLM的可选缓存层。这对两个原因很有用$: 5 | 6 | 如果您经常多次请求相同的完成,它可以通过减少您对LLM提供者的API调用次数来为您节省资金。 7 | 它可以通过减少您对LLM提供者的API调用次数来加快应用程序的速度。 8 | 9 | import CachingLLM from "@snippets/modules/model_io/models/llms/how_to/llm_caching.mdx" 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/modules/model_io/output_parsers/comma_separated.mdx: -------------------------------------------------------------------------------- 1 | # 列表解析器 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 当您想要返回逗号分隔的项目列表时,可以使用此输出解析器。 7 | 8 | import Example from "@snippets/modules/model_io/output_parsers/comma_separated.mdx" 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/model_io/output_parsers/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | # 输出解析器 (Output Parsers) 5 | 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | 语言模型输出文本。但很多时候,您可能希望获得比仅文本更结构化的信息。这就是输出解析器的作用。 10 | 11 | 输出解析器是帮助结构化语言模型响应的类。一个输出解析器必须实现两个主要方法: 12 | 13 | - "获取格式化指令": 一个返回包含语言模型输出应如何格式化的字符串的方法。 14 | - "解析": 一个接受字符串(假设为语言模型的响应)并将其解析为某种结构的方法。 15 | 16 | 然后再加一个可选的方法: 17 | 18 | - "带提示解析": 一个接受字符串(假设为语言模型的响应)和提示(假设为生成此响应的提示)并将其解析为某种结构的方法。在需要从提示中获取信息以重试或修复输出的情况下,通常提供提示。 19 | 20 | ## 快速入门 21 | 22 | import GetStarted from "@snippets/modules/model_io/output_parsers/get_started.mdx" 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/modules/model_io/output_parsers/output_fixing_parser.mdx: -------------------------------------------------------------------------------- 1 | # 自动修复解析器 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 该输出解析器包装了另一个输出解析器,并在第一个解析器失败时调用另一个LLM来修复任何错误。 7 | 8 | 但是我们除了抛出错误之外还可以做其他事情。具体来说,我们可以将格式错误的输出以及格式化的指令一起传递给模型,并要求它进行修复。 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/model_io/output_parsers/structured.mdx: -------------------------------------------------------------------------------- 1 | # 结构化输出解析器 structured 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 当您想要返回多个字段时,可以使用此输出解析器。尽管 Pydantic/JSON 解析器更强大,但我们最初尝试的数据结构仅具有文本字段。 7 | 8 | import Example from "@snippets/modules/model_io/output_parsers/structured.mdx" 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/model_io/prompts/example_selectors/index.mdx: -------------------------------------------------------------------------------- 1 | # 例子选择器 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 如果您有大量的例子,您可能需要选择要包含在提示中的例子。例子选择器是负责执行此操作的类。 7 | 8 | 基本接口定义如下: 9 | 10 | import GetStarted from "@snippets/modules/model_io/prompts/example_selectors/get_started.mdx" 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/modules/model_io/prompts/example_selectors/length_based.mdx: -------------------------------------------------------------------------------- 1 | # 选择长度 length_based 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 此示例选择器根据长度选择要使用的示例。当您担心构建的提示长度超过上下文窗口的长度时,这很有用。对于较长的输入,它会选择较少的示例进行包含,而对于较短的输入,它会选择更多。 6 | 7 | import Example from "@snippets/modules/model_io/prompts/example_selectors/length_based.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/model_io/prompts/example_selectors/similarity.mdx: -------------------------------------------------------------------------------- 1 | # 选择相似的例子 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 该对象根据与输入的相似度选择例子。它通过找到与输入具有最大余弦相似度的嵌入的例子来实现此目的。 7 | 8 | import Example from "@snippets/modules/model_io/prompts/example_selectors/similarity.mdx" 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/model_io/prompts/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 0 3 | --- 4 | 5 | # 提示(Prompts) 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | 编写模型的新方式是通过提示。 10 | 一个 **提示(prompt)** 指的是输入模型的内容。 11 | 这个输入通常由多个组件构成。 12 | LangChain 提供了多个类和函数,使构建和处理提示变得简单。 13 | 14 | - [提示模板(Prompt templates)](/docs/modules/model_io/prompts/prompt_templates/): 为模型输入添加参数 15 | - [示例选择器(Example selectors)](/docs/modules/model_io/prompts/example_selectors/): 动态选择在提示中包含的示例 -------------------------------------------------------------------------------- /docs/modules/model_io/prompts/prompt_templates/few_shot_examples.mdx: -------------------------------------------------------------------------------- 1 | # Few-shot prompt templates 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 在本教程中,我们将学习如何创建一个使用少样本示例的提示模板。少样本提示模板可以从一组示例或一个示例选择器对象构建。 6 | 7 | import Example from "@snippets/modules/model_io/prompts/prompt_templates/few_shot_examples.mdx" 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/modules/model_io/prompts/prompt_templates/formats.mdx: -------------------------------------------------------------------------------- 1 | # 模板格式 PromptTemplate 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 默认情况下,`PromptTemplate` 会将提供的模板视为 Python f-string。您可以通过 `template_format` 参数指定其他模板格式: 6 | 7 | ```python 8 | # Make sure jinja2 is installed before running this 9 | 10 | jinja2_template = "Tell me a {{ adjective }} joke about {{ content }}" 11 | prompt_template = PromptTemplate.from_template(template=jinja2_template, template_format="jinja2") 12 | 13 | prompt_template.format(adjective="funny", content="chickens") 14 | # -> Tell me a funny joke about chickens. 15 | ``` 16 | 17 | 目前,`PromptTemplate` 仅支持 `jinja2` 和 `f-string` 模板格式。如果您希望使用其他模板格式,请随时在 [Github](https://github.com/hwchase17/langchain/issues) 页面上提交问题。 18 | 19 | -------------------------------------------------------------------------------- /docs/modules/model_io/prompts/prompt_templates/index.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 0 3 | --- 4 | 5 | # 提示模板 6 | 7 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 8 | 9 | 10 | 提示模板是生成语言模型提示的预定义配方。 11 | 12 | 模板可能包括指令、少量示例以及适用于特定任务的特定上下文和问题。 13 | 14 | LangChain提供了创建和使用提示模板的工具。 15 | 16 | LangChain致力于创建与模型无关的模板,以便在不同的语言模型之间轻松重用现有模板。 17 | 18 | import GetStarted from "@snippets/modules/model_io/prompts/prompt_templates/get_started.mdx" 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/modules/model_io/prompts/prompt_templates/partial.mdx: -------------------------------------------------------------------------------- 1 | # 部分提示模板 partial 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 与其他方法一样,"部分化" 提示模板可以很有意义 - 例如,传入所需值的子集,以创建仅期望剩余子集值的新提示模板。 7 | 8 | LangChain 提供了两种方式来支持这种操作: 9 | 1. 使用字符串值进行部分格式化。 10 | 2. 使用返回字符串值的函数进行部分格式化。 11 | 12 | 这两种不同的方式支持不同的用例。在下面的示例中,我们将介绍两种用例的原因以及如何在 LangChain 中执行它们。 13 | 14 | import Example from "@snippets/modules/model_io/prompts/prompt_templates/partial.mdx" 15 | 16 | 17 | -------------------------------------------------------------------------------- /docs/modules/model_io/prompts/prompt_templates/prompt_composition.mdx: -------------------------------------------------------------------------------- 1 | # 组合 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 本笔记本介绍了如何将多个提示组合在一起。当您想要重用提示的部分时,这将非常有用。这可以通过PipelinePrompt来实现。PipelinePrompt由两个主要部分组成: 7 | 8 | - 最终提示: 返回的最终提示 9 | - 管道提示: 由一个字符串名称和一个提示模板组成的元组列表。每个提示模板将被格式化,然后作为相同名称的变量传递给未来的提示模板。 10 | 11 | import Example from "@snippets/modules/model_io/prompts/prompt_templates/prompt_composition.mdx" 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/modules/model_io/prompts/prompt_templates/validate.mdx: -------------------------------------------------------------------------------- 1 | # 验证模板 validate_template 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 默认情况下,`PromptTemplate` 会通过检查 `input_variables` 是否与 `template` 中定义的变量匹配来验证 `template` 字符串。您可以将 `validate_template` 设置为 `False` 来禁用此行为。 7 | 8 | ```python 9 | template = "I am learning langchain because {reason}." 10 | 11 | prompt_template = PromptTemplate(template=template, 12 | input_variables=["reason", "foo"]) # ValueError due to extra variables 13 | prompt_template = PromptTemplate(template=template, 14 | input_variables=["reason", "foo"], 15 | validate_template=False) # No error 16 | ``` 17 | 18 | -------------------------------------------------------------------------------- /docs/templates/docs.md: -------------------------------------------------------------------------------- 1 | # 从包中启动LangServe 2 | 3 | 您还可以直接从包中启动LangServe,而无需将其拉入项目中。 4 | 当您开发一个包并希望快速测试时,这可能非常有用。 5 | 这样做的缺点是,您对LangServe API的配置控制较少, 6 | 因此对于正式的项目,我们建议创建一个完整的项目。 7 | 8 | 要做到这一点,首先将工作目录更改为包本身。 9 | 例如,如果您当前在这个`templates`模块中,您可以进入`pirate-speak`包: 10 | 11 | ```shell 12 | cd pirate-speak 13 | ``` 14 | 15 | 在这个包中有一个`pyproject.toml`文件。 16 | 该文件包含一个`tool.langchain`部分,其中包含有关如何使用此包的信息。 17 | 例如,在`pirate-speak`中,我们可以看到: 18 | 19 | ```text 20 | [tool.langserve] 21 | export_module = "pirate_speak.chain" 22 | export_attr = "chain" 23 | ``` 24 | 25 | 可以使用这些信息自动启动LangServe实例。 26 | 为此,请确保已安装CLI: 27 | 28 | ```shell 29 | pip install -U langchain-cli 30 | ``` 31 | 32 | 然后运行: 33 | 34 | ```shell 35 | langchain template serve 36 | ``` 37 | 38 | 这将为该链启动端点、文档和游乐场。 39 | 例如,您可以在[http://127.0.0.1:8000/playground/](http://127.0.0.1:8000/playground/)上访问游乐场。 40 | 41 | ![LangServe游乐场Web界面的屏幕截图,显示输入和输出字段。](/img/playground.png "LangServe游乐场界面") -------------------------------------------------------------------------------- /docs/use_cases/apis.mdx: -------------------------------------------------------------------------------- 1 | # 与 API 交互 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 7 | 许多数据和信息存储在 API 后面。 8 | 本页面涵盖了 LangChain 中与 API 交互的所有资源。 9 | 10 | ## 链 11 | 12 | 如果您刚刚开始,并且您有相对简单的 API,那么您应该从链开始。 13 | 链是一系列预定步骤,因此它们很适合入门,因为它们给您更多控制权并让您更好地了解发生的情况。 14 | 15 | 16 | - [API 链](/docs/modules/chains/how_to/api.html) 17 | 18 | ## 代理 19 | 20 | 代理更复杂,涉及到多个查询 LML 来了解该做什么。 21 | 代理的缺点是您的控制权较少。优点是它们更强大, 22 | 这使您能够在更大更复杂的架构上使用它们。 23 | 24 | - [OpenAPI 代理](/docs/modules/agents/tools/toolkits/examples/openapi.html) 25 | -------------------------------------------------------------------------------- /docs/use_cases/chatbots/index.mdx: -------------------------------------------------------------------------------- 1 | # 聊天机器人 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | 7 | 由于语言模型擅长生成文本,因此它们非常适合创建聊天机器人。 8 | 除了基本提示/LLM 外,了解聊天机器人的一个重要概念是“记忆(memory)”。 9 | 大多数基于聊天的应用程序依赖于记住先前交互中发生的事情,而“记忆”旨在帮助实现这一目标。 10 | 11 | 存在以下资源: 12 | - [ChatGPT 克隆](/docs/modules/agents/how_to/chatgpt_clone.html):通过 LangChain 重新创建类似 ChatGPT 体验的笔记本。 13 | - [对话记忆](/docs/modules/memory.html):通过不同类型的对话记忆的使用进行演练的笔记本。 14 | - [对话代理](/docs/modules/agents/agent_types/conversational_agent.html):通过演练创建针对对话优化的代理的笔记本。 15 | 16 | 17 | 其他相关资源包括: 18 | - [记忆关键概念](/docs/modules/memory.html):解释与记忆相关的关键概念。 19 | - [记忆示例](/docs/modules/memory/how_to_guides.html):一系列用于处理记忆的示例。 20 | 21 | 更多端到端示例包括: 22 | - [语音助手](./voice_assistant.html):通过 LangChain 创建语音助手的笔记本。 23 | -------------------------------------------------------------------------------- /docs/use_cases/extraction.mdx: -------------------------------------------------------------------------------- 1 | # 提取 extraction 2 | 3 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 4 | 5 | 6 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 7 | 8 | 9 | 10 | 大多数 API 和数据库仍然处理结构化信息。 11 | 因此,为了更好地处理这些信息,从文本中提取结构化信息是有用的。 12 | 例如: 13 | 14 | - 从句子中提取一个结构化行以插入数据库 15 | - 从长文档中提取多个行以插入数据库 16 | - 从用户查询中提取正确的 API 参数 17 | 18 | 这项工作与 [输出解析](/docs/modules/prompts/output_parsers.html) 密切相关。 19 | 输出解析器负责指导 LLM 以特定格式进行响应。 20 | 在这种情况下,输出解析器指定了您希望从文档中提取的数据的格式。 21 | 此外,除了输出格式指令,提示还应包含您希望提取信息的数据。 22 | 23 | 尽管普通的输出解析器足以对响应数据进行基本的结构化处理, 24 | 但在进行提取时,您经常希望提取更复杂或嵌套的结构。 25 | 如果您想深入了解提取,请查看 [`kor`](https://eyurtsev.github.io/kor/), 26 | 这是一个使用现有的 LangChain 链和 OutputParser 抽象的库 27 | 但是允许提取更复杂模式的深入研究。 28 | -------------------------------------------------------------------------------- /docs/use_cases/question_answering/how_to/chat_vector_db.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | 5 | # 存储和引用聊天历史 6 | ConversationalRetrievalQA 链在 RetrievalQAChain 的基础上提供了一个聊天历史组件。 7 | 8 | 首先将聊天历史(可以是显式传入的或从提供的内存中检索到的)和问题合并成一个独立的问题,然后从检索器中查找相关文档,最后将这些文档和问题传递给问答链以返回一个响应。 9 | 10 | 要创建一个,您将需要一个检索器。在下面的示例中,我们将从一个向量存储中创建一个检索器,该向量存储可以从嵌入中创建。 11 | 12 | import Example from "@snippets/modules/chains/popular/chat_vector_db.mdx" 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/use_cases/question_answering/how_to/multi_retrieval_qa_router.mdx: -------------------------------------------------------------------------------- 1 | # 动态选择多个检索器 2 | 3 | 本笔记本演示了如何使用`RouterChain`范例创建一个动态选择要使用的检索系统的链。具体来说,我们将展示如何使用`MultiRetrievalQAChain`创建一个问答链,该链根据给定的问题选择最相关的检索QA链,然后使用它来回答问题。 4 | 5 | import Example from "@snippets/modules/chains/additional/multi_retrieval_qa_router.mdx" 6 | 7 | 8 | -------------------------------------------------------------------------------- /docs/use_cases/question_answering/how_to/vector_db_qa.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | # 使用检索器进行问答 5 | 6 | 这个示例展示了如何在索引上进行问答。 7 | 8 | import Example from "@snippets/modules/chains/popular/vector_db_qa.mdx" 9 | 10 | 11 | 12 | import ExampleWithSources from "@snippets/modules/chains/popular/vector_db_qa_with_sources.mdx" 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/use_cases/summarization.mdx: -------------------------------------------------------------------------------- 1 | # 摘要 summarize 2 | ![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif 'LangChain中文网') 3 | 4 | 摘要是指对多个较长文档进行概括总结。 5 | 这对于将长文档浓缩为核心信息非常有用。 6 | 7 | 使用摘要链的推荐方法是: 8 | 9 | ```python 10 | from langchain.chains.summarize import load_summarize_chain 11 | chain = load_summarize_chain(llm, chain_type="map_reduce") 12 | chain.run(docs) 13 | ``` 14 | 15 | 存在以下资源: 16 | - [摘要笔记本](/docs/modules/chains/popular/summarize.html): 一个指导如何完成这个任务的笔记本。 17 | 18 | 其他相关资源包括: 19 | - [用于处理文档的工具](/api_reference/utils.html): 介绍如何使用几个对该任务有帮助的工具,包括文本分割器(用于拆分长文档)。 20 | -------------------------------------------------------------------------------- /snippets/get_started/quickstart/chains_chat_models.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain import LLMChain 3 | from langchain.chat_models import ChatOpenAI 4 | from langchain.prompts.chat import ( 5 | ChatPromptTemplate, 6 | SystemMessagePromptTemplate, 7 | HumanMessagePromptTemplate, 8 | ) 9 | 10 | chat = ChatOpenAI(temperature=0) 11 | 12 | template = "You are a helpful assistant that translates {input_language} to {output_language}." 13 | system_message_prompt = SystemMessagePromptTemplate.from_template(template) 14 | human_template = "{text}" 15 | human_message_prompt = HumanMessagePromptTemplate.from_template(human_template) 16 | chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt]) 17 | 18 | chain = LLMChain(llm=chat, prompt=chat_prompt) 19 | chain.run(input_language="English", output_language="French", text="I love programming.") 20 | ``` 21 | ```pycon 22 | J'aime programmer. 23 | ``` 24 | -------------------------------------------------------------------------------- /snippets/get_started/quickstart/chains_llms.mdx: -------------------------------------------------------------------------------- 1 | 我们可以将这个: 2 | 3 | ```python 4 | llm.predict("What would be a good company name for a company that makes colorful socks?") 5 | ``` 6 | 7 | 替换为: 8 | 9 | ```python 10 | from langchain.chains import LLMChain 11 | 12 | chain = LLMChain(llm=llm, prompt=prompt) 13 | chain.run("colorful socks") 14 | ``` 15 | ```pycon 16 | Feetful of Fun 17 | ``` 18 | -------------------------------------------------------------------------------- /snippets/get_started/quickstart/chat_model.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain.chat_models import ChatOpenAI 3 | from langchain.schema import ( 4 | AIMessage, 5 | HumanMessage, 6 | SystemMessage 7 | ) 8 | 9 | chat = ChatOpenAI(temperature=0) 10 | chat.predict_messages([HumanMessage(content="Translate this sentence from English to French. I love programming.")]) 11 | # >> AIMessage(content = "J'aime programmer.", additional_kwargs ={}) 12 | ``` 13 | 14 | 对于理解聊天模型与普通语言模型的区别是很有用的,但有时候将它们视为相同的处理方式也是很方便的。 15 | LangChain通过提供一个接口,使得你可以像处理普通语言模型一样与聊天模型进行交互。 16 | 你可以通过`predict`接口来实现这个功能。 17 | 18 | ```python 19 | chat.predict("Translate this sentence from English to French. I love programming.") 20 | # >> J'aime programmer 21 | ``` 22 | -------------------------------------------------------------------------------- /snippets/get_started/quickstart/import_llms.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain.llms import OpenAI 3 | from langchain.chat_models import ChatOpenAI 4 | 5 | llm = OpenAI() 6 | chat_model = ChatOpenAI() 7 | 8 | llm.predict("hi!") 9 | >>> "Hi" 10 | 11 | chat_model.predict("hi!") 12 | >>> "Hi" 13 | ``` -------------------------------------------------------------------------------- /snippets/get_started/quickstart/input_messages.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain.schema import HumanMessage 3 | 4 | text = "制造多彩袜子的公司的好名字是什么?" 5 | messages = [HumanMessage(content=text)] 6 | 7 | llm.predict_messages(messages) 8 | # >> Feetful of Fun 9 | 10 | chat_model.predict_messages(messages) 11 | # >> Socks O'Color 12 | ``` -------------------------------------------------------------------------------- /snippets/get_started/quickstart/input_string.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | text = "What would be a good company name for a company that makes colorful socks?" 3 | 4 | llm.predict(text) 5 | # >> Feetful of Fun 6 | 7 | chat_model.predict(text) 8 | # >> Socks O'Color 9 | ``` -------------------------------------------------------------------------------- /snippets/get_started/quickstart/installation.mdx: -------------------------------------------------------------------------------- 1 | import Tabs from '@theme/Tabs'; 2 | import TabItem from '@theme/TabItem'; 3 | import CodeBlock from "@theme/CodeBlock"; 4 | 5 | 6 | 7 | pip install langchain 8 | 9 | 10 | conda install langchain -c conda-forge 11 | 12 | 13 | -------------------------------------------------------------------------------- /snippets/get_started/quickstart/llm.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain.llms import OpenAI 3 | 4 | llm = OpenAI(temperature=0.9) 5 | ``` 6 | 7 | 现在我们可以传入文本来进行预测了! 8 | 9 | ```python 10 | llm.predict("What would be a good company name for a company that makes colorful socks?") 11 | # >> Feetful of Fun 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /snippets/get_started/quickstart/openai_setup.mdx: -------------------------------------------------------------------------------- 1 | 首先,我们需要安装他们的Python包: 2 | 3 | ```bash 4 | pip install openai 5 | ``` 6 | 7 | 访问API需要一个API密钥,你可以通过创建一个帐户并前往[这里](https://platform.openai.com/account/api-keys)来获取。当我们获得了一个密钥之后,我们需要通过运行以下命令将其设置为环境变量: 8 | 9 | ```bash 10 | export OPENAI_API_KEY="..." 11 | ``` 12 | 13 | 如果你不想设置环境变量,你可以在初始化OpenAI LLM类时直接通过`openai_api_key`命名参数传递密钥: 14 | 15 | ```python 16 | from langchain.llms import OpenAI 17 | 18 | llm = OpenAI(openai_api_key="...") 19 | ``` 20 | -------------------------------------------------------------------------------- /snippets/get_started/quickstart/output_parser.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain.schema import BaseOutputParser 3 | 4 | class CommaSeparatedListOutputParser(BaseOutputParser): 5 | """Parse the output of an LLM call to a comma-separated list.""" 6 | 7 | def parse(self, text: str): 8 | """Parse the output of an LLM call.""" 9 | return text.strip().split(", ") 10 | 11 | CommaSeparatedListOutputParser().parse("hi, bye") 12 | # >> ['hi', 'bye'] 13 | ``` -------------------------------------------------------------------------------- /snippets/get_started/quickstart/prompt_templates_chat_models.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain.prompts.chat import ( 3 | ChatPromptTemplate, 4 | SystemMessagePromptTemplate, 5 | HumanMessagePromptTemplate, 6 | ) 7 | 8 | template = "You are a helpful assistant that translates {input_language} to {output_language}." 9 | system_message_prompt = SystemMessagePromptTemplate.from_template(template) 10 | human_template = "{text}" 11 | human_message_prompt = HumanMessagePromptTemplate.from_template(human_template) 12 | 13 | chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt]) 14 | 15 | chat_prompt.format_messages(input_language="English", output_language="French", text="I love programming.") 16 | ``` 17 | 18 | ```pycon 19 | [ 20 | SystemMessage(content="You are a helpful assistant that translates English to French.", additional_kwargs={}), 21 | HumanMessage(content="I love programming.") 22 | ] 23 | ``` 24 | -------------------------------------------------------------------------------- /snippets/get_started/quickstart/prompt_templates_llms.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain.prompts import PromptTemplate 3 | 4 | prompt = PromptTemplate.from_template("What is a good name for a company that makes {product}?") 5 | prompt.format(product="colorful socks") 6 | ``` 7 | 8 | ```pycon 9 | What is a good name for a company that makes colorful socks? 10 | ``` 11 | -------------------------------------------------------------------------------- /snippets/modules/agents/agent_types/dialogue_system_agent.mdx: -------------------------------------------------------------------------------- 1 | `dialogue_system_agent`是一个使用对话系统组件和动作选择器组件与用户进行交互的代理。它专为多轮对话设计,能够处理有状态的对话并在多个用户输入之间保持上下文。 2 | 3 | ```python 4 | from langchain.pipelines import DialogueSystemAgent 5 | 6 | agent = DialogueSystemAgent(dialogue_system_component, action_selector_component) 7 | ``` 8 | 9 | `dialogue_system_agent`使用两个组件来实现对话系统的功能:`dialogue_system_component`用于处理对话的生成和理解,而`action_selector_component`则负责根据对话状态选择下一步的动作。这样的架构使得我们可以更好地控制对话过程,并实现更加智能和灵活的对话体验。 10 | 11 | -------------------------------------------------------------------------------- /snippets/modules/agents/agent_types/react_chat.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain.chat_models import ChatOpenAI 3 | 4 | chat_model = ChatOpenAI(temperature=0) 5 | agent = initialize_agent(tools, chat_model, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True) 6 | agent.run("Who is Leo DiCaprio's girlfriend? What is her current age raised to the 0.43 power?") 7 | ``` -------------------------------------------------------------------------------- /snippets/modules/agents/tools/get_started.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain.agents import load_tools 3 | tool_names = [...] 4 | tools = load_tools(tool_names) 5 | ``` 6 | 7 | 一些工具(例如 chains,agents)可能需要一个基础 LLM 来初始化它们。 8 | 在这种情况下,您也可以传递一个 LLM: 9 | 10 | ```python 11 | from langchain.agents import load_tools 12 | tool_names = [...] 13 | llm = ... 14 | tools = load_tools(tool_names, llm=llm) 15 | ``` 16 | -------------------------------------------------------------------------------- /snippets/modules/chains/additional/qa_with_sources.mdx: -------------------------------------------------------------------------------- 1 | 我们还可以进行文档问答,并返回用于回答问题的来源。为了做到这一点,我们只需要确保每个文档的元数据中有一个 "source" 键,并使用 `load_qa_with_sources` 助手来构建我们的链: 2 | 3 | ```python 4 | docsearch = Chroma.from_texts(texts, embeddings, metadatas=[{"source": str(i)} for i in range(len(texts))]) 5 | query = "What did the president say about Justice Breyer" 6 | docs = docsearch.similarity_search(query) 7 | ``` 8 | 9 | ```python 10 | from langchain.chains.qa_with_sources import load_qa_with_sources_chain 11 | 12 | chain = load_qa_with_sources_chain(OpenAI(temperature=0), chain_type="stuff") 13 | query = "What did the president say about Justice Breyer" 14 | chain({"input_documents": docs, "question": query}, return_only_outputs=True) 15 | ``` 16 | 17 | 18 | 19 | ``` 20 | {'output_text': ' The president thanked Justice Breyer for his service.\nSOURCES: 30-pl'} 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /snippets/modules/chains/base_class.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | class Chain(BaseModel, ABC): 3 | """Base interface that all chains should implement.""" 4 | 5 | memory: BaseMemory 6 | callbacks: Callbacks 7 | 8 | def __call__( 9 | self, 10 | inputs: Any, 11 | return_only_outputs: bool = False, 12 | callbacks: Callbacks = None, 13 | ) -> Dict[str, Any]: 14 | ... 15 | ``` -------------------------------------------------------------------------------- /snippets/modules/chains/document/combine_docs.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | class BaseCombineDocumentsChain(Chain, ABC): 3 | """Base interface for chains combining documents.""" 4 | 5 | @abstractmethod 6 | def combine_docs(self, docs: List[Document], **kwargs: Any) -> Tuple[str, dict]: 7 | """Combine documents into a single string.""" 8 | 9 | ``` -------------------------------------------------------------------------------- /snippets/modules/chains/document/combine_snippets.mdx: -------------------------------------------------------------------------------- 1 | ## 准备数据 2 | 3 | 首先我们准备数据。在这个示例中,我们对向量数据库进行相似性搜索,但这些文档可以以任何方式获取(这个笔记本的重点是突出显示在获取文档之后要做的事情)。 4 | 5 | ```python 6 | """Base interface for chains combining documents.""" 7 | 8 | @abstractmethod 9 | def combine_docs(self, docs: List[Document], **kwargs: Any) -> Tuple[str, dict]: 10 | """Combine documents into a single string.""" 11 | 12 | ``` -------------------------------------------------------------------------------- /snippets/modules/chains/how_to/memory.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain.chains import ConversationChain 3 | from langchain.memory import ConversationBufferMemory 4 | 5 | conversation = ConversationChain( 6 | llm=chat, 7 | memory=ConversationBufferMemory() 8 | ) 9 | 10 | conversation.run("Answer briefly. What are the first 3 colors of a rainbow?") 11 | # -> The first three colors of a rainbow are red, orange, and yellow. 12 | conversation.run("And the next 4?") 13 | # -> The next four colors of a rainbow are green, blue, indigo, and violet. 14 | ``` 15 | 16 | 17 | 18 | ``` 19 | 'The next four colors of a rainbow are green, blue, indigo, and violet.' 20 | ``` 21 | 22 | 23 | 24 | 基本上,`BaseMemory` 定义了 `langchain` 存储内存的接口。它通过 `load_memory_variables` 方法读取存储的数据,并通过 `save_context` 方法存储新数据。您可以在 [Memory](../memory.html) 部分了解更多信息。 25 | 26 | -------------------------------------------------------------------------------- /snippets/modules/memory/chat_messages/get_started.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | from langchain.memory import ChatMessageHistory 3 | 4 | history = ChatMessageHistory() 5 | 6 | history.add_user_message("hi!") 7 | 8 | history.add_ai_message("whats up?") 9 | ``` 10 | 11 | 12 | ```python 13 | history.messages 14 | ``` 15 | 16 | 17 | 18 | ``` 19 | [HumanMessage(content='hi!', additional_kwargs={}), 20 | AIMessage(content='whats up?', additional_kwargs={})] 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /snippets/modules/model_io/models/chat/how_to/llm_chain.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | chain = LLMChain(llm=chat, prompt=chat_prompt) 3 | ``` 4 | 5 | 6 | ```python 7 | chain.run(input_language="English", output_language="French", text="I love programming.") 8 | ``` 9 | 10 | 11 | 12 | ``` 13 | "J'adore la programmation." 14 | ``` 15 | 16 | 17 | -------------------------------------------------------------------------------- /snippets/modules/model_io/prompts/example_selectors/get_started.mdx: -------------------------------------------------------------------------------- 1 | ```python 2 | class BaseExampleSelector(ABC): 3 | """Interface for selecting examples to include in prompts.""" 4 | 5 | @abstractmethod 6 | def select_examples(self, input_variables: Dict[str, str]) -> List[dict]: 7 | """Select which examples to use based on the inputs.""" 8 | ``` 9 | 10 | 它需要暴露的唯一方法是 ``select_examples`` 方法。 11 | 该方法接受输入变量,然后返回一个示例列表。每个具体的实现可以自行选择这些示例的方式。让我们来看一些示例。 -------------------------------------------------------------------------------- /src/components/HomepageFeatures/styles.module.css: -------------------------------------------------------------------------------- 1 | /* .features { 2 | display: flex; 3 | align-items: center; 4 | padding: 2rem 0; 5 | width: 100%; 6 | } */ 7 | 8 | .featureSvg { 9 | height: 200px; 10 | width: 200px; 11 | } 12 | 13 | .container { 14 | height: 10rem; 15 | background-color: #2e8555; 16 | } 17 | -------------------------------------------------------------------------------- /src/pages/index.module.css: -------------------------------------------------------------------------------- 1 | /** 2 | * CSS files with the .module.css suffix will be treated as CSS modules 3 | * and scoped locally. 4 | */ 5 | 6 | .heroBanner { 7 | padding: 4rem 0; 8 | text-align: center; 9 | position: relative; 10 | overflow: hidden; 11 | } 12 | .main-wrapper { 13 | background-color: #2e8555 !important; 14 | } 15 | 16 | .introwrap { 17 | padding: 5% 0 0; 18 | } 19 | 20 | .introwrap p { 21 | margin: 2% 0 0; 22 | } 23 | 24 | @media screen and (max-width: 996px) { 25 | .heroBanner { 26 | padding: 2rem; 27 | } 28 | } 29 | 30 | .buttons { 31 | display: flex; 32 | align-items: center; 33 | justify-content: center; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/pages/markdown-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Markdown page example 3 | --- 4 | 5 | # Markdown page example 6 | 7 | You don't need React to write simple standalone pages. 8 | -------------------------------------------------------------------------------- /static/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/.nojekyll -------------------------------------------------------------------------------- /static/img/ApifyActors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/ApifyActors.png -------------------------------------------------------------------------------- /static/img/HeliconeDashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/HeliconeDashboard.png -------------------------------------------------------------------------------- /static/img/HeliconeKeys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/HeliconeKeys.png -------------------------------------------------------------------------------- /static/img/MetalDash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/MetalDash.png -------------------------------------------------------------------------------- /static/img/OSS_LLM_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/OSS_LLM_overview.png -------------------------------------------------------------------------------- /static/img/ReAct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/ReAct.png -------------------------------------------------------------------------------- /static/img/RemembrallDashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/RemembrallDashboard.png -------------------------------------------------------------------------------- /static/img/SQLDatabaseToolkit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/SQLDatabaseToolkit.png -------------------------------------------------------------------------------- /static/img/agent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/agent.png -------------------------------------------------------------------------------- /static/img/agents_use_case_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/agents_use_case_1.png -------------------------------------------------------------------------------- /static/img/agents_use_case_trace_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/agents_use_case_trace_1.png -------------------------------------------------------------------------------- /static/img/agents_use_case_trace_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/agents_use_case_trace_2.png -------------------------------------------------------------------------------- /static/img/agents_vs_chains.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/agents_vs_chains.png -------------------------------------------------------------------------------- /static/img/api_chain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/api_chain.png -------------------------------------------------------------------------------- /static/img/api_chain_response.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/api_chain_response.png -------------------------------------------------------------------------------- /static/img/api_function_call.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/api_function_call.png -------------------------------------------------------------------------------- /static/img/api_use_case.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/api_use_case.png -------------------------------------------------------------------------------- /static/img/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/apple-touch-icon.png -------------------------------------------------------------------------------- /static/img/chat_use_case.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/chat_use_case.png -------------------------------------------------------------------------------- /static/img/chat_use_case_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/chat_use_case_2.png -------------------------------------------------------------------------------- /static/img/code_retrieval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/code_retrieval.png -------------------------------------------------------------------------------- /static/img/code_understanding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/code_understanding.png -------------------------------------------------------------------------------- /static/img/contextual_compression.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/contextual_compression.jpg -------------------------------------------------------------------------------- /static/img/cpal_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/cpal_diagram.png -------------------------------------------------------------------------------- /static/img/create_sql_query_chain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/create_sql_query_chain.png -------------------------------------------------------------------------------- /static/img/data_connection.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/data_connection.jpg -------------------------------------------------------------------------------- /static/img/docs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/docs.png -------------------------------------------------------------------------------- /static/img/extraction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/extraction.png -------------------------------------------------------------------------------- /static/img/extraction_trace_function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/extraction_trace_function.png -------------------------------------------------------------------------------- /static/img/extraction_trace_function_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/extraction_trace_function_2.png -------------------------------------------------------------------------------- /static/img/extraction_trace_joke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/extraction_trace_joke.png -------------------------------------------------------------------------------- /static/img/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/favicon-16x16.png -------------------------------------------------------------------------------- /static/img/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/favicon-32x32.png -------------------------------------------------------------------------------- /static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/favicon.ico -------------------------------------------------------------------------------- /static/img/hmbd.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var _hmt = _hmt || []; 3 | (function() { 4 | var hm = document.createElement("script"); 5 | hm.src = "https://hm.baidu.com/hm.js?e60fb290e204e04c5cb6f79b0ac1e697"; 6 | var s = document.getElementsByTagName("script")[0]; 7 | s.parentNode.insertBefore(hm, s); 8 | })(); 9 | })(); -------------------------------------------------------------------------------- /static/img/langchain_stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/langchain_stack.png -------------------------------------------------------------------------------- /static/img/llama-memory-weights.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/llama-memory-weights.png -------------------------------------------------------------------------------- /static/img/llama_t_put.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/llama_t_put.png -------------------------------------------------------------------------------- /static/img/log_traces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/log_traces.png -------------------------------------------------------------------------------- /static/img/map_reduce.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/map_reduce.jpg -------------------------------------------------------------------------------- /static/img/map_rerank.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/map_rerank.jpg -------------------------------------------------------------------------------- /static/img/memory_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/memory_diagram.png -------------------------------------------------------------------------------- /static/img/model_io.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/model_io.jpg -------------------------------------------------------------------------------- /static/img/multi_vector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/multi_vector.png -------------------------------------------------------------------------------- /static/img/oai_function_agent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/oai_function_agent.png -------------------------------------------------------------------------------- /static/img/ollama_example_img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/ollama_example_img.jpg -------------------------------------------------------------------------------- /static/img/parrot-chainlink-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/parrot-chainlink-icon.png -------------------------------------------------------------------------------- /static/img/parrot-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/parrot-icon.png -------------------------------------------------------------------------------- /static/img/playground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/playground.png -------------------------------------------------------------------------------- /static/img/portkey-dashboard.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/portkey-dashboard.gif -------------------------------------------------------------------------------- /static/img/portkey-tracing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/portkey-tracing.png -------------------------------------------------------------------------------- /static/img/pushjd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/pushjd.jpg -------------------------------------------------------------------------------- /static/img/qa_data_load.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/qa_data_load.png -------------------------------------------------------------------------------- /static/img/qa_intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/qa_intro.png -------------------------------------------------------------------------------- /static/img/qa_privacy_protection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/qa_privacy_protection.png -------------------------------------------------------------------------------- /static/img/rag_indexing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/rag_indexing.png -------------------------------------------------------------------------------- /static/img/rag_retrieval_generation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/rag_retrieval_generation.png -------------------------------------------------------------------------------- /static/img/refine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/refine.jpg -------------------------------------------------------------------------------- /static/img/run_details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/run_details.png -------------------------------------------------------------------------------- /static/img/self_querying.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/self_querying.jpg -------------------------------------------------------------------------------- /static/img/sql_usecase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/sql_usecase.png -------------------------------------------------------------------------------- /static/img/sqldbchain_trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/sqldbchain_trace.png -------------------------------------------------------------------------------- /static/img/stuff.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/stuff.jpg -------------------------------------------------------------------------------- /static/img/summarization_use_case_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/summarization_use_case_1.png -------------------------------------------------------------------------------- /static/img/summarization_use_case_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/summarization_use_case_2.png -------------------------------------------------------------------------------- /static/img/summarization_use_case_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/summarization_use_case_3.png -------------------------------------------------------------------------------- /static/img/summary_chains.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/summary_chains.png -------------------------------------------------------------------------------- /static/img/tagging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/tagging.png -------------------------------------------------------------------------------- /static/img/tagging_trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/tagging_trace.png -------------------------------------------------------------------------------- /static/img/test_results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/test_results.png -------------------------------------------------------------------------------- /static/img/vector_stores.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/vector_stores.jpg -------------------------------------------------------------------------------- /static/img/web_research.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/web_research.png -------------------------------------------------------------------------------- /static/img/web_scraping.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/web_scraping.png -------------------------------------------------------------------------------- /static/img/wsj_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liteli1987gmail/python_langchain_cn/3a2794aca97970df301a8e67c2d30c878feeccf2/static/img/wsj_page.png --------------------------------------------------------------------------------