没有合适的资源?快使用搜索试试~ 我知道了~
OpenAI ChatGPT通过文档打造自己的知识库python代码.docx
1 下载量 53 浏览量
2023-05-17
12:41:32
上传
评论
收藏 11KB DOCX 举报
温馨提示
试读
2页
OpenAI ChatGPT通过文档打造自己的知识库python代码
资源推荐
资源详情
资源评论
OpenAI ChatGPT 通过文档打造自己的知识库 python 代码
import sys, os, logging
from llama_index import GPTVectorStoreIndex
from llama_index import SimpleDirectoryReader
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.std
out))
#文件作为知识库文档
def file_query():
documents = SimpleDirectoryReader('./data/mr_fujino').load_data()
index = GPTVectorStoreIndex.from_documents(documents)
index.storage_context.persist()
# rebuild storage context
#storage_context =
StorageContext.from_defaults(persist_dir="./storage")
# load index
#index = load_index_from_storage(storage_context)
query_engine = index.as_query_engine()
response = query_engine.query("雅居乐附近都有什么")
print(response)
资源评论
中本王
- 粉丝: 166
- 资源: 321
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功