我在他们的官方网站上搜索了所有 langchain 文档,但没有找到如何从 python 中的 str 变量创建 langchain 文档,所以我在他们的 GitHub 代码中搜索,发现了这个:
doc=Document(
page_content="text",
metadata={"source": "local"}
)
Run Code Online (Sandbox Code Playgroud)
PS:我添加了元数据属性
,然后尝试将该文档与我的链一起使用:
内存和链:
memory = ConversationBufferMemory(memory_key="chat_history", input_key="human_input")
chain = load_qa_chain(
llm, chain_type="stuff", memory=memory, prompt=prompt
)
Run Code Online (Sandbox Code Playgroud)
调用方法:
chain({"input_documents": doc, "human_input": query})
Run Code Online (Sandbox Code Playgroud)
提示模板:
template = """You are a senior financial analyst analyzing the below document and having a conversation with a human.
{context}
{chat_history}
Human: {human_input}
senior financial analyst:"""
prompt = PromptTemplate(
input_variables=["chat_history", "human_input", "context"], template=template
)
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
AttributeError: 'tuple' object has no attribute 'page_content'
Run Code Online (Sandbox Code Playgroud)
当我在将 …
我试图在 google colab 中解压缩 zip 文件,但收到此错误
存档:object_detection.zip 未找到中央目录结尾签名。该文件要么不是 zip 文件,要么构成多部分存档的一张磁盘。在后一种情况下,中央目录和 zip 文件注释将在此存档的最后一个磁盘上找到。unzip:无法在 object_detection.zip 或 object_detection.zip.zip 之一中找到 zipfile 目录,并且无法找到 object_detection.zip.ZIP,期间。
from google.colab import drive
drive.mount('/content/drive')
!cp '/content/drive/My Drive/slim.zip' slim.zip
!unzip object_detection.zip
Run Code Online (Sandbox Code Playgroud)
我已经在驱动器上上传了我的 zip 文件
我在 gooogle colab 中使用来自 parelmouth 的 praat,从 parelmouth.praat 导入调用导入时出现此错误
/usr/local/lib/python3.7/dist-packages/parselmouth/adapters/dfp/interface.py in <module>()
15 from datetime import timedelta
16 from pytz import timezone
---> 17 from urllib import quote
18
19 # Parselmouth Imports
ImportError: cannot import name 'quote' from 'urllib' (/usr/lib/python3.7/urllib/__init__.py)
Run Code Online (Sandbox Code Playgroud)
我尝试安装不同版本的 urllib 但没有任何效果
我知道 urllib 使用 import urllib.parse.quote而不是from urllib import quote 但我不是导入 urllib 包的人,它是 praat 模块,我无法更改它