refactor(updateWorkflowList): replace Local Service call with IDE Service
Update the workflow list retrieval mechanism by replacing the direct local service invocation with a call to the IDE service. This change introduces a more structured approach to interacting with services and sets the foundation for future service communications within the application.
This commit is contained in:
parent
56e30328be
commit
2499ff5312
@ -56,8 +56,8 @@ export default function App() {
|
|||||||
compare_func(configs);
|
compare_func(configs);
|
||||||
// 假设setReady是一个函数,用于设置应用状态为准备就绪
|
// 假设setReady是一个函数,用于设置应用状态为准备就绪
|
||||||
setReady(true);
|
setReady(true);
|
||||||
// 调用 Local Service 更新工作流,更新、重载命令列表
|
// update workflow list
|
||||||
MessageUtil.sendMessage({ command: "updateWorkflowList"});
|
config.updateWorkflowList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import MessageUtil from "@/util/MessageUtil";
|
import MessageUtil from "@/util/MessageUtil";
|
||||||
|
import IDEServiceUtil from "@/util/IDEServiceUtil";
|
||||||
import { types, Instance, flow } from "mobx-state-tree";
|
import { types, Instance, flow } from "mobx-state-tree";
|
||||||
import modelsTemplate from "@/models";
|
import modelsTemplate from "@/models";
|
||||||
import cloneDeep from "lodash.clonedeep";
|
import cloneDeep from "lodash.clonedeep";
|
||||||
@ -26,6 +27,22 @@ function deepCopy(obj) {
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const doUpdateWorkflowList = async () => {
|
||||||
|
try {
|
||||||
|
// Get local service port
|
||||||
|
const port = await IDEServiceUtil.callService("get_local_service_port", {});
|
||||||
|
// Call local service to update Workflows
|
||||||
|
await axios.post(`http://localhost:${port}/workflows/update`, {});
|
||||||
|
await axios.post(`http://localhost:${port}/workflows/custom_update`, {});
|
||||||
|
// Update command list
|
||||||
|
MessageUtil.sendMessage({ command: "regCommandList" });
|
||||||
|
} catch (e) {
|
||||||
|
console.error("do update workflow and command list error:", e);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const fetchServerConfigUtil = async ({ modelsUrl, devchatApiKey }) => {
|
export const fetchServerConfigUtil = async ({ modelsUrl, devchatApiKey }) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`${modelsUrl}/models`, {
|
const response = await axios.get(`${modelsUrl}/models`, {
|
||||||
@ -295,6 +312,9 @@ export const ConfigStore = types
|
|||||||
MessageUtil.handleMessage({ command: "readServerConfig", value: undefined });
|
MessageUtil.handleMessage({ command: "readServerConfig", value: undefined });
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
updateWorkflowList: flow(function* (){
|
||||||
|
yield doUpdateWorkflowList();
|
||||||
|
}),
|
||||||
checkAndSetCompletionDefaults: (newConfig) => {
|
checkAndSetCompletionDefaults: (newConfig) => {
|
||||||
const codeModels = self.modelsTemplate.filter(model => model.category === "code");
|
const codeModels = self.modelsTemplate.filter(model => model.category === "code");
|
||||||
const isCustomAPIBase = self.modelsUrl.indexOf("api.devchat.ai") === -1 && self.modelsUrl.indexOf("api.devchat-ai.cn") === -1;
|
const isCustomAPIBase = self.modelsUrl.indexOf("api.devchat.ai") === -1 && self.modelsUrl.indexOf("api.devchat-ai.cn") === -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user