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

[Bug] [agent] The LLM response content from the agent is missing. #2297

Open
2 of 15 tasks
FOkvj opened this issue Jan 10, 2025 · 0 comments
Open
2 of 15 tasks

[Bug] [agent] The LLM response content from the agent is missing. #2297

FOkvj opened this issue Jan 10, 2025 · 0 comments
Labels
bug Something isn't working Waiting for reply

Comments

@FOkvj
Copy link
Contributor

FOkvj commented Jan 10, 2025

Search before asking

  • I had searched in the issues and found no similar issues.

Operating system information

Linux

Python version information

=3.11

DB-GPT version

main

Related scenes

  • Chat Data
  • Chat Excel
  • Chat DB
  • Chat Knowledge
  • Model Management
  • Dashboard
  • Plugins

Installation Information

Device information

Models information

deepseek v3

What happened

What you expected to happen

In the agent module, when processing the LLM's response, if the response contains the ### symbol, the content before ### will be truncated.

How to reproduce

  1. execute the coede below
import asyncio

from dbgpt.agent import AgentContext, AgentMemory, LLMConfig, UserProxyAgent, ProfileConfig, ConversableAgent, \
   BlankAction
from dbgpt.model.proxy import SiliconFlowLLMClient


async def main():

   llm_client = SiliconFlowLLMClient(
       model_alias=os.getenv(
           "SILICONFLOW_MODEL_VERSION", "Qwen/Qwen2.5-Coder-32B-Instruct"
       ),
   )
   context: AgentContext = AgentContext(conv_id="test456")

   agent_memory = AgentMemory()
   agent_memory.gpts_memory.init(conv_id="test456")

   user_proxy = await UserProxyAgent().bind(agent_memory).bind(context).build()

   # 代码优化助手
   code_optimizer_profile = ProfileConfig(
       name="Jack",
       role="CodeOptimizer",
       goal="优化用户给的代码。",
       desc="专门对用户代码进行优化",
       constraints=["要给出代码优化前后的对比,用markdown格式展示代码"],
   )
   code_optimizer = (
       await ConversableAgent(profile=code_optimizer_profile)
       .bind(context)
       .bind(LLMConfig(llm_client=llm_client))
       .bind(agent_memory)
       .bind(BlankAction)
       .build()
   )

   await user_proxy.initiate_chat(
       recipient=code_optimizer,
       reviewer=user_proxy,
       message="select * from table 帮我优化代码,解释部分和代码用###分割",
   )

   ## dbgpt-vis message infos
   print(await agent_memory.gpts_memory.app_link_chat_message("test456"))


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

model original output

### Explanation
The SQL query `SELECT * FROM table` retrieves all columns from the specified table. While this is a simple and straightforward query, it can be optimized in several ways depending on the context:

1. **Specific Columns**: Instead of selecting all columns (`*`), specify only the columns you need. This reduces the amount of data transferred and processed, which can improve performance, especially for large tables.

2. **Index Usage**: Ensure that the columns you are querying are indexed, especially if you are filtering or sorting the data. This can significantly speed up the query.

3. **Limit Clause**: If you only need a subset of the data, consider using a `LIMIT` clause to restrict the number of rows returned.

4. **Avoiding SELECT ***: Using `SELECT *` can lead to issues if the table schema changes (e.g., columns are added or removed). Explicitly listing the columns you need makes your query more robust.

### Optimized Code
Here’s an optimized version of the query, assuming you only need specific columns and a limited number of rows:

```sql
-- Original Query
SELECT * FROM table;

-- Optimized Query
SELECT column1, column2, column3 
FROM table
LIMIT 100;
```

### Explanation of Optimized Code
- **Specific Columns**: The optimized query selects only `column1`, `column2`, and `column3` instead of all columns. This reduces the amount of data processed and transferred.
- **LIMIT Clause**: The `LIMIT 100` clause restricts the result set to 100 rows, which can be useful if you only need a sample of the data or are working with a large dataset.

This optimized query is more efficient and safer to use in production environments.

processed output

 Explanation of Optimized Code
- **Specific Columns**: The optimized query selects only `column1`, `column2`, and `column3` instead of all columns. This reduces the amount of data processed and transferred.
- **LIMIT Clause**: The `LIMIT 100` clause restricts the result set to 100 rows, which can be useful if you only need a sample of the data or are working with a large dataset.

This optimized query is more efficient and safer to use in production environments.

Additional context

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Waiting for reply
Projects
None yet
Development

No branches or pull requests

1 participant