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

wj8zmpe1  于 2023-11-22  发布在  其他
关注(0)|答案(2)|浏览(229)
  1. if topic:
  2. llm = GooglePalm(google_api_key=google_api_key)
  3. llm.temperature = 0.1
  4. template = "Tell me reasons why I am having these symptoms {topic}.
  5. prompt = PromptTemplate.from_template(template)
  6. chain = LLMChain(llm=llm, prompt = prompt)
  7. try:
  8. chain.predict(topic=topic)
  9. except Exception as e:
  10. print(f"Error during chain running: {e}")
  11. 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回应:

  1. {
  2. "filters": [
  3. {
  4. "reason": "SAFETY"
  5. }
  6. ],
  7. "safetyFeedback": [
  8. {
  9. "rating": {
  10. "category": "HARM_CATEGORY_MEDICAL",
  11. "probability": "HIGH"
  12. },
  13. "setting": {
  14. "category": "HARM_CATEGORY_MEDICAL",
  15. "threshold": "BLOCK_MEDIUM_AND_ABOVE"
  16. }
  17. }
  18. ]
  19. }

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

  1. 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,减少块的大小和重叠。

相关问题