mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-20 19:36:08 +00:00
feat: set cloud_service_url
This commit is contained in:
@@ -14,6 +14,11 @@ class SystemRouterGroup(group.RouterGroup):
|
|||||||
'version': constants.semantic_version,
|
'version': constants.semantic_version,
|
||||||
'debug': constants.debug_mode,
|
'debug': constants.debug_mode,
|
||||||
'enabled_platform_count': len(self.ap.platform_mgr.get_running_adapters()),
|
'enabled_platform_count': len(self.ap.platform_mgr.get_running_adapters()),
|
||||||
|
'cloud_service_url': (
|
||||||
|
self.ap.instance_config.data['plugin']['cloud_service_url']
|
||||||
|
if 'cloud_service_url' in self.ap.instance_config.data['plugin']
|
||||||
|
else 'https://space.langbot.app'
|
||||||
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -57,7 +62,11 @@ class SystemRouterGroup(group.RouterGroup):
|
|||||||
data=await self.ap.tool_mgr.execute_func_call(data['tool_name'], data['tool_parameters'])
|
data=await self.ap.tool_mgr.execute_func_call(data['tool_name'], data['tool_parameters'])
|
||||||
)
|
)
|
||||||
|
|
||||||
@self.route('/debug/plugin/action', methods=['POST'], auth_type=group.AuthType.USER_TOKEN)
|
@self.route(
|
||||||
|
'/debug/plugin/action',
|
||||||
|
methods=['POST'],
|
||||||
|
auth_type=group.AuthType.USER_TOKEN,
|
||||||
|
)
|
||||||
async def _() -> str:
|
async def _() -> str:
|
||||||
if not constants.debug_mode:
|
if not constants.debug_mode:
|
||||||
return self.http_status(403, 403, 'Forbidden')
|
return self.http_status(403, 403, 'Forbidden')
|
||||||
|
|||||||
@@ -20,3 +20,4 @@ system:
|
|||||||
secret: ''
|
secret: ''
|
||||||
plugin:
|
plugin:
|
||||||
runtime_ws_url: 'ws://plugin-runtime:5400/control/ws'
|
runtime_ws_url: 'ws://plugin-runtime:5400/control/ws'
|
||||||
|
cloud_service_url: 'https://space.langbot.app'
|
||||||
@@ -151,6 +151,7 @@ export interface PluginReorderElement {
|
|||||||
export interface ApiRespSystemInfo {
|
export interface ApiRespSystemInfo {
|
||||||
debug: boolean;
|
debug: boolean;
|
||||||
version: string;
|
version: string;
|
||||||
|
cloud_service_url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiRespAsyncTasks {
|
export interface ApiRespAsyncTasks {
|
||||||
|
|||||||
@@ -53,7 +53,11 @@ export interface RequestConfig extends AxiosRequestConfig {
|
|||||||
retry?: number; // 重试次数
|
retry?: number; // 重试次数
|
||||||
}
|
}
|
||||||
|
|
||||||
export let systemInfo: ApiRespSystemInfo | null = null;
|
export let systemInfo: ApiRespSystemInfo = {
|
||||||
|
debug: false,
|
||||||
|
version: '',
|
||||||
|
cloud_service_url: '',
|
||||||
|
};
|
||||||
|
|
||||||
class HttpClient {
|
class HttpClient {
|
||||||
private instance: AxiosInstance;
|
private instance: AxiosInstance;
|
||||||
@@ -74,7 +78,10 @@ class HttpClient {
|
|||||||
this.disableToken = disableToken || false;
|
this.disableToken = disableToken || false;
|
||||||
this.initInterceptors();
|
this.initInterceptors();
|
||||||
|
|
||||||
if (systemInfo === null && baseURL != 'https://space.langbot.app') {
|
if (
|
||||||
|
systemInfo.cloud_service_url === '' &&
|
||||||
|
baseURL != 'https://space.langbot.app'
|
||||||
|
) {
|
||||||
this.getSystemInfo().then((res) => {
|
this.getSystemInfo().then((res) => {
|
||||||
systemInfo = res;
|
systemInfo = res;
|
||||||
});
|
});
|
||||||
@@ -86,12 +93,6 @@ class HttpClient {
|
|||||||
return this.baseURL;
|
return this.baseURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取Session
|
|
||||||
private async getSession() {
|
|
||||||
// NOT IMPLEMENT
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// 同步获取Session
|
// 同步获取Session
|
||||||
private getSessionSync() {
|
private getSessionSync() {
|
||||||
// NOT IMPLEMENT
|
// NOT IMPLEMENT
|
||||||
@@ -505,4 +506,4 @@ const getBaseURL = (): string => {
|
|||||||
export const httpClient = new HttpClient(getBaseURL());
|
export const httpClient = new HttpClient(getBaseURL());
|
||||||
|
|
||||||
// 临时写法,未来两种Client都继承自HttpClient父类,不允许共享方法
|
// 临时写法,未来两种Client都继承自HttpClient父类,不允许共享方法
|
||||||
export const spaceClient = new HttpClient('https://space.langbot.app');
|
export const spaceClient = new HttpClient(systemInfo.cloud_service_url);
|
||||||
|
|||||||
Reference in New Issue
Block a user