Skip to content

Commit

Permalink
fix: typo, specify the function return type. (#87)
Browse files Browse the repository at this point in the history
* fix: typo

* fix: vercel build

* chore: stylelint
  • Loading branch information
BroKun committed Nov 26, 2024
1 parent 0dba9ae commit ea15fc2
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
12 changes: 7 additions & 5 deletions docs/site/.dumi/theme/styles/heti.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

@font-face {
font-family: 'Heti Hei SC';
src: local('PingFang SC Regular'), local('Heiti SC Regular'), local('Microsoft YaHei'),
local('Source Han Sans CN Regular'), local('Noto Sans CJK SC Regular'),
local('WenQuanYi Micro Hei'), local('Droid Sans Fallback');
src: local('PingFang SC Regular'), local('Heiti SC Regular'),
local('Microsoft YaHei'), local('Source Han Sans CN Regular'),
local('Noto Sans CJK SC Regular'), local('WenQuanYi Micro Hei'),
local('Droid Sans Fallback');
}

@font-face {
Expand Down Expand Up @@ -45,8 +46,9 @@
@font-face {
font-family: 'Heti Hei SC Light';
font-weight: 200;
src: local('PingFang SC Light'), local('Heiti SC Light'), 'Heti Hei SC Light Fallback',
local('Source Han Sans CN Light'), local('Noto Sans CJK SC Light');
src: local('PingFang SC Light'), local('Heiti SC Light'),
'Heti Hei SC Light Fallback', local('Source Han Sans CN Light'),
local('Noto Sans CJK SC Light');
}

@font-face {
Expand Down
3 changes: 2 additions & 1 deletion docs/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "MIT",
"description": "Document site for magent",
"scripts": {
"start": "UMI_DEV_SERVER_COMPRESS=none dumi dev"
"start": "UMI_DEV_SERVER_COMPRESS=none dumi dev",
"build": "dumi build"
},
"type": "module",
"devDependencies": {
Expand Down
6 changes: 4 additions & 2 deletions web-apps/ui/src/views/agent-flow/agent-flow-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ViewInstance,
} from '@difizen/mana-app';
import { Button } from 'antd';
// import yaml from 'js-yaml';
import type { AxiosResponse } from 'axios';
import { forwardRef, useEffect, useState } from 'react';

import { AgentManager } from '@/modules/agent/agent-manager.js';
Expand Down Expand Up @@ -335,7 +335,9 @@ export class AgentFlowView extends BaseView {
return await this.getWorkflowInfo(workflowId);
};

saveGraph = async (graph: Graph) => {
saveGraph = async (
graph: Graph,
): Promise<AxiosResponse<WorkflowMeta, any> | undefined> => {
await this.agent.ready;
if (!this.workflowId || !this.workflow) {
return;
Expand Down
13 changes: 10 additions & 3 deletions web-packages/magent-au/src/agent/agent-manager.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { FecterResponse } from '@difizen/magent-core';
import { Fetcher } from '@difizen/magent-core';
import { inject, singleton } from '@difizen/mana-app';

Expand Down Expand Up @@ -33,7 +34,9 @@ export class AgentManager {
return agent;
};

create = async (option: AgentModelCreateOption) => {
create = async (
option: AgentModelCreateOption,
): Promise<FecterResponse<AgentModelOption[], any>> => {
let res;
if (option.planner.id === 'workflow_planner') {
res = await this.doCreateWorkflowAgent(option);
Expand All @@ -43,10 +46,14 @@ export class AgentManager {
return res;
};

protected doCreateNormalAgent = async (option: AgentModelCreateOption) => {
protected doCreateNormalAgent = async (
option: AgentModelCreateOption,
): Promise<FecterResponse<AgentModelOption[], any>> => {
return await this.fetcher.post<AgentModelOption[]>(`/api/v1/agents`, option);
};
protected doCreateWorkflowAgent = async (option: AgentModelCreateOption) => {
protected doCreateWorkflowAgent = async (
option: AgentModelCreateOption,
): Promise<FecterResponse<AgentModelOption[], any>> => {
return await this.fetcher.post<AgentModelOption[]>(
`/api/v1/agents/workflow`,
option,
Expand Down
3 changes: 2 additions & 1 deletion web-packages/magent-au/src/plugin/plugin-manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Fetcher } from '@difizen/magent-core';
import type { FecterResponse } from '@difizen/magent-core';
import { inject, prop, singleton } from '@difizen/mana-app';

import type { PluginModel } from './plugin-model.js';
Expand Down Expand Up @@ -44,7 +45,7 @@ export class PluginManager {
return plugin;
};

create = async (option: PluginMeta) => {
create = async (option: PluginMeta): Promise<FecterResponse<string>> => {
const res = await this.fetcher.post<string>(`/api/v1/plugins/openapi`, option);
return res;
};
Expand Down
23 changes: 18 additions & 5 deletions web-packages/magent-core/src/fetcher/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
import { inject, singleton } from '@difizen/mana-app';
import type { AxiosRequestConfig } from 'axios';
import type { AxiosRequestConfig, AxiosResponse } from 'axios';
import qs from 'query-string';

import { AxiosClient } from './protocol.js';

export type FecterResponse<T = any, D = any> = AxiosResponse<T, D>;

@singleton()
export class Fetcher {
@inject(AxiosClient) axios: AxiosClient;
get = <T>(
basePath: string,
params?: Record<string, any>,
config?: AxiosRequestConfig<any>,
) => {
): Promise<FecterResponse<T, any>> => {
let url = basePath;
if (params) {
url = `${url}?${qs.stringify(params)}`;
}
return this.axios.get<T>(url, config);
};

post = async <T>(url: string, data: any, config?: AxiosRequestConfig<any>) => {
post = async <T>(
url: string,
data: any,
config?: AxiosRequestConfig<any>,
): Promise<FecterResponse<T, any>> => {
return this.axios.post<T>(url, data, config);
};

put = async <T>(url: string, data: any, config?: AxiosRequestConfig<any>) => {
put = async <T>(
url: string,
data: any,
config?: AxiosRequestConfig<any>,
): Promise<FecterResponse<T, any>> => {
return this.axios.put<T>(url, data, config);
};
delete = async <T>(url: string, config?: AxiosRequestConfig<any>) => {
delete = async <T>(
url: string,
config?: AxiosRequestConfig<any>,
): Promise<FecterResponse<T, any>> => {
return this.axios.delete<T>(url, config);
};
}

0 comments on commit ea15fc2

Please sign in to comment.