netease-youdao / QAnything

Question and Answer based on Anything.
https://qanything.ai
GNU Affero General Public License v3.0
11.88k stars 1.15k forks source link

[BUG] 在提问时,默认传递给大语言模型的时间不是本地时区时间 #518

Open batumgl opened 2 months ago

batumgl commented 2 months ago

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

当前行为 | Current Behavior

在提问时,如果询问”现在几点啦“,大语言模型会回答时间,但经过测试,大语言模型回答的时间是UTC时间,而非服务器所在的CTS时间,时间数据是QAnything构造的提示词,看起来似乎是获取时间函数存在bug

微信截图_20240911184520 微信截图_20240911184551 服务器的时间设置是正常的

期望行为 | Expected Behavior

能够修复该bug,使得大语言模型回答的时间为当地时区的时间,比如Asia/Shanghai的CTS时间

运行环境 | Environment

- OS:Rocky 9
- NVIDIA Driver:545.23.06
- CUDA:12.3
- Docker Compose:1.27.4
- NVIDIA GPU Memory:48GB

QAnything日志 | QAnything logs

2024-09-11 10:37:32,160 - [PID: 1664][Sanic-Server-0-0] - [Function: rename_knowledge_base] - INFO - rename_knowledge_base zzp1234 2024-09-11 10:37:32,164 - [PID: 1664][Sanic-Server-0-0] - [Function: check_kb_exist] - INFO - check_kb_exist [('KBf7cbace6015b49679190238cff581727_240625_QUICK',)] 2024-09-11 10:37:32,171 - [PID: 1664][Sanic-Server-0-0] - [Function: get_time_async_inner] - INFO - 函数 rename_knowledge_base 执行耗时: 11.26 毫秒 2024-09-11 10:37:32,173 - [PID: 1664][Sanic-Server-0-0] - [Function: add_qalog] - INFO - add_qalog: 现在几点啦 2024-09-11 10:37:32,252 - [PID: 1664][Sanic-Server-0-0] - [Function: generate_answer] - INFO - response: Connection error. 2024-09-11 10:43:43,476 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - local_doc_chat zzp1234 2024-09-11 10:43:43,477 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - user_info 1234 2024-09-11 10:43:43,477 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - rerank False 2024-09-11 10:43:43,477 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - history: [] 2024-09-11 10:43:43,478 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - question: 现在几点啦 2024-09-11 10:43:43,478 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - kb_ids: ['KBf7cbace6015b49679190238cff581727_240625_QUICK'] 2024-09-11 10:43:43,478 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - user_id: zzp1234 2024-09-11 10:43:43,479 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - custom_prompt: None 2024-09-11 10:43:43,479 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - model: qwen2:54b 2024-09-11 10:43:43,479 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - max_token: 512 2024-09-11 10:43:43,479 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - request_source: unknown 2024-09-11 10:43:43,480 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - only_need_search_results: False 2024-09-11 10:43:43,480 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - bot_id: None 2024-09-11 10:43:43,480 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - need_web_search: False 2024-09-11 10:43:43,480 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - api_base: http://localhost:10004/v1 2024-09-11 10:43:43,481 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - api_key: ollama 2024-09-11 10:43:43,481 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - api_context_length: 2048 2024-09-11 10:43:43,481 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - top_p: 0.99 2024-09-11 10:43:43,481 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - top_k: 30 2024-09-11 10:43:43,481 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - temperature: 0.5 2024-09-11 10:43:43,482 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - hybrid_search: False 2024-09-11 10:43:43,482 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - web_chunk_size: 800 2024-09-11 10:43:43,486 - [PID: 1664][Sanic-Server-0-0] - [Function: check_kb_exist] - INFO - check_kb_exist [('KBf7cbace6015b49679190238cff581727_240625_QUICK',)] 2024-09-11 10:43:43,489 - [PID: 1664][Sanic-Server-0-0] - [Function: check_kb_exist] - INFO - check_kb_exist [] 2024-09-11 10:43:43,489 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - exist_faq_kb_ids: [] 2024-09-11 10:43:43,492 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - valid_files is empty, use only chat mode. 2024-09-11 10:43:43,492 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - streaming: True 2024-09-11 10:43:43,492 - [PID: 1664][Sanic-Server-0-0] - [Function: local_doc_chat] - INFO - start generate answer 2024-09-11 10:43:43,493 - [PID: 1664][Sanic-Server-0-0] - [Function: get_time_async_inner] - INFO - 函数 local_doc_chat 执行耗时: 16.69 毫秒 2024-09-11 10:43:43,493 - [PID: 1664][Sanic-Server-0-0] - [Function: generate_answer] - INFO - start generate... 2024-09-11 10:43:43,493 - [PID: 1664][Sanic-Server-0-0] - [Function: init] - WARNING - qwen2:54b not found in tiktoken, using cl100k_base! 2024-09-11 10:43:43,524 - [PID: 1664][Sanic-Server-0-0] - [Function: init] - INFO - OPENAI_API_KEY = ollama 2024-09-11 10:43:43,524 - [PID: 1664][Sanic-Server-0-0] - [Function: init] - INFO - OPENAI_API_BASE = http://localhost:10004/v1 2024-09-11 10:43:43,524 - [PID: 1664][Sanic-Server-0-0] - [Function: init] - INFO - OPENAI_API_MODEL_NAME = qwen2:54b 2024-09-11 10:43:43,524 - [PID: 1664][Sanic-Server-0-0] - [Function: init] - INFO - OPENAI_API_CONTEXT_LENGTH = 2048 2024-09-11 10:43:43,524 - [PID: 1664][Sanic-Server-0-0] - [Function: init] - INFO - OPENAI_API_MAX_TOKEN = 512 2024-09-11 10:43:43,524 - [PID: 1664][Sanic-Server-0-0] - [Function: init__] - INFO - TOP_P = 0.99 2024-09-11 10:43:43,524 - [PID: 1664][Sanic-Server-0-0] - [Function: init] - INFO - TEMPERATURE = 0.5 2024-09-11 10:43:43,524 - [PID: 1664][Sanic-Server-0-0] - [Function: reprocess_source_documents] - INFO - ============================================= 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: reprocess_source_documents] - INFO - token_window = 2048 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: reprocess_source_documents] - INFO - max_token = 512 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: reprocess_source_documents] - INFO - offcut_token = 50 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: reprocess_source_documents] - INFO - limited token nums: 1273.6000000000001 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: reprocess_source_documents] - INFO - template token nums: 178.79999999999998 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: reprocess_source_documents] - INFO - reference_field token nums: 0.0 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: reprocess_source_documents] - INFO - query token nums: 33.6 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: reprocess_source_documents] - INFO - history token nums: 0.0 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: reprocess_source_documents] - INFO - ============================================= 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: reprocess_source_documents] - INFO - new_source_docs token nums: 0.0 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: prepare_source_documents] - INFO - retrieval_documents len: 0 2024-09-11 10:43:43,525 - [PID: 1664][Sanic-Server-0-0] - [Function: prepare_source_documents] - ERROR - aggregate_documents error w/ 'file_id': Traceback (most recent call last): File "/workspace/QAnything/qanything_kernel/core/local_doc_qa.py", line 275, in prepare_source_documents new_docs = self.aggregate_documents(retrieval_documents, limited_token_nums, custom_llm) File "/workspace/QAnything/qanything_kernel/core/local_doc_qa.py", line 700, in aggregate_documents first_completed_doc, first_completed_doc_with_figure = self.get_completed_document(first_file_dict['file_id']) KeyError: 'file_id'

复现方法 | Steps To Reproduce

向QAnything提问 "现在几点啦"

备注 | Anything else?

No response