Skip to content

Commit

Permalink
Merge pull request DeepInsight-AI#145 from DeepInsight-AI/new_pre
Browse files Browse the repository at this point in the history
marge for v2.0.3
  • Loading branch information
lichengxin9527 authored Jun 21, 2024
2 parents 8f2bfd1 + 8cfb99c commit 547a790
Show file tree
Hide file tree
Showing 27 changed files with 1,357 additions and 265 deletions.
1 change: 1 addition & 0 deletions Install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ sec_key=$(openssl rand -hex 16)
env_content=$(echo "$env_content" | sed "s/SEC_KEY/$sec_key/g")
# save .env file
echo "$env_content" > .env
echo "DATA_SOURCE_FILE_DIR=/app/user_upload_files" >> .env
cp Dockerfile.template Dockerfile
# save env file over
echo "You setting as fellows:"
Expand Down
1 change: 1 addition & 0 deletions Install_CN.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ sec_key=$(openssl rand -hex 16)
env_content=$(echo "$env_content" | sed "s/SEC_KEY/$sec_key/g")
# save .env file,保存文件
echo "$env_content" > .env
echo "DATA_SOURCE_FILE_DIR=/app/user_upload_files" >> .env
# 修改配置 pip 为国内清华源
sed 's/#CN#//g' Dockerfile.template > Dockerfile
# 输出说明:
Expand Down
10 changes: 5 additions & 5 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ git clone http://github.com/DeepInsight-AI/DeepBI.git
<td>OpenAI</td>
<td>gpt-4o</td>
<td>支持</td>
<td>不稳定</td>
<td>支持</td>
<td>支持</td>
<td>支持</td>
<td>价格更便宜</td>
Expand All @@ -128,15 +128,15 @@ git clone http://github.com/DeepInsight-AI/DeepBI.git
<td>DeepInsight</td>
<td>gpt-4o</td>
<td>支持</td>
<td>不稳定</td>
<td>支持</td>
<td>支持</td>
<td>支持</td>
<td>目前只支持gpt-4o</td>
<td>128k/ 输入0.036元输出0.109元(约)</td>
</tr>
<tr>
<td>Microsoft Azure</td>
<td>gpt-4</td>
<td>gpt-4 (自定义的名称)</td>
<td>支持</td>
<td>支持</td>
<td>支持</td>
Expand All @@ -146,9 +146,9 @@ git clone http://github.com/DeepInsight-AI/DeepBI.git
</tr>
<tr>
<td>Microsoft Azure</td>
<td>gpt-4o</td>
<td>gpt-4o(自定义的名称)</td>
<td>支持</td>
<td>支持</td>
<td>不稳定</td>
<td>支持</td>
<td>支持</td>
<td>价格更便宜</td>
Expand Down
13 changes: 10 additions & 3 deletions ai/agents/agent_instance_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from ai.backend.util.write_log import logger
import traceback
from ai.backend.util.token_util import num_tokens_from_messages
from ai.agents.prompt import CSV_ECHART_TIPS_MESS, \
MYSQL_ECHART_TIPS_MESS, MYSQL_MATPLOTLIB_TIPS_MESS, POSTGRESQL_ECHART_TIPS_MESS, MONGODB_ECHART_TIPS_MESS
from ai.agents.prompt import EXCEL_ECHART_TIPS_MESS, \
MYSQL_ECHART_TIPS_MESS, MYSQL_MATPLOTLIB_TIPS_MESS, POSTGRESQL_ECHART_TIPS_MESS, MONGODB_ECHART_TIPS_MESS, CSV_ECHART_TIPS_MESS
from ai.agents.agentchat import (UserProxyAgent, GroupChat, AssistantAgent, GroupChatManager,
PythonProxyAgent, BIProxyAgent, TaskPlannerAgent, TaskSelectorAgent, CheckAgent,
ChartPresenterAgent)
Expand Down Expand Up @@ -202,8 +202,10 @@ def get_agent_mysql_engineer(self):
Hand over your code to the Executor for execution.
Don’t query too much data, Try to merge query data as simply as possible.
Be careful to avoid using mysql special keywords in mysql code.
If function call is needed, the function name mast be 'run_mysql_code', be sure contains no other characters.
Reply "TERMINATE" in the end when everything is done.
''',
function_map={"bi_run_chart_code": BIProxyAgent.run_chart_code},
websocket=self.websocket,
is_log_out=self.is_log_out,
user_name=self.user_name,
Expand Down Expand Up @@ -895,7 +897,7 @@ def get_agent_chart_planner(self):
)
return chart_planner

def get_agent_python_executor(self, report_file_name=None):
def get_agent_python_executor(self, report_file_name=None, is_auto_pilot=False):
python_executor = PythonProxyAgent(
name="python_executor",
system_message="python executor. Execute the python code and report the result.",
Expand All @@ -908,6 +910,7 @@ def get_agent_python_executor(self, report_file_name=None):
# incoming=self.incoming,
db_id=self.db_id,
report_file_name=report_file_name,
is_auto_pilot=is_auto_pilot
)
return python_executor

Expand All @@ -927,6 +930,10 @@ def get_agent_csv_echart_assistant(self, use_cache=True):
When you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.
Reply "TERMINATE" in the end when everything is done.
When you find an answer, You are a report analysis, you have the knowledge and skills to turn raw data into information and insight, which can be used to make business decisions.include your analysis in your reply.
It involves data queries that truncate the data if it exceeds 1000 rows, or reduce the number of rows by summing and other means.
It involves data queries that truncate the data if it exceeds 1000 rows, or reduce the number of rows by summing and other means.
It involves data queries that truncate the data if it exceeds 1000 rows, or reduce the number of rows by summing and other means.
It involves data queries that truncate the data if it exceeds 1000 rows, or reduce the number of rows by summing and other means.
""" + '\n' + self.base_csv_info + '\n' + python_base_dependency + '\n' + CSV_ECHART_TIPS_MESS,
human_input_mode="NEVER",
user_name=self.user_name,
Expand Down
6 changes: 3 additions & 3 deletions ai/agents/agentchat/bi_proxy_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ async def run_chart_code(self, chart_code_str: str):

for config in str_obj:
if 'columnMapping' in config and isinstance(config['columnMapping'], dict) and config[
'columnMapping']:
'columnMapping']:
for variable, axis in config['columnMapping'].items():
print('axis :', axis)
if axis in ["x"]:
Expand Down Expand Up @@ -1404,7 +1404,6 @@ async def tell_logger(self, log_str):
"from user:[{}".format(self.user_name) + "] , " + self.name + " send a message:{}".format(
send_json_str))


except Exception as e:
traceback.print_exc()
logger.error("from user:[{}".format(self.user_name) + "] , " + str(e))
Expand Down Expand Up @@ -1512,7 +1511,8 @@ async def run_echart_code(self, chart_code_str: str, name: str):
websocket = self.websocket

send_json_str = json.dumps(result_message)
await websocket.send(send_json_str)
if websocket and send_json_str:
await websocket.send(send_json_str)
print(str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) + ' ---- ' + " send a message:{}".format(
send_json_str))
logger.info(
Expand Down
2 changes: 1 addition & 1 deletion ai/agents/agentchat/groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async def run_chat(
sender: Optional[Agent] = None,
config: Optional[GroupChat] = None,
) -> Union[str, Dict, None]:
"""Run a group chat."""
"""Run a group chat. mysql_engineer, bi_proxy, chart_presenter"""
if messages is None:
messages = self._oai_messages[sender]
message = messages[-1]
Expand Down
Loading

0 comments on commit 547a790

Please sign in to comment.