debugging Langchain预测函数调用解析错误

wj8zmpe1  于 2023-11-22  发布在  其他
关注(0)|答案(2)|浏览(185)
if topic:
    llm = GooglePalm(google_api_key=google_api_key)
    llm.temperature = 0.1
    template = "Tell me reasons why I am having these symptoms {topic}.
    prompt = PromptTemplate.from_template(template)
    chain = LLMChain(llm=llm, prompt = prompt)
    try:
        chain.predict(topic=topic)
    except Exception as e:
        print(f"Error during chain running: {e}")
        return "An error occurred while processing the chain."

字符串
我在链运行期间遇到错误:运行链时列表索引超出范围。predict(topic=topic)?它来自langchain使用的输出解析器:
/langchain/schema/output_parser.py”,第226行,在parse_result中返回self.parse(result[0].text)~~^^ IndexError:list index out of range
为什么会这样呢?
它应该只输出一些文本,但无法使用predict函数解析它。

zxlwwiss

zxlwwiss1#

Google Palm由于安全原因阻止了您的查询。
Google Palm回应:

{
  "filters": [
    {
      "reason": "SAFETY"
    }
  ],
  "safetyFeedback": [
    {
      "rating": {
        "category": "HARM_CATEGORY_MEDICAL",
        "probability": "HIGH"
      },
      "setting": {
        "category": "HARM_CATEGORY_MEDICAL",
        "threshold": "BLOCK_MEDIUM_AND_ABOVE"
      }
    }
  ]
}

字符串
我在langchain上提出了issue,用于中继Google Palm的正确错误消息。
与此同时,你可以通过curl测试你的基本提示,看看Google Palm发送了什么作为响应:

curl -H 'Content-Type: application/json' -d '{ "prompt": { "text": "Tell me reasons why I am having symptoms of cold"} }' "https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key={PASTE_YOUR_KEY_HERE}

qco9c6ql

qco9c6ql2#

试着重新创建你的vector db,减少块的大小和重叠。

相关问题