Skip to content

Commit

Permalink
Merge pull request #94 from AI-Citizen/wuaustin/autogen-planner
Browse files Browse the repository at this point in the history
Improve AutoGen Analysis
  • Loading branch information
daviddai1998 authored Nov 2, 2023
2 parents b3e2ac5 + e156197 commit 3620dc9
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 71 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
# 🚀 What’s this
Chat everything with your code repository, ask repository-level code questions, and discuss your requirements. AI scans and learns from your code to seek coding advice, develop coding plans, and generate a product requirement documents using the information in the repository.

***SolidGPT <> AutoGen***
🚀 Introducing AutoGen Analysis! 🧠 Engage in issue focused chat sessions, to get the most detailed insights.

***Chat with Your Code Repository (Beta) Published***
Chat with everything with your code repository, ask repository-level code questions, and discuss your requirements.
<img width="1506" alt="Screen Shot 2023-10-18 at 11 10 47 PM" src="https://github.com/AI-Citizen/SolidGPT/assets/39673228/3164a280-755a-4f05-8848-ec61c570a420">


### 🔥🔥 [Click to try official host SolidGPT](https://calm-flower-017281610.3.azurestaticapps.net/)

If you like our work, please give us a 🌟 star. Your support serves as a great encouragement for us. Thank you! 😊
Expand Down
9 changes: 6 additions & 3 deletions StartServer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ if [[ "$(uname)" == "Darwin" ]]; then
# If not, start Redis service using Homebrew
brew services start redis
fi
if pgrep redis-server > /dev/null; then
brew services restart redis
fi
fi
if [[ !"$(uname)" == "Darwin" ]]; then
service redis-server start
fi


service redis-server start
celery -A solidgpt.src.api.celery_tasks worker --loglevel=info --detach
uvicorn solidgpt.src.api.api:app --proxy-headers --host 0.0.0.0 --port 8000
5 changes: 2 additions & 3 deletions solidgpt/src/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ async def autogen_analysis(body: dict = Body(...)):
openai_key, requirement, onboarding_id, graph_id])
task_id = result.id
autogen_task_map[task_id] = result

return JSONResponse(content={
"message": f"New autogen analysis graph...",
"task_id": task_id,
Expand All @@ -226,7 +225,7 @@ async def autogen_analysis(body: dict = Body(...)):
"status": 2,
"current_work_name": "autogen analysis"
}, status_code=200)
r.lpush(task_id, requirement)
redis_instance.lpush(task_id, requirement)
return JSONResponse(content={
"message": f"Continuing autogen analysis graph...",
"task_id": task_id,
Expand Down Expand Up @@ -265,7 +264,7 @@ async def get_autogen_status(body: dict = Body(...)):
}, status_code=200)
if celery_task_result.ready():
return JSONResponse(content={
"message": "status: Error, autogen task cannot be finished",
"message": "Status: Current session is over, chat to start a new session",
"task_id": task_id,
"status": 2,
"result": ""
Expand Down
5 changes: 2 additions & 3 deletions solidgpt/src/api/celery_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
CELERY_RESULT_BACKEND='redis://localhost:6379/1'
)
app.autodiscover_tasks(['solidgpt.src.api'])
r = redis.Redis()
redis_instance = redis.Redis()
Initializer()


Expand Down Expand Up @@ -126,9 +126,8 @@ def celery_task_autogen_analysis_graph(self, openai_key, requirement, onboarding
state='PROGRESS',
meta={'result': "", 'state_id': ""}
)

def autogen_message_input_callback():
data = r.blpop(self.request.id)
data = redis_instance.blpop(self.request.id)
if data:
# Extracting UUID and poem text from the tuple
task_id, poem_bytes = data
Expand Down
22 changes: 11 additions & 11 deletions solidgpt/src/manager/autogenmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ def __init__(self, if_show_reply=False):
self.assistant = None
self.user_proxy = None

def run(self, prompt):
self.construct_agents()
def run(self, requirement, relatived_code):
self.construct_agents(relatived_code)
self.user_proxy.initiate_chat(
self.assistant,
message=prompt,
message=requirement,
)

@staticmethod
Expand Down Expand Up @@ -215,10 +215,10 @@ def get_customized_user_proxy_agent(name: str,
default_auto_reply=default_auto_reply,
)

def construct_agents(self):
def construct_agents(self, relatived_code):
self.planner = self.generate_default_planner()
self.planner_user = self.generate_default_planner_user()
self.assistant = self.generate_default_assistant()
self.assistant = self.generate_default_assistant(relatived_code)
self.user_proxy = self.generate_default_user_proxy()
self.planner.manager = self
self.planner_user.manager = self
Expand All @@ -239,7 +239,7 @@ def retrieve_message(self):
def generate_default_planner(self):
# todo: update callback function
planner = SolidAssistantAgent(
name="planner",
name="Planner",
llm_config={"config_list": self.config_list},
# the default system message of the AssistantAgent is overwritten here
system_message=DEFAULT_SYSTEM_MESSAGE)
Expand All @@ -248,7 +248,7 @@ def generate_default_planner(self):
def generate_default_planner_user(self):
# todo: update callback function
planner_user = SolidUserProxyAgent(
name="planner_user",
name="Your_Proxy",
max_consecutive_auto_reply=0, # terminate without auto-reply
human_input_mode="NEVER",
)
Expand All @@ -260,11 +260,11 @@ def ask_planner(self, message):
# return the last message received from the planner
return self.planner_user.last_message()["content"]

def generate_default_assistant(self):
def generate_default_assistant(self, relatived_code: str):
# todo: update callback function
assistant = SolidAssistantAgent(
name="assistant",
system_message=ASSISTANT_SYSTEM_MESSAGE,
name="SolidGPT",
system_message=ASSISTANT_SYSTEM_MESSAGE + f"""Relatived code as follow: {relatived_code}""",
llm_config={
"temperature": 0,
"request_timeout": 600,
Expand Down Expand Up @@ -294,7 +294,7 @@ def generate_default_assistant(self):
def generate_default_user_proxy(self):
# todo: update callback function
user_proxy = SolidUserProxyAgent(
name="user_proxy",
name="Your_Proxy",
human_input_mode="ALWAYS",
max_consecutive_auto_reply=10,
is_termination_msg=lambda x: "content" in x and x["content"] is not None and x["content"].rstrip().endswith(
Expand Down
21 changes: 11 additions & 10 deletions solidgpt/src/workskill/skills/autogen_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,18 @@ def __get_input_content(self, skill_input: SkillInput):
return load_from_text(self.get_input_path(skill_input), extension=".txt")

def execution_impl(self):
self.autogen_manager.construct_agents()
prompt = self.__get_model_input()
self.autogen_manager.construct_agents(self.related_files_content)
# prompt = self.__get_model_input()
self.autogen_manager.user_proxy.callback_map["autogen_message_input_callback"] = self.graph.custom_data.get("autogen_message_input_callback")
self.autogen_manager.user_proxy.callback_map["autogen_update_result_callback"] = self.graph.custom_data.get("autogen_update_result_callback")
self.autogen_manager.run(prompt)
self.autogen_manager.run(self.requirements_content, self.related_files_content)
return

def __get_model_input(self):
return f'''Requirements: {self.requirements_content} \n
And the repository information as below
Project Instruction: {self.summary_content} \n
Code schema: {self.code_schema_content} \n
Related code files: {self.related_files_content} \n
and always input the Markdown clean format '''
# def __get_model_input(self):
# return f'''Requirements: {self.requirements_content} \n
# And the repository information as below
# Project Instruction: {self.summary_content} \n
# Code schema: {self.code_schema_content} \n
# Related code files: {self.related_files_content} \n
# and always input the Markdown clean format '''

25 changes: 6 additions & 19 deletions solidportal/panel/src/components/UserInputView.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const UserInputView = ({ showView,
setGetAutoGenStatusCall,
setSaveSetAutoGenTaskId,
getAutoGenTaskId,
setIsFinal,
setSaveOpenAIKey,
setSaveUserRequirement,
setSaveProductInfo,
Expand Down Expand Up @@ -99,7 +98,6 @@ const UserInputView = ({ showView,
}
}, [uploadStatus, pollingInterval]);


const handleGraphTypeSelectChange = (e) => {
setSelectedGraphType(e.target.value);
setSaveSelectedGraphType(e.target.value);
Expand Down Expand Up @@ -271,11 +269,11 @@ const UserInputView = ({ showView,
setCurrentRunningSubgraphName("Chat with your repository")
}
}else if(selectedGraphType === GraphType.AutoGenAnalysis){
if (await AutoGenAnalysis()){
if (await AutoGenAnalysis(userRequirement)){
setTotalSubgraph([
"Chat with Engineer Agent(Online Live data)",
"AutoGen Analysis(Beta)",
])
setCurrentRunningSubgraphName("Chat with Engineer Agent(Online Live data)")
setCurrentRunningSubgraphName("AutoGen Analysis(Beta)")
}
}
}
Expand Down Expand Up @@ -365,12 +363,12 @@ const UserInputView = ({ showView,
}
}

const AutoGenAnalysis = async () => {
const AutoGenAnalysis = async ( requirement ) => {
disableStart.current = true
const requestBody = JSON.stringify({
openai_key: openAIKey,
onboarding_id: localStorage.getItem(config.GraphId),
requirement: userRequirement,
requirement: requirement,
task_id: getAutoGenTaskId,
is_new_session: isAutoGenNewSession
})
Expand Down Expand Up @@ -398,6 +396,7 @@ const UserInputView = ({ showView,
}
} catch (error) {
setSaveMdEditorValue(error.message)
setIsAutoGenNewSession(true)
console.error('Error:', error);
window.alert(error);
return false
Expand Down Expand Up @@ -484,18 +483,6 @@ const UserInputView = ({ showView,
allowClear placeholder="Please input your product information"/>
</div>
</div>}
{/* <div>
<div><TextArea className={styles.notionpageid} bordered={false}
value={notionID}
onChange={handleNotionIDInputChange}
autoSize={{minRows: 2, maxRows: 2}} placeholder="Notion Page ID:"/></div>
</div>
<div>
<div><TextArea className={styles.notionkey} bordered={false}
value={notionKey}
onChange={handleNotionKeyInputChange} autoSize={{minRows: 2, maxRows: 2}}
placeholder="Notion API Key:"/></div>
</div>*/}
<div>
<Button className={styles.startbutton}
onClick={startClicked}
Expand Down
8 changes: 8 additions & 0 deletions solidportal/panel/src/config/autoGenActivePlannerState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const AutoGenActivePlannerState = {
Disable : 0,
RequestPlanner : 2,
Confirm: 3,
Active: 4
}

export default AutoGenActivePlannerState
2 changes: 1 addition & 1 deletion solidportal/panel/src/config/graphType.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const GraphType = {
GeneratePRD: "Generate Product Requirement Document",
TechSolution: "Get Technical Solution",
RepoChat: "Chat with Your Code Repo(Beta)",
AutoGenAnalysis: "Chat with Engineer Agent(Online Live data)"
AutoGenAnalysis: "AutoGen Analysis(Beta)"
}

export default GraphType
14 changes: 12 additions & 2 deletions solidportal/panel/src/config/stringConstant.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,23 @@ export const stringConstant = {
"\n" +
"- After this, choose Generate PRD or Get Tech Solution for customized solutions based on the onboarded project.\n" +
"\n" +
"## 📖 Onborading your project\n" +
"\n" +
"## ❗️❗️ Onborading your project(Required)\n" +
"1. Choose `Onboard Project` from the top left dropdown.\n" +
"1. Enter your OpenAI API key.\n" +
"1. Upload your project folder.\n" +
"1. ❗️Note: After completing the Onboard Project, an Onboard ID will be generated. If you remain in the same browser session, it will be automatically applied to subsequent actions. Alternatively, you can save it and manually input it in the future to bypass onboarding.\n" +
"\n" +
"\n" +
"## 🤖️ Chat with Your Code Repo\n" +
"1. Choose `Chat with Your Repo(Beta)` from the top left dropdown.\n" +
"1. Enter your OpenAI API key.\n" +
"1. Input your problem/Requirement and start any topic with your codebase \n" +
"\n" +
"## 🧠 AutoGen Analysis\n" +
"1. Choose `AutoGen Analysis(Beta)` from the top left dropdown.\n" +
"1. Enter your OpenAI API key.\n" +
"1. Input your problem/Requirement and start the issue focused chat sessions\n" +
"\n" +
"## 🧮 Get Technical Solution\n" +
"1. Choose `Get Tech Solution` from the top left dropdown.\n" +
"1. Enter your OpenAI API key.\n" +
Expand Down
Loading

0 comments on commit 3620dc9

Please sign in to comment.