:::success DB-GPT提供了一系列的工具来帮助开发者排除故障并解决可能遇到的一些问题。

:::

Trace日志

DB-GPT将一些关键的系统运行时信息写入跟踪日志中,默认情况下,他们位于logs/dbgpt*.jsonl中。

DB-GPT还提供了一个命令行工具dbgpt trace 来帮助分析这些跟踪日志。 可以通过如下命令查看具体的用法:

  1. dbgpt trace --help

查看聊天详情

可以通过dbgpt trace chat 命令查看聊天详情。默认会显示最新的对话信息。

查看服务运行时信息

  1. dbgpt trace chat --hide_conv

可以看到如下输出:

  1. +------------------------+--------------------------+-----------------------------+------------------------------------+
  2. | Config Key (Webserver) | Config Value (Webserver) | Config Key (EmbeddingModel) | Config Value (EmbeddingModel) |
  3. +------------------------+--------------------------+-----------------------------+------------------------------------+
  4. | host | 0.0.0.0 | model_name | text2vec |
  5. | port | 5000 | model_path | /app/models/text2vec-large-chinese |
  6. | daemon | False | device | cuda |
  7. | share | False | normalize_embeddings | None |
  8. | remote_embedding | False | | |
  9. | log_level | None | | |
  10. | light | False | | |
  11. +------------------------+--------------------------+-----------------------------+------------------------------------+
  12. +--------------------------+-----------------------------+----------------------------+------------------------------+
  13. | Config Key (ModelWorker) | Config Value (ModelWorker) | Config Key (WorkerManager) | Config Value (WorkerManager) |
  14. +--------------------------+-----------------------------+----------------------------+------------------------------+
  15. | model_name | vicuna-13b-v1.5 | model_name | vicuna-13b-v1.5 |
  16. | model_path | /app/models/vicuna-13b-v1.5 | model_path | /app/models/vicuna-13b-v1.5 |
  17. | device | cuda | worker_type | None |
  18. | model_type | huggingface | worker_class | None |
  19. | prompt_template | None | model_type | huggingface |
  20. | max_context_size | 4096 | host | 0.0.0.0 |
  21. | num_gpus | None | port | 5000 |
  22. | max_gpu_memory | None | daemon | False |
  23. | cpu_offloading | False | limit_model_concurrency | 5 |
  24. | load_8bit | False | standalone | True |
  25. | load_4bit | False | register | True |
  26. | quant_type | nf4 | worker_register_host | None |
  27. | use_double_quant | True | controller_addr | http://127.0.0.1:5000 |
  28. | compute_dtype | None | send_heartbeat | True |
  29. | trust_remote_code | True | heartbeat_interval | 20 |
  30. | verbose | False | log_level | None |
  31. +--------------------------+-----------------------------+----------------------------+------------------------------+

查看最新对话信息

  1. dbgpt trace chat --hide_run_params

输出如下

  1. +-------------------------------------------------------------------------------------------------------------------------------------------+
  2. | Chat Trace Details |
  3. +----------------+--------------------------------------------------------------------------------------------------------------------------+
  4. | Key | Value Value |
  5. +----------------+--------------------------------------------------------------------------------------------------------------------------+
  6. | trace_id | 5d1900c3-5aad-4159-9946-fbb600666530 |
  7. | span_id | 5d1900c3-5aad-4159-9946-fbb600666530:14772034-bed4-4b4e-b43f-fcf3a8aad6a7 |
  8. | conv_uid | 5e456272-68ac-11ee-9fba-0242ac150003 |
  9. | user_input | Who are you? |
  10. | chat_mode | chat_normal |
  11. | select_param | None |
  12. | model_name | vicuna-13b-v1.5 |
  13. | temperature | 0.6 |
  14. | max_new_tokens | 1024 |
  15. | echo | False |
  16. | llm_adapter | FastChatLLMModelAdaperWrapper(fastchat.model.model_adapter.VicunaAdapter) |
  17. | User prompt | A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polit |
  18. | | e answers to the user's questions. USER: Who are you? ASSISTANT: |
  19. | Model output | You can call me Vicuna, and I was trained by Large Model Systems Organization (LMSYS) researchers as a language model. |
  20. +----------------+--------------------------------------------------------------------------------------------------------------------------+

查看聊天详情和调用链

  1. dbgpt trace chat --hide_run_params --tree

可以看到如下输出

  1. Invoke Trace Tree:
  2. Operation: DB-GPT-Web-Entry (Start: 2023-10-12 03:06:43.180, End: None)
  3. Operation: get_chat_instance (Start: 2023-10-12 03:06:43.258, End: None)
  4. Operation: get_chat_instance (Start: 2023-10-12 03:06:43.258, End: 2023-10-12 03:06:43.424)
  5. Operation: stream_generator (Start: 2023-10-12 03:06:43.425, End: None)
  6. Operation: BaseChat.stream_call (Start: 2023-10-12 03:06:43.426, End: None)
  7. Operation: WorkerManager.generate_stream (Start: 2023-10-12 03:06:43.426, End: None)
  8. Operation: DefaultModelWorker.generate_stream (Start: 2023-10-12 03:06:43.428, End: None)
  9. Operation: DefaultModelWorker_call.generate_stream_func (Start: 2023-10-12 03:06:43.430, End: None)
  10. Operation: DefaultModelWorker_call.generate_stream_func (Start: 2023-10-12 03:06:43.430, End: 2023-10-12 03:06:48.518)
  11. Operation: DefaultModelWorker.generate_stream (Start: 2023-10-12 03:06:43.428, End: 2023-10-12 03:06:48.518)
  12. Operation: WorkerManager.generate_stream (Start: 2023-10-12 03:06:43.426, End: 2023-10-12 03:06:48.518)
  13. Operation: BaseChat.stream_call (Start: 2023-10-12 03:06:43.426, End: 2023-10-12 03:06:48.519)
  14. Operation: stream_generator (Start: 2023-10-12 03:06:43.425, End: 2023-10-12 03:06:48.519)
  15. Operation: DB-GPT-Web-Entry (Start: 2023-10-12 03:06:43.180, End: 2023-10-12 03:06:43.257)
  16. +-------------------------------------------------------------------------------------------------------------------------------------------+
  17. | Chat Trace Details |
  18. +----------------+--------------------------------------------------------------------------------------------------------------------------+
  19. | Key | Value Value |
  20. +----------------+--------------------------------------------------------------------------------------------------------------------------+
  21. | trace_id | 5d1900c3-5aad-4159-9946-fbb600666530 |
  22. | span_id | 5d1900c3-5aad-4159-9946-fbb600666530:14772034-bed4-4b4e-b43f-fcf3a8aad6a7 |
  23. | conv_uid | 5e456272-68ac-11ee-9fba-0242ac150003 |
  24. | user_input | Who are you? |
  25. | chat_mode | chat_normal |
  26. | select_param | None |
  27. | model_name | vicuna-13b-v1.5 |
  28. | temperature | 0.6 |
  29. | max_new_tokens | 1024 |
  30. | echo | False |
  31. | llm_adapter | FastChatLLMModelAdaperWrapper(fastchat.model.model_adapter.VicunaAdapter) |
  32. | User prompt | A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polit |
  33. | | e answers to the user's questions. USER: Who are you? ASSISTANT: |
  34. | Model output | You can call me Vicuna, and I was trained by Large Model Systems Organization (LMSYS) researchers as a language model. |
  35. +----------------+--------------------------------------------------------------------------------------------------------------------------+

根据trace_id查看聊天详情

  1. dbgpt trace chat --hide_run_params --trace_id ec30d733-7b35-4d61-b02e-2832fd2e29ff

输出如下

  1. +-------------------------------------------------------------------------------------------------------------------------------------------+
  2. | Chat Trace Details |
  3. +----------------+--------------------------------------------------------------------------------------------------------------------------+
  4. | Key | Value Value |
  5. +----------------+--------------------------------------------------------------------------------------------------------------------------+
  6. | trace_id | ec30d733-7b35-4d61-b02e-2832fd2e29ff |
  7. | span_id | ec30d733-7b35-4d61-b02e-2832fd2e29ff:0482a0c5-38b3-4b38-8101-e42489f90ccd |
  8. | conv_uid | 87a722de-68ae-11ee-9fba-0242ac150003 |
  9. | user_input | Hello |
  10. | chat_mode | chat_normal |
  11. | select_param | None |
  12. | model_name | vicuna-13b-v1.5 |
  13. | temperature | 0.6 |
  14. | max_new_tokens | 1024 |
  15. | echo | False |
  16. | llm_adapter | FastChatLLMModelAdaperWrapper(fastchat.model.model_adapter.VicunaAdapter) |
  17. | User prompt | A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polit |
  18. | | e answers to the user's questions. USER: Hello ASSISTANT: |
  19. | Model output | Hello! How can I help you today? Is there something specific you want to know or talk about? I'm here to answer any ques |
  20. | | tions you might have, to the best of my ability. |
  21. +----------------+--------------------------------------------------------------------------------------------------------------------------+

更多chat命令用法

  1. dbgpt trace chat --help
  1. Usage: dbgpt trace chat [OPTIONS] [FILES]...
  2. Show conversation details
  3. Options:
  4. --trace_id TEXT Specify the trace ID to analyze. If None,
  5. show latest conversation details
  6. --tree Display trace spans as a tree
  7. --hide_conv Hide your conversation details
  8. --hide_run_params Hide run params
  9. --output [text|html|csv|latex|json]
  10. The output format
  11. --help Show this message and exit.

根据trace_id查看调用树

  1. dbgpt trace tree --trace_id ec30d733-7b35-4d61-b02e-2832fd2e29ff

输出如下:

  1. Operation: DB-GPT-Web-Entry (Start: 2023-10-12 03:22:10.592, End: None)
  2. Operation: get_chat_instance (Start: 2023-10-12 03:22:10.594, End: None)
  3. Operation: get_chat_instance (Start: 2023-10-12 03:22:10.594, End: 2023-10-12 03:22:10.658)
  4. Operation: stream_generator (Start: 2023-10-12 03:22:10.659, End: None)
  5. Operation: BaseChat.stream_call (Start: 2023-10-12 03:22:10.659, End: None)
  6. Operation: WorkerManager.generate_stream (Start: 2023-10-12 03:22:10.660, End: None)
  7. Operation: DefaultModelWorker.generate_stream (Start: 2023-10-12 03:22:10.675, End: None)
  8. Operation: DefaultModelWorker_call.generate_stream_func (Start: 2023-10-12 03:22:10.676, End: None)
  9. Operation: DefaultModelWorker_call.generate_stream_func (Start: 2023-10-12 03:22:10.676, End: 2023-10-12 03:22:16.130)
  10. Operation: DefaultModelWorker.generate_stream (Start: 2023-10-12 03:22:10.675, End: 2023-10-12 03:22:16.130)
  11. Operation: WorkerManager.generate_stream (Start: 2023-10-12 03:22:10.660, End: 2023-10-12 03:22:16.130)
  12. Operation: BaseChat.stream_call (Start: 2023-10-12 03:22:10.659, End: 2023-10-12 03:22:16.130)
  13. Operation: stream_generator (Start: 2023-10-12 03:22:10.659, End: 2023-10-12 03:22:16.130)
  14. Operation: DB-GPT-Web-Entry (Start: 2023-10-12 03:22:10.592, End: 2023-10-12 03:22:10.673)

列出Trace信息

列出所有的Trace信息

  1. dbgpt trace list

输出如下

  1. +--------------------------------------+---------------------------------------------------------------------------+-----------------------------------+------------------+
  2. | Trace ID | Span ID | Operation Name | Conversation UID |
  3. +--------------------------------------+---------------------------------------------------------------------------+-----------------------------------+------------------+
  4. | eaf4830f-976f-45a4-9a50-244f3ab6f9e1 | eaf4830f-976f-45a4-9a50-244f3ab6f9e1:f650065f-f761-4790-99f7-8109c15f756a | run_webserver | None |
  5. | eaf4830f-976f-45a4-9a50-244f3ab6f9e1 | eaf4830f-976f-45a4-9a50-244f3ab6f9e1:b2ff279e-0557-4b2d-8959-85e25dcfe94e | EmbeddingLoader.load | None |
  6. | eaf4830f-976f-45a4-9a50-244f3ab6f9e1 | eaf4830f-976f-45a4-9a50-244f3ab6f9e1:b2ff279e-0557-4b2d-8959-85e25dcfe94e | EmbeddingLoader.load | None |
  7. | eaf4830f-976f-45a4-9a50-244f3ab6f9e1 | eaf4830f-976f-45a4-9a50-244f3ab6f9e1:3e8b1b9d-5ef2-4382-af62-6b2b21cc04fd | WorkerManager._start_local_worker | None |
  8. | eaf4830f-976f-45a4-9a50-244f3ab6f9e1 | eaf4830f-976f-45a4-9a50-244f3ab6f9e1:3e8b1b9d-5ef2-4382-af62-6b2b21cc04fd | WorkerManager._start_local_worker | None |
  9. | eaf4830f-976f-45a4-9a50-244f3ab6f9e1 | eaf4830f-976f-45a4-9a50-244f3ab6f9e1:4c280ec9-0fd6-4ee8-b79f-1afcab0f9901 | DefaultModelWorker.start | None |
  10. +--------------------------------------+---------------------------------------------------------------------------+-----------------------------------+------------------+

根据Trace类型查看trace信息

  1. dbgpt trace list --span_type chat
  2. +--------------------------------------+---------------------------------------------------------------------------+-------------------+--------------------------------------+
  3. | Trace ID | Span ID | Operation Name | Conversation UID |
  4. +--------------------------------------+---------------------------------------------------------------------------+-------------------+--------------------------------------+
  5. | 5d1900c3-5aad-4159-9946-fbb600666530 | 5d1900c3-5aad-4159-9946-fbb600666530:14772034-bed4-4b4e-b43f-fcf3a8aad6a7 | get_chat_instance | 5e456272-68ac-11ee-9fba-0242ac150003 |
  6. | 5d1900c3-5aad-4159-9946-fbb600666530 | 5d1900c3-5aad-4159-9946-fbb600666530:14772034-bed4-4b4e-b43f-fcf3a8aad6a7 | get_chat_instance | 5e456272-68ac-11ee-9fba-0242ac150003 |
  7. | ec30d733-7b35-4d61-b02e-2832fd2e29ff | ec30d733-7b35-4d61-b02e-2832fd2e29ff:0482a0c5-38b3-4b38-8101-e42489f90ccd | get_chat_instance | 87a722de-68ae-11ee-9fba-0242ac150003 |
  8. | ec30d733-7b35-4d61-b02e-2832fd2e29ff | ec30d733-7b35-4d61-b02e-2832fd2e29ff:0482a0c5-38b3-4b38-8101-e42489f90ccd | get_chat_instance | 87a722de-68ae-11ee-9fba-0242ac150003 |
  9. +--------------------------------------+---------------------------------------------------------------------------+-------------------+--------------------------------------+

搜索Trace信息

  1. dbgpt trace list --search Hello
  2. +--------------------------------------+---------------------------------------------------------------------------+----------------------------------------------+--------------------------------------+
  3. | Trace ID | Span ID | Operation Name | Conversation UID |
  4. +--------------------------------------+---------------------------------------------------------------------------+----------------------------------------------+--------------------------------------+
  5. | ec30d733-7b35-4d61-b02e-2832fd2e29ff | ec30d733-7b35-4d61-b02e-2832fd2e29ff:0482a0c5-38b3-4b38-8101-e42489f90ccd | get_chat_instance | 87a722de-68ae-11ee-9fba-0242ac150003 |
  6. | ec30d733-7b35-4d61-b02e-2832fd2e29ff | ec30d733-7b35-4d61-b02e-2832fd2e29ff:0482a0c5-38b3-4b38-8101-e42489f90ccd | get_chat_instance | 87a722de-68ae-11ee-9fba-0242ac150003 |
  7. | ec30d733-7b35-4d61-b02e-2832fd2e29ff | ec30d733-7b35-4d61-b02e-2832fd2e29ff:03de6c87-34d6-426a-85e8-7d46d475411e | BaseChat.stream_call | None |
  8. | ec30d733-7b35-4d61-b02e-2832fd2e29ff | ec30d733-7b35-4d61-b02e-2832fd2e29ff:03de6c87-34d6-426a-85e8-7d46d475411e | BaseChat.stream_call | None |
  9. | ec30d733-7b35-4d61-b02e-2832fd2e29ff | ec30d733-7b35-4d61-b02e-2832fd2e29ff:19593596-b4c7-4d15-a3c1-0924d86098dd | DefaultModelWorker_call.generate_stream_func | None |
  10. | ec30d733-7b35-4d61-b02e-2832fd2e29ff | ec30d733-7b35-4d61-b02e-2832fd2e29ff:19593596-b4c7-4d15-a3c1-0924d86098dd | DefaultModelWorker_call.generate_stream_func | None |
  11. +--------------------------------------+---------------------------------------------------------------------------+----------------------------------------------+--------------------------------------+

更多list相关命令用法

  1. dbgpt trace list --help
  2. Usage: dbgpt trace list [OPTIONS] [FILES]...
  3. List your trace spans
  4. Options:
  5. --trace_id TEXT Specify the trace ID to list
  6. --span_id TEXT Specify the Span ID to list.
  7. --span_type TEXT Specify the Span Type to list.
  8. --parent_span_id TEXT Specify the Parent Span ID to list.
  9. --search TEXT Search trace_id, span_id, parent_span_id,
  10. operation_name or content in metadata.
  11. -l, --limit INTEGER Limit the number of recent span displayed.
  12. --start_time TEXT Filter by start time. Format: "YYYY-MM-DD
  13. HH:MM:SS.mmm"
  14. --end_time TEXT Filter by end time. Format: "YYYY-MM-DD
  15. HH:MM:SS.mmm"
  16. --desc Whether to use reverse sorting. By default,
  17. sorting is based on start time.
  18. --output [text|html|csv|latex|json]
  19. The output format
  20. --help Show this message and exit.