Skip to content

Commit

Permalink
fixed fontbug
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangWei-KUMO committed Apr 22, 2024
1 parent f188236 commit 2080446
Show file tree
Hide file tree
Showing 9 changed files with 6,082 additions and 2,007 deletions.
8 changes: 6 additions & 2 deletions next/src/services/agent/autonomous-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,14 @@ class AutonomousAgent {
executionMessage.info = "";
},
(text) => {
executionMessage.info = text.replace(/"/g, "");
this.messageService.updateMessage(executionMessage);
executionMessage.info += text;
if(executionMessage.info){
console.log("执行任务信息",executionMessage)
this.messageService.updateMessage(executionMessage);
}
},
(error) => {
console.log("执行任务错误",error)
this.messageService.sendErrorMessage(error);
this.shutdown();
},
Expand Down
28 changes: 10 additions & 18 deletions next/src/services/stream-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,18 @@ async function processStream(
onError: (error: unknown) => void,
shouldClose: () => boolean
): Promise<void> {
try {
onStart();
while (true) {
if (shouldClose()) {
await reader.cancel();
return;
}

let text = await readStream(reader);
if (text === null) break;
if(text[text.length-1]=='"'){
onText(eval(text));
}else{
onText(text);
}

onStart();
while (true) {
if (shouldClose()) {
await reader.cancel();
return;
}
} catch (error) {
onError(error);

const text = await readStream(reader);
if (text === null) break;
onText(text);
}

}

export const streamText = async (
Expand Down
4,206 changes: 2,229 additions & 1,977 deletions next/yarn.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion platform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

这个项目使用poetry作为现代化的依赖管理工具。要运行这个项目,请使用以下命令:
```bash
python3 -m pip install poetry==1.2.0
poetry install
poetry run python -m agent_backend
poetry run python3 -m agent_backend
```
这将在配置的主机上启动服务器。您可以在`/api/docs`处找到Swagger文档。
您可以在此处阅读有关poetry的更多信息:https://python-poetry.org/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async def analyze_task_agent(
)

try:
print("====",completion)
return pydantic_parser.parse(completion)
except Exception as error:
return Analysis.get_default_analysis()
Expand Down
8 changes: 5 additions & 3 deletions platform/agent_backend/web/api/agent/tools/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def _google_serper_search_results(
# 调用serper.dev的API
async with aiohttp.ClientSession() as session:
async with session.post(
f"https://google.serper.dev/{search_type}", headers=headers, params=params
f"https://google.serper.dev/{search_type}", headers=headers, params=params,ssl=False
) as response:
response.raise_for_status()
search_results = await response.json()
Expand Down Expand Up @@ -95,7 +95,9 @@ async def call(

if len(snippets) == 0:
return stream_string("Google搜索引擎中没有搜索到相关信息", True)

print("====",snippets)
# 生成摘要
return summarize(self.model_settings, goal, task, snippets)
res = summarize(self.model_settings, goal, task, snippets)
print(res)
return res

8 changes: 4 additions & 4 deletions platform/agent_backend/web/api/agent/tools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from agent_backend.web.api.agent.tools.reason import Reason
from agent_backend.web.api.agent.tools.search import Search
from agent_backend.web.api.agent.tools.tool import Tool

from agent_backend.web.api.agent.tools.wikipedia_search import Wikipedia

def get_user_tools(tool_names: List[str]) -> List[Type[Tool]]:
return list(map(get_tool_from_name, tool_names)) + get_default_tools()
Expand All @@ -22,10 +22,10 @@ def get_available_tools_names() -> List[str]:

def get_external_tools() -> List[Type[Tool]]:
return [
# Wikipedia, # TODO: Remove if async doesn't work
Image,
#Wikipedia, # TODO: Remove if async doesn't work
# Image,
Search,
Code,
#Code,
]


Expand Down
5 changes: 3 additions & 2 deletions platform/agent_backend/web/lifetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ def register_startup_event(

@app.on_event("startup")
async def _startup() -> None: # noqa: WPS430
_setup_db(app)
# _setup_db(app)
# await _create_tables()
# await init_kafka(app)

return _startup
# return _startup
return ""


def register_shutdown_event(
Expand Down
Loading

0 comments on commit 2080446

Please sign in to comment.