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

fix sql not found error for chat data #2152

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GITHUBear
Copy link
Contributor

@GITHUBear GITHUBear commented Nov 22, 2024

Description

Fixed the issue that the chat data function occasionally raises "Can not find sql in response" error when there is the answer in the context.
截屏2024-11-22 17 52 02

How Has This Been Tested?

  • Chat Data
  • make test

Snapshots:

Checklist:

  • My code follows the style guidelines of this project
  • I have already rebased the commits and make the commit message conform to the project standard.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules

@github-actions github-actions bot added the fix Bug fixes label Nov 22, 2024
Copy link
Collaborator

@Aries-ckt Aries-ckt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. r+

@priyamshah112
Copy link

Attempted your pull request changes and ran into following issues
image

Get prompt template of scene_name: chat_with_db_execute with model_name: vicuna-13b-v1.5, proxyllm_backend: None, language: en
--- Logging error ---
Traceback (most recent call last):
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/openapi/api_v1/api_v1.py", line 537, in chat_completions
    chat: BaseChat = await get_chat_instance(dialogue)
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/openapi/api_v1/api_v1.py", line 440, in get_chat_instance
    chat: BaseChat = await blocking_func_to_async(
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/util/executor_utils.py", line 67, in blocking_func_to_async
    return await loop.run_in_executor(executor, run_with_context)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/util/executor_utils.py", line 64, in run_with_context
    return ctx.run(partial(func, *args, **kwargs))
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/scene/chat_factory.py", line 36, in get_implementation
    implementation = cls(**kwargs)
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/scene/chat_db/auto_execute/chat.py", line 34, in __init__
    raise ValueError(
ValueError: <bound method ChatScene.value of <ChatScene.ChatWithDbExecute: <dbgpt.app.scene.base.Scene object at 0x7d3858dbd660>>> mode should chose db!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/logging/__init__.py", line 1100, in emit
    msg = self.format(record)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/logging/__init__.py", line 943, in format
    return fmt.format(record)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/logging/__init__.py", line 678, in format
    record.message = record.getMessage()
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/logging/__init__.py", line 368, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/dbgpt_server.py", line 289, in <module>
    run_webserver()
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/dbgpt_server.py", line 285, in run_webserver
    run_uvicorn(param)
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/dbgpt_server.py", line 245, in run_uvicorn
    uvicorn.run(
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/uvicorn/main.py", line 579, in run
    server.run()
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/middleware/base.py", line 149, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/routing.py", line 73, in app
    response = await f(request)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/fastapi/routing.py", line 301, in app
    raw_response = await run_endpoint_function(
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
    return await dependant.call(**values)
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/openapi/api_v1/api_v1.py", line 552, in chat_completions
    logger.exception(f"Chat Exception!{dialogue}", e)
Message: 'Chat Exception!conv_uid=\'0012343e-a909-11ef-bcc9-08bfb8168874\' user_input=\'What is the email address of the user named "Alice Smith"?\' user_name=\'001\' chat_mode=\'chat_with_db_execute\' app_code=\'chat_with_db_execute\' temperature=0.5 select_param=\'\' model_name=\'vicuna-13b-v1.5\' incremental=False sys_code=None ext_info={}'
Arguments: (ValueError('<bound method ChatScene.value of <ChatScene.ChatWithDbExecute: <dbgpt.app.scene.base.Scene object at 0x7d3858dbd660>>> mode should chose db!'),)
--- Logging error ---
Traceback (most recent call last):
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/openapi/api_v1/api_v1.py", line 537, in chat_completions
    chat: BaseChat = await get_chat_instance(dialogue)
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/openapi/api_v1/api_v1.py", line 440, in get_chat_instance
    chat: BaseChat = await blocking_func_to_async(
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/util/executor_utils.py", line 67, in blocking_func_to_async
    return await loop.run_in_executor(executor, run_with_context)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/util/executor_utils.py", line 64, in run_with_context
    return ctx.run(partial(func, *args, **kwargs))
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/scene/chat_factory.py", line 36, in get_implementation
    implementation = cls(**kwargs)
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/scene/chat_db/auto_execute/chat.py", line 34, in __init__
    raise ValueError(
ValueError: <bound method ChatScene.value of <ChatScene.ChatWithDbExecute: <dbgpt.app.scene.base.Scene object at 0x7d3858dbd660>>> mode should chose db!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/logging/__init__.py", line 1100, in emit
    msg = self.format(record)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/logging/__init__.py", line 943, in format
    return fmt.format(record)
  File "/home/priyamshah/.local/lib/python3.10/site-packages/coloredlogs/__init__.py", line 1140, in format
    return logging.Formatter.format(self, record)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/logging/__init__.py", line 678, in format
    record.message = record.getMessage()
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/logging/__init__.py", line 368, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/dbgpt_server.py", line 289, in <module>
    run_webserver()
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/dbgpt_server.py", line 285, in run_webserver
    run_uvicorn(param)
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/dbgpt_server.py", line 245, in run_uvicorn
    uvicorn.run(
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/uvicorn/main.py", line 579, in run
    server.run()
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/middleware/base.py", line 149, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/starlette/routing.py", line 73, in app
    response = await f(request)
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/fastapi/routing.py", line 301, in app
    raw_response = await run_endpoint_function(
  File "/home/priyamshah/anaconda3/envs/dbgpt_env1/lib/python3.10/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
    return await dependant.call(**values)
  File "/home/priyamshah/Desktop/DB-GPT/dbgpt/app/openapi/api_v1/api_v1.py", line 552, in chat_completions
    logger.exception(f"Chat Exception!{dialogue}", e)
Message: 'Chat Exception!conv_uid=\'0012343e-a909-11ef-bcc9-08bfb8168874\' user_input=\'What is the email address of the user named "Alice Smith"?\' user_name=\'001\' chat_mode=\'chat_with_db_execute\' app_code=\'chat_with_db_execute\' temperature=0.5 select_param=\'\' model_name=\'vicuna-13b-v1.5\' incremental=False sys_code=None ext_info={}'
Arguments: (ValueError('<bound method ChatScene.value of <ChatScene.ChatWithDbExecute: <dbgpt.app.scene.base.Scene object at 0x7d3858dbd660>>> mode should chose db!'),)
INFO:     127.0.0.1:57336 - "POST /api/v1/chat/completions HTTP/1.1" 200 OK```


@Aries-ckt
Copy link
Collaborator

@priyamshah112 ,

ValueError: <bound method ChatScene.value of <ChatScene.ChatWithDbExecute: <dbgpt.app.scene.base.Scene object at 0x7d3858dbd660>>> mode should chose db!

it looks like you haven't chose your db.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants