Chi*_*ain 2 langchain gpt4all pygpt4all
from langchain import PromptTemplate, LLMChain
from langchain.llms import GPT4All
from langchain.callbacks.base import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
local_path = './models/gpt4all-converted.bin'
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
template = """Question: {question}
Answer: Let's think step by step.
"""
prompt = PromptTemplate(template=template, input_variables=["question"])
llm = GPT4All(model=local_path,
callback_manager=callback_manager, verbose=True)
llm_chain = LLMChain(prompt=prompt, llm=llm)
question = "What NFL team won the Super Bowl in the year Justin Bieber was born?"
# question = input("Enter your question: ")
llm_chain.run(question)
Run Code Online (Sandbox Code Playgroud)
尝试在本地使用 gpt4all 测试 langchain 并收到此错误。看起来像是版本的东西。我尝试了很多上网冲浪但没有得到任何结果。
Exception ignored in: <function Model.__del__ at 0x7f45417143a0>
Traceback (most recent call last):
File "/home/chirag/.local/lib/python3.8/site-packages/pyllamacpp/model.py", line 336, in __del__
if self._ctx:
AttributeError: 'Model' object has no attribute '_ctx'
Traceback (most recent call last):
File "basic_langchain_setup.py", line 16, in <module>
llm = GPT4All(model=local_path,
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for GPT4All
__root__
__init__() got an unexpected keyword argument 'ggml_model' (type=type_error)
Run Code Online (Sandbox Code Playgroud)
请帮忙解决。
| 归档时间: |
|
| 查看次数: |
3163 次 |
| 最近记录: |