Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

生成答案时,调用接口失败 #4

Closed
1 task done
CharmingDaiDai opened this issue May 20, 2024 · 1 comment
Closed
1 task done

生成答案时,调用接口失败 #4

CharmingDaiDai opened this issue May 20, 2024 · 1 comment

Comments

@CharmingDaiDai
Copy link

CharmingDaiDai commented May 20, 2024

检查之前的issues

  • 我已经检查过之前的issues,没有我遇到的问题

描述Bug

调用接口失败

配置信息加载完成。
模型和重排器初始化完成。
向量存储和客户端初始化完成。
集合中没有数据,开始导入数据。
build_pipeline
update_collection
Parsing nodes: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 42139/42139 [00:14<00:00, 2947.44it/s]
Generating embeddings: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 31/31 [02:04<00:00,  4.01s/it]
arun
数据导入完成,共导入 42139 条数据。
检索器初始化完成。
读取查询文件完成,共读取 5 个问题。
开始生成答案...
  0%|                                                                                                                                                        | 0/5 [00:00<?, ?it/s]retrieved:
[NodeWithScore(node=TextNode(id_='9a97c71d-40fd-4e8f-9a0c-27b1b4fae26f', embedding=None, metadata={'file_path': 'CommonS_HTTP_LB/zh-cn/tree/6426959.txt', 'file_name': '6426959.txt', 'file_type': 'text/plain', 'file_size': 1318, 'creation_date': '2024-05-20', 'last_modified_date': '2024-03-12', 'document_title': '# PCF配置'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={<NodeRelationship.SOURCE: '1'>: RelatedNodeInfo(node_id='77f4436e-3317-4907-9f77-89418fc8869d', node_type=<ObjectType.DOCUMENT: '4'>, metadata={'file_path': '/data1/wjm/projects/AIOPS/aiops24-RAG-demo/demo/data/rcp/CommonS_HTTP_LB/zh-cn/tree/6426959.txt', 'file_name': '6426959.txt', 'file_type': 'text/plain', 'file_size': 1318, 'creation_date': '2024-05-20', 'last_modified_date': '2024-03-12'}, hash='e512d05aacda5af2f1bae00ac8b0c8ea5adf5e5d64422da7d14c28764795e972'), <NodeRelationship.PREVIOUS: '2'>: RelatedNodeInfo(node_id='e1d7ebaf-e8a9-461b-93dc-4362feaef901', node_type=<ObjectType.TEXT: '1'>, metadata={'file_path': '/data1/wjm/projects/AIOPS/aiops24-RAG-demo/demo/data/rcp/CommonS_HTTP_LB/zh-cn/tree/642695869.txt', 'file_name': '642695869.txt', 'file_type': 'text/plain', 'file_size': 1536, 'creation_date': '2024-05-20', 'last_modified_date': '2024-03-12'}, hash='0fa9e2eb4955d4b1c1269bd8562fccafb044088b0fa37635046415c2e3ec11e0'), <NodeRelationship.NEXT: '3'>: RelatedNodeInfo(node_id='6b5047bc-78f8-43b0-9767-a92470045e5e', node_type=<ObjectType.TEXT: '1'>, metadata={}, hash='58ac580dae586f8f6782fdf004b05a1baebe10ff456e4496981a4ffae55e541a')}, text='# PCF配置\n\n## 背景知识\n\nPCF(Policy Control Function,策略控制功能)是5G核心网中的网络实体,提供统一的策略框架和控制平面功能的策略规则。\n\n当服务提供者(对端)向NRF注册时,如果对端的NF(Network Function,网络功能)类型为PCF,注册请求中携带的对端NFProfile参数可以包含PCF信息(PcfInfo)参数,该参数又包含了一些通用或PCF特有的参数。\n\n当服务使用者(本端)向NRF发现可用的服务提供者(对端),并且对端的NF类型为PCF时,NRF可以用服务发现请求中的发现参数与对端NFProfile包含的PCF信息进行比较,如果能匹配成功,则认为发现成功,并且在发现响应中携带该NFProfile。当本端启用本地NRF功能时,PCF信息配置会呈现在对端NFProfile的PCF信息参数中。\n\n## 功能说明\n\nPCF配置为命令树目录,下面包含了PCF信息配置。PCF信息配置即对应本地NRF配置的对端NFProfile的PCF信息参数,如果不配置,则对端NFProfile缺少PCF信息参数,本端如果需要发现可用的对端PCF时,就无法进行有效的发现参数匹配,可能导致业务失败。当启用本地NRF功能时,需要配置该命令。\n\n## 子主题:\n\n  * PCF信息配置\n  * PCF信息组配置', start_char_idx=0, end_char_idx=579, text_template='[Excerpt from document]\n{metadata_str}\nExcerpt:\n-----\n{content}\n-----\n', metadata_template='{key}: {value}', metadata_seperator='\n'), score=0.7117493365147981), NodeWithScore(node=TextNode(id_='6b5047bc-78f8-43b0-9767-a92470045e5e', embedding=None, metadata={'file_path': 'CommonS_HTTP_LB/zh-cn/tree/642695970.txt', 'file_name': '642695970.txt', 'file_type': 'text/plain', 'file_size': 1387, 'creation_date': '2024-05-20', 'last_modified_date': '2024-03-12', 'document_title': '# PCF信息配置'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={<NodeRelationship.SOURCE: '1'>: RelatedNodeInfo(node_id='eb53c5df-2b60-4e12-99a1-f05574e6a1ac', node_type=<ObjectType.DOCUMENT: '4'>, metadata={'file_path': '/data1/wjm/projects/AIOPS/aiops24-RAG-demo/demo/data/rcp/CommonS_HTTP_LB/zh-cn/tree/642695970.txt', 'file_name': '642695970.txt', 'file_type': 'text/plain', 'file_size': 1387, 'creation_date': '2024-05-20', 'last_modified_date': '2024-03-12'}, hash='fa50ccebf358f2fad03ffc6396e260fdf2f7cf635a053a079fe6abccd637da53'), <NodeRelationship.PREVIOUS: '2'>: RelatedNodeInfo(node_id='9a97c71d-40fd-4e8f-9a0c-27b1b4fae26f', node_type=<ObjectType.TEXT: '1'>, metadata={'file_path': '/data1/wjm/projects/AIOPS/aiops24-RAG-demo/demo/data/rcp/CommonS_HTTP_LB/zh-cn/tree/6426959.txt', 'file_name': '6426959.txt', 'file_type': 'text/plain', 'file_size': 1318, 'creation_date': '2024-05-20', 'last_modified_date': '2024-03-12'}, hash='aeca63902ab1d9c9297f645b232e1791e5c34ff277d763a803d5c36a6d25b3fa'), <NodeRelationship.NEXT: '3'>: RelatedNodeInfo(node_id='56eab3ec-fac1-43c6-acd2-8dfee88cd7c7', node_type=<ObjectType.TEXT: '1'>, metadata={}, hash='250a49f9bcd2fbf3f41c82477129493fe8b20321db0992273a96cff9fbb7f7fe')}, text='# PCF信息配置\n\n## 背景知识\n\nPCF(Policy Control Function,策略控制功能)是5G核心网中的网络实体,提供统一的策略框架和控制平面功能的策略规则。\n\n当服务提供者(对端)向NRF注册时,如果对端的NF(Network Function,网络功能)类型为PCF,注册请求中携带的对端NFProfile参数可以包含PCF信息(PcfInfo)参数,该参数又包含了一些通用或PCF特有的参数。\n\n当服务使用者(本端)向NRF发现可用的服务提供者(对端),并且对端的NF类型为PCF时,NRF可以用服务发现请求中的发现参数与对端NFProfile包含的PCF信息进行比较,如果能匹配成功,则认为发现成功,并且在发现响应中携带该NFProfile。当本端启用本地NRF功能时,PCF信息配置会呈现在对端NFProfile的PCF信息参数中。\n\n## 功能说明\n\nPCF信息配置即对应本地NRF配置的对端NFProfile的PCF信息参数,如果不配置,则对端NFProfile缺少PCF信息参数,本端如果需要发现可用的对端PCF时,就无法进行有效的发现参数匹配,可能导致业务失败。当启用本地NRF功能时,需要配置该命令。\n\n## 子主题:\n\n  * 新增PCF信息配置(ADD SBIPCFINFO)\n  * 修改PCF信息配置(SET SBIPCFINFO)\n  * 删除PCF信息配置(DEL SBIPCFINFO)\n  * 查询PCF信息配置(SHOW SBIPCFINFO)', start_char_idx=0, end_char_idx=652, text_template='[Excerpt from document]\n{metadata_str}\nExcerpt:\n-----\n{content}\n-----\n', metadata_template='{key}: {value}', metadata_seperator='\n'), score=0.7070457266023675), NodeWithScore(node=TextNode(id_='08a5e8cf-c2e1-4f71-a187-6839e7f0621a', embedding=None, metadata={'file_path': 'data/umac/初始配置/1586917989971.txt', 'file_name': '1586917989971.txt', 'file_type': 'text/plain', 'file_size': 4294, 'creation_date': '2024-05-20', 'last_modified_date': '2024-05-11', 'document_title': '配置与NRF对接数据'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={<NodeRelationship.SOURCE: '1'>: RelatedNodeInfo(node_id='2745ad19-90ff-4369-8bb5-ad8abe0d1b65', node_type=<ObjectType.DOCUMENT: '4'>, metadata={'file_path': '/data1/wjm/projects/AIOPS/aiops24-RAG-demo/demo/data/umac/初始配置/1586917989971.txt', 'file_name': '1586917989971.txt', 'file_type': 'text/plain', 'file_size': 4294, 'creation_date': '2024-05-20', 'last_modified_date': '2024-05-11'}, hash='fdd38b64649e0e5645044eca886481ec02eed239929df2265c9f04980a93e58f'), <NodeRelationship.PREVIOUS: '2'>: RelatedNodeInfo(node_id='d66d742d-94a4-449c-9b88-d3a97f5c7c18', node_type=<ObjectType.TEXT: '1'>, metadata={'file_path': '/data1/wjm/projects/AIOPS/aiops24-RAG-demo/demo/data/umac/初始配置/1586916338080.txt', 'file_name': '1586916338080.txt', 'file_type': 'text/plain', 'file_size': 1844, 'creation_date': '2024-05-20', 'last_modified_date': '2024-05-11'}, hash='111a685f474d839daac0ee9a7e7627c0907e5742d5e834063f47af3737e523f8'), <NodeRelationship.NEXT: '3'>: RelatedNodeInfo(node_id='0f51b5b0-2980-493b-8133-529b3857aa82', node_type=<ObjectType.TEXT: '1'>, metadata={}, hash='9ee970f83d08735c721dfeccdc25023195ce4b7415c421717ff2739fa6436202')}, text='配置与NRF对接数据\n\n摘要\n\n本节介绍如何配置AMF与NRF对接的信息。\n\n步骤\n\n  1. 执行SET NRFCLIENTCFG命令,配置NRF查询方式,启用SBI-GW功能。\n\n  2. 执行ADD SBINRFGROUP命令,配置NRF服务器分组。\n\n  3. 执行ADD SBINRFNODE命令,配置NRF服务器节点。\n\n  4. 执行ADD SBINRFPOLICY命令,配置NRF服务器策略。\n\n  5. 执行ADD SBINRFPROFILE命令,配置NRF服务器模板。\n\n  6. 执行ADD SBINRFPROFILESEL命令,配置NRF服务器模板选择。\n\n  7. 执行ADD SBIRESELECT命令,新建重选配置。\n\n  8. 支持ADD SBISUBCOND命令,新增订阅条件配置。\n\n\n\n\n举例\n\n在配置数据之前,应当完成相关数据规划,数据规划示例参见下表。\n\n配置项| 参数名称| 取值  \n---|---|---  \nNRF Client配置| 是否启用SBI-GW功能| 是  \nNRF服务器分组配置| NRF服务器组编号| 1、2  \nNRF服务器节点配置| NRF服务器节点编号| 1| 2| 3| 4  \nNRF服务器IP地址| 172.12.39.33| 170.12.39.44| 2408:8143:60FF:FA90:1:1:322:5| 2408:8143:60FF:FA90:1:1:322:8  \nNRF服务器端口| 80| 80| 80| 80  \nURI scheme| HTTP| HTTP| HTTP| HTTP  \nAPI版本| v1| v1| v1| v1  \nHTTP客户端模板编号| 1| 1| 2| 2  \n通知时使用的HTTP服务端模板编号| 1| 1| 2| 2  \nNRF服务器节点优先级| 2| 2| 1| 1  \n归属的NRF服务器组编号| 1| 2| 1| 2  \nNRF服务器策略配置| NRF服务器策略编号| 1  \nNRF模式| 互备双活模式  \n主用恢复后启用方式| 自动倒回  \n临时重定向次数| 2  \n主备不可用响应码| 420  \n主备间永久重定向响应码| 308  \n是否启用流控功能| 不启用  \n心跳间隔(秒)| 60  \n负载上报变化量阈值(%)| 5  \nNRF服务器模板配置| NRF服务器模板编号| 1  \nNRF服务器策略编号| 1  \n主用NRF服务器组编号| 1  \n备用NRF服务器组编号| 2  \n检测方法| HEARTBEAT  \n检测使用的NF实例标识| 00000000-0000-0000-0000-000000000000  \n异常不可用检测次数| 5  \n可用检测次数| 3  \n检测间隔(秒)| 5  \n服务信息格式类型配置| ARRAY  \nNRF服务器模板选择配置| NF类型| 全部  \nNRF服务器模板编号| 1  \n重选配置| 目的NF类型| NRF  \n链路重选次数| 0  \nIP重选次数| 0  \nNF重选次数| 1  \n重选等待时长(秒)| 5  \n订阅条件配置| ID| 1  \n目的NF类型| AMF  \n条件类型| AMF集  \n条件值| {"amfRegionId":"56","amfSetId":"02A"}  \n事件类型| "EVENT_REGISTERED"&"EVENT_DEREGISTERED"&"EVENT_CHANGED"  \n  \n根据规划,进行如下配置。\n\n  1. 设置NRF查询方式,命令如下。\n\nSET NRFCLIENTCFG:SUPPORTSBIGWFLAG="ISVALID"\n\n  2.', start_char_idx=0, end_char_idx=1547, text_template='[Excerpt from document]\n{metadata_str}\nExcerpt:\n-----\n{content}\n-----\n', metadata_template='{key}: {value}', metadata_seperator='\n'), score=0.7059760733890543)]
------
  0%|                                                                                                                                                        | 0/5 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/data1/wjm/projects/AIOPS/aiops24-RAG-demo/demo/main.py", line 88, in <module>
    asyncio.run(main())
  File "/usr/local/Miniconda3/envs/rag/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/Miniconda3/envs/rag/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/data1/wjm/projects/AIOPS/aiops24-RAG-demo/demo/main.py", line 78, in main
    result = await generation_with_knowledge_retrieval(
  File "/data1/wjm/projects/AIOPS/aiops24-RAG-demo/demo/pipeline/rag.py", line 82, in generation_with_knowledge_retrieval
    ret = await llm.acomplete(fmt_qa_prompt)
  File "/usr/local/Miniconda3/envs/rag/lib/python3.10/site-packages/llama_index/legacy/llms/openai_like.py", line 134, in acomplete
    return await super().acomplete(prompt, **kwargs)
  File "/usr/local/Miniconda3/envs/rag/lib/python3.10/site-packages/llama_index/legacy/llms/base.py", line 183, in wrapped_async_llm_predict
    f_return_val = await f(_self, *args, **kwargs)
  File "/usr/local/Miniconda3/envs/rag/lib/python3.10/site-packages/llama_index/legacy/llms/openai.py", line 519, in acomplete
    return await acomplete_fn(prompt, **kwargs)
  File "/usr/local/Miniconda3/envs/rag/lib/python3.10/site-packages/llama_index/legacy/llms/openai.py", line 618, in _acomplete
    response = await aclient.completions.create(
  File "/usr/local/Miniconda3/envs/rag/lib/python3.10/site-packages/openai/resources/completions.py", line 1036, in create
    return await self._post(
  File "/usr/local/Miniconda3/envs/rag/lib/python3.10/site-packages/openai/_base_client.py", line 1783, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
  File "/usr/local/Miniconda3/envs/rag/lib/python3.10/site-packages/openai/_base_client.py", line 1486, in request
    return await self._request(
  File "/usr/local/Miniconda3/envs/rag/lib/python3.10/site-packages/openai/_base_client.py", line 1577, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: Error code: 404 - {'timestamp': '2024-05-20T08:06:06.051+00:00', 'status': 404, 'error': 'Not Found', 'path': '/v4/completions'}

复现步骤

import asyncio

from dotenv import dotenv_values
from llama_index.core import Settings
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.legacy.llms import OpenAILike as OpenAI
from qdrant_client import models
from tqdm.asyncio import tqdm

from pipeline.ingestion import build_pipeline, build_vector_store, read_data
from pipeline.qa import read_jsonl, save_answers
from pipeline.rag import QdrantRetriever, generation_with_knowledge_retrieval

async def main():
    config = dotenv_values(".env")
    print("配置信息加载完成。")

    # 初始化 LLM 嵌入模型 和 Reranker
    llm = OpenAI(
        api_key=config["GLM_KEY"],
        model="glm-4",
        api_base="https://open.bigmodel.cn/api/paas/v4/", 
    )
    embeding = HuggingFaceEmbedding(
        model_name="BAAI/bge-small-zh-v1.5",
        cache_folder="./",
        embed_batch_size=1024,
    )
    Settings.embed_model = embeding

    print("模型和重排器初始化完成。")

    # 初始化 数据ingestion pipeline 和 vector store
    client, vector_store = await build_vector_store(config, reindex=False)
    print("向量存储和客户端初始化完成。")

    collection_info = await client.get_collection(
        config["COLLECTION_NAME"] or "aiops24"
    )
    
    if collection_info.points_count == 0:
        print("集合中没有数据,开始导入数据。")
        data = read_data("data")

        pipeline = build_pipeline(llm, embeding, vector_store=vector_store)
        print("build_pipeline")

        # 暂时停止实时索引
        await client.update_collection(
            collection_name=config["COLLECTION_NAME"] or "aiops24",
            optimizer_config=models.OptimizersConfigDiff(indexing_threshold=0),
        )
        print("update_collection")

        await pipeline.arun(documents=data, show_progress=True, num_workers=1)
        print("arun")

        # 恢复实时索引
        await client.update_collection(
            collection_name=config["COLLECTION_NAME"] or "aiops24",
            optimizer_config=models.OptimizersConfigDiff(indexing_threshold=20000),
        )

        print("数据导入完成,共导入 {} 条数据。".format(len(data)))
    else:
        print("集合中已有数据,跳过导入。")

    retriever = QdrantRetriever(vector_store, embeding, similarity_top_k=3)
    print("检索器初始化完成。")

    queries = read_jsonl("question-test.jsonl")
    print("读取查询文件完成,共读取 {} 个问题。".format(len(queries)))

    # 开始生成答案
    print("开始生成答案...")
    results = []
    for query in tqdm(queries, total=len(queries)):
        result = await generation_with_knowledge_retrieval(
            query["query"], retriever, llm, debug=True, progress=True
        )
        results.append(result)

    # 处理结果
    save_answers(queries, results, "submit_result.jsonl")
    print("答案生成完成,并已保存至 'submit_result.jsonl'。")

if __name__ == "__main__":
    asyncio.run(main())

预期行为

No response

代码分支

glm

运行环境

本地环境

其他信息

No response

@issaccv
Copy link
Owner

issaccv commented May 20, 2024

请重新拉取最新的glm分支,最新的提交中已经修复了这个问题

@issaccv issaccv closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants