Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
* 批量返回结构体。
Expand Down Expand Up @@ -67,7 +68,25 @@ public static <T> RangedResultSet<T> create(List<T> results, Range range, long t
* @return RangedResultSet
*/
public static <T> RangedResultSet<T> create(List<T> results, RangeResult range) {
return new RangedResultSet(results, range);
return new RangedResultSet<>(results, range);
}

/**
* 集合是否为空.
*
* @return 返回集合是否是空的 {@code boolean}。
*/
public boolean isEmpty() {
return this.range.getTotal() == 0;
}

/**
* 获取第一个元素.
*
* @return {@link Optional}{@code <}{@code T}{@code >} Optional对象.
*/
public Optional<T> getFirst() {
return this.isEmpty() ? Optional.empty() : Optional.of(this.results.get(0));
}

public List<T> getResults() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ void patchMetaInstance(String versionId, String instanceId, InstanceDeclarationI
* 查询meta实例。
*
* @param versionId 表示实例所属meta唯一标识的 {@link String}。
* @param filter 表示meta实例过滤器的 {@link MetaInstanceFilter}。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
参数还再,不应该删除该参数注释

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

* @param offset 表示查询到的meta版本的结果集在全量结果集中的偏移量的 64 位整数
* @param limit 表示查询到的meta版本的结果集中的最大数量的 32 位整数
* @param filter 表示 meta 实例过滤器的 {@link MetaInstanceFilter}。
* @param offset 表示查询到的meta版本的结果集在全量结果集中的偏移量的 64 位整数的 {@code long}
* @param limit 表示查询到的meta版本的结果集中的最大数量的 32 位整数的 {@code int}
* @param context 表示操作上下文的 {@link OperationContext}。
* @return 表示查询到的结果集的 {@link RangedResultSet}{@code <}{@link Instance}{@code >}。
*/
Expand All @@ -90,8 +90,8 @@ RangedResultSet<Instance> list(String versionId, MetaInstanceFilter filter, long
* 查询meta实例。
*
* @param versionId 表示实例所属meta唯一标识的 {@link String}。
* @param offset 表示查询到的meta版本的结果集在全量结果集中的偏移量的 64 位整数
* @param limit 表示查询到的meta版本的结果集中的最大数量的 32 位整数
* @param offset 表示查询到的meta版本的结果集在全量结果集中的偏移量的 64 位整数的 {@code long}
* @param limit 表示查询到的meta版本的结果集中的最大数量的 32 位整数的 {@code int}
* @param context 表示操作上下文的 {@link OperationContext}。
* @return 表示查询到的结果集的 {@link RangedResultSet}{@code <}{@link Instance}{@code >}。
*/
Expand All @@ -102,7 +102,8 @@ RangedResultSet<Instance> list(String versionId, MetaInstanceFilter filter, long
* 查询meta实例。
*
* @param ids 表示实例id集合。
* @param limit 表示查询到的meta版本的结果集中的最大数量的 32 位整数。
* @param offset 表示查询到的meta版本的结果集在全量结果集中的偏移量的 64 位整数的 {@code long}。
* @param limit 表示查询到的meta版本的结果集中的最大数量的 32 位整数的 {@code int}。
* @param context 表示操作上下文的 {@link OperationContext}。
* @return 表示查询到的结果集的 {@link RangedResultSet}{@code <}{@link Instance}{@code >}。
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

package modelengine.fit.jober.aipp;

import modelengine.fit.jober.aipp.mapper.AppChatNumMapper;
import modelengine.fitframework.annotation.Component;
import modelengine.fitframework.plugin.Plugin;
import modelengine.fitframework.plugin.PluginStartedObserver;
import modelengine.fitframework.util.ObjectUtils;
import modelengine.fitframework.util.StringUtils;

/**
* 插件启动器
*
* @author 邬涨财
* @since 2025-06-04
*/
@Component
public class AippPluginStarter implements PluginStartedObserver {
@Override
public void onPluginStarted(Plugin plugin) {
if (!StringUtils.equals(plugin.metadata().name(), "aipp-plugin")) {
return;
}
plugin.container().all(AppChatNumMapper.class).stream().findAny().ifPresent(beanFactory -> {
AppChatNumMapper appChatNumMapper = ObjectUtils.cast(beanFactory.get());
appChatNumMapper.clearNum();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

package modelengine.fit.jober.aipp.aop;

import lombok.RequiredArgsConstructor;
import modelengine.fit.jober.aipp.service.DatabaseFieldLocaleService;
import modelengine.jade.authentication.context.UserContext;
import modelengine.jade.authentication.context.UserContextHolder;

import lombok.RequiredArgsConstructor;
import modelengine.fitframework.annotation.Component;
import modelengine.fitframework.aop.ProceedingJoinPoint;
import modelengine.fitframework.aop.annotation.Around;
Expand Down Expand Up @@ -36,11 +39,8 @@
@RequiredArgsConstructor
public class LocaleAspect {
private static final Logger log = Logger.get(LocaleAspect.class);

private static final String I18N_PATTERN = "i18n_appBuilder_\\{(.*?)\\}";

private static final Pattern PATTERN = Pattern.compile(I18N_PATTERN);

private static final List<Locale> LOCALES = Collections.unmodifiableList(
Arrays.asList(new Locale("en"), new Locale("zh"), new Locale("en", "US"), new Locale("zh", "CN")));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

package modelengine.fit.jober.aipp.common;

import modelengine.fit.jober.aipp.domains.business.RunContext;
import modelengine.fit.jober.aipp.entity.ChatSession;

/**
* 应用执行接口。
*
* @author 张越
* @since 2025-01-10
*/
public interface AppTaskRunnable {
/**
* 运行任务。
*
* @param context 上下文信息。
*/
void run(RunContext context);

/**
* 运行任务。
*
* @param context 上下文信息。
* @param chatSession 会话对象。
*/
void run(RunContext context, ChatSession<Object> chatSession);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

package modelengine.fit.jober.aipp.common.exception;

import lombok.Getter;
import modelengine.fit.jane.common.entity.OperationContext;

import lombok.Getter;

/**
* aipp通用受检异常
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

package modelengine.fit.jober.aipp.common.exception;

import lombok.Getter;
import modelengine.fit.jane.common.entity.OperationContext;

import lombok.Getter;

/**
* aipp通用受检异常
*
Expand All @@ -19,10 +20,9 @@
public class AippTaskNotFoundException extends AippCheckedException {
private OperationContext context;

private modelengine.fit.jober.aipp.common.exception.AippErrCode error;
private AippErrCode error;

public AippTaskNotFoundException(OperationContext context,
modelengine.fit.jober.aipp.common.exception.AippErrCode error) {
public AippTaskNotFoundException(OperationContext context, AippErrCode error) {
super(context, error);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,18 @@
public class AippQueryCondition {
@RequestQuery(name = "name", required = false)
private String name;

@RequestQuery(name = "status", required = false)
private String status;

@RequestQuery(name = "version", required = false)
private String version;

@RequestQuery(name = "creator", required = false)
private String creator;

@Property(description = "排序条件,支持字段:create_at/update_at", example = "create_at")
@Property(description = "排序条件,支持字段:create_at/update_at",
example = "create_at")
@RequestQuery(name = "sort", required = false, defaultValue = "update_at")
private String sort;

@Property(description = "排序方向,descend表示降序,ascend表示升序", example = "descend")
@Property(description = "排序方向,descend表示降序,ascend表示升序",
example = "descend")
@RequestQuery(name = "order", required = false, defaultValue = "descend")
private String order;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class AppQueryCondition {

@RequestParam(name = "type", required = false, defaultValue = "app")
private String type;

private List<String> ids;

@RequestParam(name = "name", required = false)
Expand All @@ -40,11 +39,14 @@ public class AppQueryCondition {

@RequestParam(name = "app_category", required = false)
private String appCategory;

private List<String> excludeNames;
private String appSuiteId;
private String orderBy;
private String sort;
private Long offset;
private Integer limit;

@RequestParam(name = "app_type", required = false)
private String appType;

private String createBy;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@
@AllArgsConstructor
public class FormQueryCondition {
private String tenantId;

private String type;

private Long offset;

private int limit;

private String name;

private String id;

private String createBy;

private List<String> excludeNames;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@
@AllArgsConstructor
public class InspirationQueryCondition {
private String aippId;

@RequestParam(name = "parent_id", required = false)
private String parentId;

private String categoryId;

private String createUser;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import modelengine.fitframework.validation.Validated;
import modelengine.jade.service.annotations.CarverSpan;
import modelengine.jade.service.annotations.SpanAttr;

/**
* 表示智能体信息获取接口集。
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@

package modelengine.fit.jober.aipp.controller;

import modelengine.fit.jane.task.gateway.Authenticator;
import modelengine.fit.jober.aipp.dto.chat.ChatInfoRspDto;
import modelengine.fit.jober.aipp.common.exception.AippTaskNotFoundException;
import modelengine.fit.jober.aipp.dto.chat.CreateChatRequest;
import modelengine.fit.jober.aipp.dto.chat.QueryChatInfoRequest;
import modelengine.fit.jober.aipp.dto.chat.QueryChatRequest;
import modelengine.fit.jober.aipp.dto.chat.QueryChatRsp;
import modelengine.fit.jober.aipp.dto.chat.QueryChatRspDto;
import modelengine.fit.jober.aipp.service.AippChatService;
import modelengine.fit.jober.common.RangedResultSet;
import modelengine.jade.service.annotations.CarverSpan;
import modelengine.jade.service.annotations.SpanAttr;

import modelengine.fit.http.annotation.DeleteMapping;
import modelengine.fit.http.annotation.PathVariable;
import modelengine.fit.http.annotation.PostMapping;
Expand All @@ -28,6 +15,7 @@
import modelengine.fit.http.server.HttpClassicServerRequest;
import modelengine.fit.jane.common.controller.AbstractController;
import modelengine.fit.jane.common.response.Rsp;
import modelengine.fit.jane.task.gateway.Authenticator;
import modelengine.fit.jober.aipp.common.exception.AippTaskNotFoundException;
import modelengine.fit.jober.aipp.dto.chat.ChatInfoRspDto;
import modelengine.fit.jober.aipp.dto.chat.CreateChatRequest;
Expand All @@ -39,6 +27,8 @@
import modelengine.fit.jober.common.RangedResultSet;
import modelengine.fitframework.annotation.Component;
import modelengine.fitframework.util.StringUtils;
import modelengine.jade.service.annotations.CarverSpan;
import modelengine.jade.service.annotations.SpanAttr;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -170,45 +160,4 @@ public Rsp<Void> deleteChatV2(HttpClassicServerRequest httpRequest, @PathVariabl
@RequestBody("chat_id") String chatIds) {
return this.deleteChat(httpRequest, tenantId, appId, chatIds);
}

/**
* deleteChat(用于mag网关)
*
* @param httpRequest httpRequest
* @param tenantId tenantId
* @param chatId 会话ID, 当传入多个id时,以“,”进行分割
* @param body 请求体
* @return Rsp<Void>
* @throws AippTaskNotFoundException 未查询到task异常
* @deprecated 废弃,下个版本删除
*/
@Deprecated
@CarverSpan(value = "operation.aippChat.update")
@PostMapping(path = "/{chat_id}", description = "更新会话接口")
public Rsp<QueryChatRsp> updateChat(HttpClassicServerRequest httpRequest,
@PathVariable("tenant_id") String tenantId, @PathVariable("chat_id") @SpanAttr("chat_id") String chatId,
@RequestBody CreateChatRequest body) throws AippTaskNotFoundException {
return Rsp.ok(this.aippChatService.updateChat(chatId, body, this.contextOf(httpRequest, tenantId)));
}

/**
* 重新发起会话。
*
* @param httpRequest Http 请求体。
* @param currentInstanceId 需要重新发起会话的实例 ID。
* @param tenantId 租户 ID。
* @param additionalContext 重新会话需要的信息,如是否使用多轮对话等等。
* @return 表示会话相应体的 {@link Rsp}{@code <}{@link QueryChatRsp}{@code >}。
* @deprecated 废弃,下个版本删除
*/
@Deprecated
@CarverSpan(value = "operation.aippChat.rechat")
@PostMapping(path = "/instances/{current_instance_id}", description = "重新发起会话接口")
public Rsp<QueryChatRsp> restartChat(HttpClassicServerRequest httpRequest,
@PathVariable("tenant_id") String tenantId,
@PathVariable("current_instance_id") @SpanAttr("current_instance_id") String currentInstanceId,
@RequestBody Map<String, Object> additionalContext) {
return Rsp.ok(this.aippChatService.restartChat(currentInstanceId, additionalContext,
this.contextOf(httpRequest, tenantId)));
}
}
Loading
Loading