mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-12 04:37:51 +02:00
ci: fix notebook runner & VCR cassette recorder (#1849)
Co-authored-by: vbarda <vadym@langchain.dev>
This commit is contained in:
co-authored by
vbarda
parent
ea0418334b
commit
98f5df4f6f
@@ -51,8 +51,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%capture --no-stderr\n",
|
||||
"%pip install -U langchain_community langchain_openai langgraph wikipedia scikit-learn langchain_fireworks\n",
|
||||
"%pip install -U duckduckgo tavily-python"
|
||||
"%pip install -U langchain_community langchain_openai langchain_fireworks langgraph wikipedia duckduckgo-search tavily-python"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -69,7 +68,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 86,
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -110,16 +109,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain_openai import ChatOpenAI\n",
|
||||
"\n",
|
||||
"fast_llm = ChatOpenAI(model=\"gpt-3.5-turbo\")\n",
|
||||
"fast_llm = ChatOpenAI(model=\"gpt-4o-mini\")\n",
|
||||
"# Uncomment for a Fireworks model\n",
|
||||
"# fast_llm = ChatFireworks(model=\"accounts/fireworks/models/firefunction-v1\", max_tokens=32_000)\n",
|
||||
"long_context_llm = ChatOpenAI(model=\"gpt-4-turbo-preview\")"
|
||||
"long_context_llm = ChatOpenAI(model=\"gpt-4o\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -146,7 +145,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -213,7 +212,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -224,19 +223,19 @@
|
||||
"\n",
|
||||
"## Introduction\n",
|
||||
"\n",
|
||||
"Overview of million-plus token context window language models and RAG (Retrieval-Augmented Generation).\n",
|
||||
"Brief overview of million-plus token context window language models and RAG.\n",
|
||||
"\n",
|
||||
"## Million-Plus Token Context Window Language Models\n",
|
||||
"\n",
|
||||
"Explanation of million-plus token context window language models, their architecture, training data, and applications.\n",
|
||||
"Explanation of million-plus token context window language models, their architecture, training process, and capabilities.\n",
|
||||
"\n",
|
||||
"## RAG (Retrieval-Augmented Generation)\n",
|
||||
"## Retrieval-Augmented Generation (RAG)\n",
|
||||
"\n",
|
||||
"Overview of RAG, its architecture, how it combines retrieval and generation models, and its use in natural language processing tasks.\n",
|
||||
"Explanation of RAG model, its components, and how it combines information retrieval with text generation.\n",
|
||||
"\n",
|
||||
"## Impact on RAG\n",
|
||||
"\n",
|
||||
"Discuss the impact of million-plus token context window language models on RAG, including improvements in performance, efficiency, and challenges faced.\n"
|
||||
"Discussion on how million-plus token context window language models impact RAG, including improvements in performance, efficiency, and potential challenges.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -261,7 +260,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -288,16 +287,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"RelatedSubjects(topics=['Language models', 'Retriever-Reader-Generator (RAG) model', 'Natural language processing', 'Machine learning', 'Artificial intelligence', 'Text generation', 'Transformer architecture', 'Context window', 'Impact of language models'])"
|
||||
"RelatedSubjects(topics=['million-plus token context window language models', 'RAG'])"
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -319,7 +318,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -370,7 +369,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -409,7 +408,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -418,31 +417,35 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'editors': [{'affiliation': 'Academic Research',\n",
|
||||
" 'name': 'Dr. Linguist',\n",
|
||||
" 'role': 'Language Model Expert',\n",
|
||||
" 'description': 'Dr. Linguist will focus on explaining the technical aspects of million-plus token context window language models and their impact on RAG (Retrieval-Augmented Generation) systems.'},\n",
|
||||
" {'affiliation': 'Industry',\n",
|
||||
" 'name': 'TechTrendz',\n",
|
||||
" 'role': 'AI Solutions Architect',\n",
|
||||
" 'description': 'TechTrendz will provide insights on the practical applications of million-plus token context window language models in RAG systems and discuss their benefits and challenges in real-world scenarios.'},\n",
|
||||
" {'affiliation': 'Open Source Community',\n",
|
||||
" 'name': 'CodeGenius',\n",
|
||||
" 'role': 'Machine Learning Enthusiast',\n",
|
||||
" 'description': 'CodeGenius will explore the open-source tools and frameworks available for implementing million-plus token context window language models in RAG systems and share their experiences with the community.'},\n",
|
||||
" {'affiliation': 'Tech Journalism',\n",
|
||||
" 'name': 'DataDive',\n",
|
||||
" 'role': 'AI Technology Journalist',\n",
|
||||
" 'description': 'DataDive will cover the latest developments and advancements in million-plus token context window language models and their implications for RAG systems, focusing on industry trends and use cases.'}]}"
|
||||
"{'editors': [{'affiliation': 'Research Institution',\n",
|
||||
" 'name': 'AliceResearcher',\n",
|
||||
" 'role': 'Researcher',\n",
|
||||
" 'description': 'AliceResearcher focuses on the impact of million-plus token context window language models on the Retrieval-Augmented Generation (RAG) framework. They analyze the effectiveness of large language models within the RAG framework and investigate how these models influence information retrieval and generation tasks.'},\n",
|
||||
" {'affiliation': 'Tech Company',\n",
|
||||
" 'name': 'BobEngineer',\n",
|
||||
" 'role': 'Engineer',\n",
|
||||
" 'description': 'BobEngineer specializes in implementing million-plus token context window language models in practical applications, particularly within the Retrieval-Augmented Generation (RAG) framework. They focus on optimizing the performance and efficiency of these models for real-world usage.'},\n",
|
||||
" {'affiliation': 'Academic Institution',\n",
|
||||
" 'name': 'CharlieAcademic',\n",
|
||||
" 'role': 'Academic',\n",
|
||||
" 'description': 'CharlieAcademic studies the theoretical implications of integrating million-plus token context window language models with the RAG framework. They explore the broader implications of using such large models for natural language processing and information retrieval.'},\n",
|
||||
" {'affiliation': 'Industry Expert',\n",
|
||||
" 'name': 'DianaExpert',\n",
|
||||
" 'role': 'Industry Expert',\n",
|
||||
" 'description': 'DianaExpert provides insights from the industry perspective on the impact of million-plus token context window language models on RAG. They focus on practical applications, challenges, and opportunities that arise when utilizing these models in commercial settings.'},\n",
|
||||
" {'affiliation': 'AI Ethics Organization',\n",
|
||||
" 'name': 'EveEthicist',\n",
|
||||
" 'role': 'Ethicist',\n",
|
||||
" 'description': 'EveEthicist examines the ethical considerations surrounding the use of million-plus token context window language models in the context of RAG. They focus on potential biases, fairness, and transparency issues that may arise from the deployment of such models.'}]}"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -467,7 +470,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -518,7 +521,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -576,16 +579,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"\"Yes, that's correct. I'm focusing on the technical aspects of million-plus token context window language models and their impact on Retrieval-Augmented Generation (RAG) systems. Can you provide more information on how these large context window language models are trained and how they differ from traditional models in the context of RAG systems?\""
|
||||
"\"Yes, that's correct. I focus on studying the impact of million-plus token context window language models on the Retrieval-Augmented Generation (RAG) framework. I analyze how these large language models affect information retrieval and generation tasks within the RAG framework. Is there a specific aspect of this topic that you would like to know more about?\""
|
||||
]
|
||||
},
|
||||
"execution_count": 15,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -615,7 +618,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -641,17 +644,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"['Training process of million-plus token context window language models',\n",
|
||||
" 'Differences between large context window language models and traditional models in Retrieval-Augmented Generation systems']"
|
||||
"['impact of million-plus token context window language models on Retrieval-Augmented Generation (RAG) framework',\n",
|
||||
" 'information retrieval tasks in the RAG framework with large language models',\n",
|
||||
" 'generation tasks in the RAG framework with million-plus token context window models']"
|
||||
]
|
||||
},
|
||||
"execution_count": 17,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -665,7 +669,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -705,7 +709,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -736,7 +740,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -781,16 +785,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'Large context window language models, such as the Llama2 70B model, can support context windows of more than 100k tokens without continual training through innovations like Dual Chunk Attention (DCA). These models have significantly longer context windows compared to traditional models, with capabilities like processing up to 1 million tokens at once, providing more consistent and relevant outputs. Training these models often involves starting with a smaller window size and gradually increasing it through fine-tuning on larger windows. In contrast, traditional models have much shorter context windows, limiting their ability to process extensive information in a prompt. Retrieval-Augmented Generation (RAG) systems, on the other hand, integrate large language models with external knowledge sources to enhance their performance, offering a pathway to combine the capabilities of models like ChatGPT/GPT-4 with custom data sources for more informed and contextually aware outputs.\\n\\nCitations:\\n\\n[1]: https://arxiv.org/abs/2402.17463\\n[2]: https://blog.google/technology/ai/long-context-window-ai-models/\\n[3]: https://medium.com/@ddxzzx/why-and-how-to-achieve-longer-context-windows-for-llms-5f76f8656ea9\\n[4]: https://blog.google/technology/ai/google-gemini-next-generation-model-february-2024/\\n[5]: https://huggingface.co/papers/2402.13753\\n[6]: https://www.pinecone.io/blog/why-use-retrieval-instead-of-larger-context/\\n[7]: https://medium.com/emalpha/innovations-in-retrieval-augmented-generation-8e6e70f95629\\n[8]: https://inside-machinelearning.com/en/rag/'"
|
||||
"'Studying the impact of million-plus token context window language models on the Retrieval-Augmented Generation (RAG) framework involves analyzing how these large language models affect information retrieval and generation tasks within the RAG framework. The introduction of large language models with extensive context windows, such as Google Gemini 1.5 Pro with a record 1 million token context window, has sparked discussions in the AI community about the potential implications for RAG. While there are concerns about the negative impact of supermassive context windows on RAG, there is also a recognition of the benefits they bring, enabling more use cases and enhancing performance in knowledge-intensive tasks. Retrieval-Augmented Generation (RAG) combines the generative capabilities of transformer architectures with dynamic information retrieval, allowing large language models to access and integrate relevant external knowledge during text generation, leading to more accurate and credible outputs. RAG has been identified as a valuable solution to address challenges faced by Large Language Models (LLMs), such as hallucination, outdated knowledge, lack of transparency, and untraceable reasoning processes. By incorporating external databases, RAG improves the consistency and coherence of generated content, especially in conversational question answering tasks. RAG has also been recognized as a powerful tool for large language models to efficiently process overly lengthy contexts, with recent LLMs like Gemini-1.5 and GPT-4 showcasing exceptional capabilities in understanding long contexts directly. There is ongoing research and benchmarking to compare the strengths of RAG and long-context LLMs, aiming to leverage the advantages of both approaches for enhanced performance in information retrieval and generation tasks within the RAG framework.\\n\\nCitations:\\n\\n[1]: https://thenewstack.io/do-enormous-llm-context-windows-spell-the-end-of-rag/\\n[2]: https://medium.com/enterprise-rag/why-gemini-1-5-and-other-large-context-models-are-bullish-for-rag-ce3218930bb4\\n[3]: https://medium.com/@amanatulla1606/rag-is-here-to-stay-four-reasons-why-large-context-windows-cant-replace-it-ad112013de25\\n[4]: https://www.freecodecamp.org/news/retrieval-augmented-generation-rag-handbook/\\n[5]: https://www.deepset.ai/blog/long-context-llms-rag\\n[6]: https://arxiv.org/abs/2312.10997\\n[7]: https://arxiv.org/abs/2409.13385\\n[8]: https://irisagent.com/blog/enhancing-large-language-models-a-deep-dive-into-rag-llm-technology/\\n[9]: https://arxiv.org/abs/2407.16833'"
|
||||
]
|
||||
},
|
||||
"execution_count": 21,
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -814,11 +818,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"max_num_turns = 5\n",
|
||||
"from langgraph.pregel import RetryPolicy\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def route_messages(state: InterviewState, name: str = \"Subject_Matter_Expert\"):\n",
|
||||
@@ -836,18 +841,18 @@
|
||||
"\n",
|
||||
"builder = StateGraph(InterviewState)\n",
|
||||
"\n",
|
||||
"builder.add_node(\"ask_question\", generate_question)\n",
|
||||
"builder.add_node(\"answer_question\", gen_answer)\n",
|
||||
"builder.add_node(\"ask_question\", generate_question, retry=RetryPolicy(max_attempts=5))\n",
|
||||
"builder.add_node(\"answer_question\", gen_answer, retry=RetryPolicy(max_attempts=5))\n",
|
||||
"builder.add_conditional_edges(\"answer_question\", route_messages)\n",
|
||||
"builder.add_edge(\"ask_question\", \"answer_question\")\n",
|
||||
"\n",
|
||||
"builder.add_edge(START, \"ask_question\")\n",
|
||||
"interview_graph = builder.compile().with_config(run_name=\"Conduct Interviews\")"
|
||||
"interview_graph = builder.compile(checkpointer=False).with_config(run_name=\"Conduct Interviews\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -873,7 +878,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -881,19 +886,21 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ask_question\n",
|
||||
"-- [AIMessage(content=\"Yes, that's correct. I am focusing on the technical aspects of million-plus token context window language models and their impact on RAG systems. Can you provide more insight into how these large context window models affect the performance and capabilities of RAG systems?\", name\n",
|
||||
"-- [AIMessage(content=\"Yes, that's correct. My focus is on how million-plus token context window language models impact the Retrieval-Augmented Generation (RAG) framework. I'm interested in understanding how the size and scope of these language models influence the effectiveness of the RAG framework in\n",
|
||||
"answer_question\n",
|
||||
"-- [AIMessage(content='The introduction of large context window language models, such as Gemini 1.5 with a 1 million token context window, has raised concerns in the AI community regarding its impact on Retrieval-Augmented Generation (RAG) systems. RAG systems represent a significant advancement over t\n",
|
||||
"-- [AIMessage(content='The integration of million-plus token context window language models in the Retrieval-Augmented Generation (RAG) framework has emerged as a significant advancement in natural language processing. RAG has been a reliable solution for context-based answer generation, overcoming the\n",
|
||||
"ask_question\n",
|
||||
"-- [AIMessage(content='Thank you for the detailed explanation and resources. Could you elaborate on the specific challenges and opportunities that million-plus token context window language models present for RAG systems in terms of improving generation quality, addressing data biases, and the potentia\n",
|
||||
"-- [AIMessage(content='Can you elaborate on how the retrieval-augmented techniques in the RAG framework enhance the accuracy and relevance of the generated text by accessing external knowledge dynamically? How does this process differ from traditional language modeling approaches, and what specific ben\n",
|
||||
"answer_question\n",
|
||||
"-- [AIMessage(content='Million-plus token context window language models present both challenges and opportunities for RAG systems. Challenges include the increased computational cost and complexity associated with processing larger context windows, potential issues with retaining factual accuracy when\n",
|
||||
"-- [AIMessage(content='The integration of retrieval-augmented techniques in the RAG framework enhances the accuracy and relevance of generated text by dynamically accessing external knowledge sources to enrich the generation process. Unlike traditional language modeling approaches that rely solely on i\n",
|
||||
"ask_question\n",
|
||||
"-- [AIMessage(content='Thank you for the detailed information and references provided. It has been insightful to understand both the challenges and opportunities that million-plus token context window language models bring to RAG systems. I appreciate your assistance in shedding light on this complex t\n",
|
||||
"-- [AIMessage(content='Thank you for the insightful information on how retrieval-augmented techniques enhance the accuracy and relevance of text generation in the RAG framework by incorporating external knowledge sources. How do these external knowledge sources impact the overall performance and adapta\n",
|
||||
"answer_question\n",
|
||||
"-- [AIMessage(content=\"You're welcome! If you have any more questions or need further assistance in the future, feel free to reach out. Good luck with your article on RAG systems and million-plus token context window language models!\\n\\nCitations:\\n\\n[1]: https://www.nerdwallet.com/article/finance/exam\n",
|
||||
"__end__\n",
|
||||
"-- [AIMessage(content='So you said you were writing an article on Impact of million-plus token context window language models on RAG?', name='Subject Matter Expert'), AIMessage(content=\"Yes, that's correct. I am focusing on the technical aspects of million-plus token context window language models and \n"
|
||||
"-- [AIMessage(content='External knowledge sources significantly impact the overall performance and adaptability of RAG models in handling various types of information retrieval and generation tasks. By leveraging external knowledge, RAG models access up-to-date information, reduce the incidence of gene\n",
|
||||
"ask_question\n",
|
||||
"-- [AIMessage(content='Thank you for sharing insights on how external knowledge sources impact the performance and adaptability of RAG models in handling diverse information retrieval and generation tasks. This information will be valuable for my research on the impact of million-plus token context win\n",
|
||||
"answer_question\n",
|
||||
"-- [AIMessage(content=\"The integration of million-plus token context window language models in the Retrieval-Augmented Generation (RAG) framework has sparked discussions in the AI community, with some concerns about the potential impact on RAG's relevance. However, RAG continues to be a valuable soluti\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -913,8 +920,7 @@
|
||||
" name = next(iter(step))\n",
|
||||
" print(name)\n",
|
||||
" print(\"-- \", str(step[name][\"messages\"])[:300])\n",
|
||||
" if END in step:\n",
|
||||
" final_step = step"
|
||||
"final_step = step"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1065,7 +1071,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain_community.vectorstores import SKLearnVectorStore\n",
|
||||
"from langchain_community.vectorstores import InMemoryVectorStore\n",
|
||||
"from langchain_core.documents import Document\n",
|
||||
"from langchain_openai import OpenAIEmbeddings\n",
|
||||
"\n",
|
||||
@@ -1077,11 +1083,11 @@
|
||||
"# This really doesn't need to be a vectorstore for this size of data.\n",
|
||||
"# It could just be a numpy matrix. Or you could store documents\n",
|
||||
"# across requests if you want.\n",
|
||||
"vectorstore = SKLearnVectorStore.from_documents(\n",
|
||||
"vectorstore = InMemoryVectorStore.from_documents(\n",
|
||||
" reference_docs,\n",
|
||||
" embedding=embeddings,\n",
|
||||
")\n",
|
||||
"retriever = vectorstore.as_retriever(k=10)"
|
||||
"retriever = vectorstore.as_retriever(k=3)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1520,7 +1526,7 @@
|
||||
"]\n",
|
||||
"for i in range(len(nodes)):\n",
|
||||
" name, node = nodes[i]\n",
|
||||
" builder_of_storm.add_node(name, node)\n",
|
||||
" builder_of_storm.add_node(name, node, retry=RetryPolicy(max_attempts=3))\n",
|
||||
" if i > 0:\n",
|
||||
" builder_of_storm.add_edge(nodes[i - 1][0], name)\n",
|
||||
"\n",
|
||||
|
||||
Reference in New Issue
Block a user