mirror of
https://github.com/hwchase17/langchain.git
synced 2026-01-24 05:50:18 +00:00
q
This commit is contained in:
@@ -102,8 +102,12 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"llm = OpenAI(temperature=0, model='text-davinci-003') # Used for the readers and the query generator\n",
|
||||
"selector_llm = ChatOpenAI(temperature=0, model='gpt-4') # Used for selecting which links to explore"
|
||||
"llm = OpenAI(\n",
|
||||
" temperature=0, model=\"text-davinci-003\"\n",
|
||||
") # Used for the readers and the query generator\n",
|
||||
"selector_llm = ChatOpenAI(\n",
|
||||
" temperature=0, model=\"gpt-4\"\n",
|
||||
") # Used for selecting which links to explore"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -125,7 +129,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"qa_chain = load_qa_chain(llm, chain_type='refine')"
|
||||
"qa_chain = load_qa_chain(llm, chain_type=\"refine\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -138,12 +142,12 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"research = Research.from_llms(\n",
|
||||
" query_generation_llm=llm, \n",
|
||||
" link_selection_llm=selector_llm, \n",
|
||||
" underlying_reader_chain=qa_chain, \n",
|
||||
" top_k_per_search=1, \n",
|
||||
" max_num_pages_per_doc=3, \n",
|
||||
" download_handler=PlaywrightDownloadHandler()\n",
|
||||
" query_generation_llm=llm,\n",
|
||||
" link_selection_llm=selector_llm,\n",
|
||||
" underlying_reader_chain=qa_chain,\n",
|
||||
" top_k_per_search=1,\n",
|
||||
" max_num_pages_per_doc=3,\n",
|
||||
" download_handler=PlaywrightDownloadHandler(),\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
@@ -156,7 +160,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"results = await research.acall(inputs={'question': question})"
|
||||
"results = await research.acall(inputs={\"question\": question})"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -244,9 +248,9 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for doc in results['docs']:\n",
|
||||
" print('--'*80)\n",
|
||||
" print(doc.metadata['source'])\n",
|
||||
"for doc in results[\"docs\"]:\n",
|
||||
" print(\"--\" * 80)\n",
|
||||
" print(doc.metadata[\"source\"])\n",
|
||||
" print(doc.page_content)"
|
||||
]
|
||||
},
|
||||
@@ -267,7 +271,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"qa_chain = load_qa_chain(llm, chain_type='stuff')"
|
||||
"qa_chain = load_qa_chain(llm, chain_type=\"stuff\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -279,7 +283,9 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"summary = await qa_chain.acall(inputs={'input_documents': results['docs'], 'question': question})"
|
||||
"summary = await qa_chain.acall(\n",
|
||||
" inputs={\"input_documents\": results[\"docs\"], \"question\": question}\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -320,7 +326,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(summary['output_text'])"
|
||||
"print(summary[\"output_text\"])"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -362,7 +368,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"suggetions = await research.searcher.acall(inputs={'question': question})\n",
|
||||
"suggetions = await research.searcher.acall(inputs={\"question\": question})\n",
|
||||
"suggetions"
|
||||
]
|
||||
},
|
||||
@@ -376,14 +382,14 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 17,
|
||||
"id": "c6f9d1b5-e513-4d8d-b325-32eacbee92b4",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"blobs = await research.downloader.adownload(suggetions['urls'])"
|
||||
"blobs = await research.downloader.adownload(suggetions[\"urls\"])"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user