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

feat(multi-agents):Add Summary Assistant Agent #1015

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

# How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

# Snapshots:

Include snapshots for easier review.

# 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
93 changes: 93 additions & 0 deletions dbgpt/agent/agents/expand/summary_assistant_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
from typing import Callable, Dict, Literal, Optional, Union

from dbgpt._private.config import Config
from dbgpt.agent.agents.base_agent import ConversableAgent
from dbgpt.agent.plugin.commands.command_mange import ApiCall

from ...memory.gpts_memory import GptsMemory
from ..agent import Agent, AgentContext


class SummaryAssistantAgent(ConversableAgent):
"""(In preview) Assistant agent, designed to solve a task with LLM.

AssistantAgent is a subclass of ConversableAgent configured with a default system message.
The default system message is designed to solve a task with LLM,
including suggesting python code blocks and debugging.
`human_input_mode` is default to "NEVER"
and `code_execution_config` is default to False.
This agent doesn't execute code by default, and expects the user to execute the code.
"""

DEFAULT_SYSTEM_MESSAGE = (
"""You are a great summary writter to summarize the provided text content according to user questions.
Please complete this task step by step following instructions below:
1. You need to first detect user's question that you need to answer with your summarization.
2. Output the extracted user's question with the format - The User's Question: user's question.
3. Then you need to summarize the historical messages
4. Output the summarization only related to user's question with the format - The Summarization: the summarization.
"""
)

DEFAULT_DESCRIBE = (
"""Summarize provided text content according to user's questions and output the summaraization."""
)

NAME = "Summarizer"

def __init__(
self,
memory: GptsMemory,
agent_context: AgentContext,
describe: Optional[str] = DEFAULT_DESCRIBE,
is_termination_msg: Optional[Callable[[Dict], bool]] = None,
max_consecutive_auto_reply: Optional[int] = None,
human_input_mode: Optional[str] = "NEVER",
**kwargs,
):
super().__init__(
name=self.NAME,
memory=memory,
describe=describe,
system_message=self.DEFAULT_SYSTEM_MESSAGE,
is_termination_msg=is_termination_msg,
max_consecutive_auto_reply=max_consecutive_auto_reply,
human_input_mode=human_input_mode,
agent_context=agent_context,
**kwargs,
)
self.register_reply(Agent, SummaryAssistantAgent.generate_summary_reply)
self.agent_context = agent_context

async def generate_summary_reply(
self,
message: Optional[str] = None,
sender: Optional[Agent] = None,
reviewer: Optional[Agent] = None,
config: Optional[Union[Dict, Literal[False]]] = None,
):
"""Generate a reply with summary."""

response_success = True
view = None
content = None
if message is None:
# Answer failed, turn on automatic repair
fail_reason += f"Nothing is summarized, please check your input."
response_success = False
else:
try:
vis_client = ApiCall()
content = "The generated summary is shown above."
view = content
except Exception as e:
fail_reason += f"Return summarization error,{str(e)}"
response_success = False

if not response_success:
content = fail_reason
return True, {
"is_exe_success": response_success,
"content": content,
"view": view,
}
4 changes: 2 additions & 2 deletions dbgpt/app/knowledge/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dbgpt.rag.chunk import Chunk
from dbgpt.rag.chunk_manager import ChunkParameters
from dbgpt.rag.embedding.embedding_factory import EmbeddingFactory
from dbgpt.rag.knowledge.base import KnowledgeType
from dbgpt.rag.knowledge.base import KnowledgeType, ChunkStrategy
from dbgpt.rag.knowledge.factory import KnowledgeFactory
from dbgpt.rag.text_splitter.text_splitter import (
RecursiveCharacterTextSplitter,
Expand Down Expand Up @@ -234,7 +234,7 @@ def batch_document_sync(
f" doc:{doc.doc_name} status is {doc.status}, can not sync"
)
chunk_parameters = sync_request.chunk_parameters
if "Automatic" == chunk_parameters.chunk_strategy:
if chunk_parameters.chunk_strategy != ChunkStrategy.CHUNK_BY_SIZE.name:
space_context = self.get_space_context(space_name)
chunk_parameters.chunk_size = (
CFG.KNOWLEDGE_CHUNK_SIZE
Expand Down
2 changes: 1 addition & 1 deletion dbgpt/app/static/404.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/404/index.html

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Loading
Loading