办理llama_index中利用Ollama出现timed out 问题

打印 上一主题 下一主题

主题 968|帖子 968|积分 2906

征象:
  1.   File "~/anaconda3/envs/leo_py38/lib/python3.8/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
  2.     raise mapped_exc(message) from exc
  3. httpx.ReadTimeout: timed out
复制代码
代码:
  1. from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
  2. from llama_index.embeddings.huggingface import HuggingFaceEmbedding
  3. from llama_index.llms.ollama import Ollama
  4. ###定义使用的llm,embedding 模型
  5. llm = Ollama(model="yi:34b")
  6. embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-large-zh-v1.5")
  7. Settings.llm = llm
  8. Settings.embed_model = embed_model
  9. ## 加载文档
  10. documents = SimpleDirectoryReader("../../data").load_data()
  11. print("documents: ", len(documents))
  12. ## 构建index
  13. index = VectorStoreIndex.from_documents(documents, show_progress=True)
  14. ## 构建query engine
  15. query_engine = index.as_query_engine()
  16. query = "身长九尺,髯长二尺的人是谁?"
  17. ## query
  18. response = query_engine.query(query)
  19. print(f"query:{query}")
  20. print(f"查询结果:{response}")
复制代码
办理办法是增加timeout时长
  1. llm = Ollama(model="yi:34b", request_timeout=500)
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

用多少眼泪才能让你相信

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表