langchain+chatgpt打造私有文档数据的问答系统代码
代码语言:python
所属分类:其他
代码描述:langchain+chatgpt打造私有文档数据的问答系统代码
代码标签: langchain chatgpt 打造 私有 文档 数据 问答 系统 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
#!/usr/local/python3/bin/python3 from llama_index import SimpleDirectoryReader, LangchainEmbedding, GPTListIndex,GPTSimpleVectorIndex, PromptHelper, LLMPredictor, ServiceContext from langchain import OpenAI import sys import os os.environ["OPENAI_API_KEY"] = 'openai的key' def construct_index(directory_path): #max_input_size = 4096 num_outputs = 2000 #max_chunk_overlap = 20 #chunk_size_limit = 600 #prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit) llm_predictor = LLMPredictor(llm=OpenAI(temperature=0.7, model_name="gpt-3.5-turbo", max_tokens=num_outputs)) documents = SimpleDirectoryReader(directory_path).load_data() #chunk_size_limit表示最大分块大小 service_context = ServiceContext.from_defaults(llm_predictor=l.........完整代码请登录后点击上方下载按钮下载查看
网友评论0