Skip to content

Commit

Permalink
将nop-gpt重命名为nop-ai。初步的消息设计参考agents flex项目。
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Oct 18, 2024
1 parent 0e6aec5 commit 67dff01
Show file tree
Hide file tree
Showing 53 changed files with 1,329 additions and 118 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ Engine)、任务调度引擎(Job Scheduler)、批处理引擎(Batch Prcessin
| nop-stream | 简化的流处理,可以集成Flink | 0% |
| nop-netty | TCP/IP服务处理框架 | 0% |
| nop-datav | BI数据分析 | 0% |
| nop-gpt | 与AI大模型集成,实现AIGC | 2% |
| nop-ai | 与AI大模型集成,实现AIGC | 2% |
| nop-js | GraalVM Js引擎封装,在Java中运行JS | 50% |
| nop-integration | 邮件、短信、文件服务等外部服务封装 | 30% |
| nop-auth | 用户权限管理 | 已完成 |
| nop-sys | 系统配置管理 | 已完成 |
| nop-ofbiz | 将Ofbiz的模型文件转换为Nop平台的模型定义 | 0% |
| nop-ofbiz | 将Ofbiz的模型文件转换为Nop平台的模型定义 | 0% |

## 源码地址

Expand Down
12 changes: 12 additions & 0 deletions docs/dev-guide/auth/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,18 @@ if (auth.getPermissions() != null && !auth.getPermissions().isEmpty()) {
全部可用的变量在[biz-var.dict.yaml](https://gitee.com/canonical-entropy/nop-entropy/blob/master/nop-xlang/src/main/resources/_vfs/dict/core/biz-var.dict.yaml)
中定义。

一般情况下`/nop/main/auth/app.data-auth.xml`文件中可以配置动态搜集所有模块下的data-auth配置

```xml
<data-auth x:schema="/nop/schema/data-auth.xdef" xmlns:x="/nop/schema/xdsl.xdef"
xmlns:auth-gen="auth-gen" xmlns:xpl="xpl">
<x:gen-extends>
<!-- 自动收集各个模块下定义的数据权限 -->
<auth-gen:GenFromModules xpl:lib="/nop/auth/xlib/auth-gen.xlib"/>
</x:gen-extends>
</data-auth>
```

### 通过NopAuthRoleDataAuth表来定义数据权限

数据库中定义的数据权限会和`data-auth.xml`配置文件中定义的权限合并。
Expand Down
4 changes: 2 additions & 2 deletions nop-gpt/nop-gpt-core/pom.xml → nop-ai/nop-ai-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.entropy-cloud</groupId>
<artifactId>nop-gpt</artifactId>
<artifactId>nop-ai</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>nop-gpt-core</artifactId>
<artifactId>nop-ai-core</artifactId>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* Gitee: https://gitee.com/canonical-entropy/nop-entropy
* Github: https://github.com/entropy-cloud/nop-entropy
*/
package io.nop.gpt.core;
package io.nop.ai.core;

public interface GptCoreConstants {
public interface AiCoreConstants {
String ROLE_USER = "user";

String ROLE_SYSTEM = "system";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/**
* Copyright (c) 2017-2024 Nop Platform. All rights reserved.
* Author: [email protected]
* Blog: https://www.zhihu.com/people/canonical-entropy
* Gitee: https://gitee.com/canonical-entropy/nop-entropy
* Github: https://github.com/entropy-cloud/nop-entropy
*/
package io.nop.ai.core.api.chat;

import io.nop.api.core.beans.ExtensibleBean;

import java.util.List;

public class ChatOptions extends ExtensibleBean {
private IChatProgressListener progressListener;

public ChatOptions progressListener(IChatProgressListener progressListener) {
this.setProgressListener(progressListener);
return this;
}

public IChatProgressListener getProgressListener() {
return progressListener;
}

public void setProgressListener(IChatProgressListener progressListener) {
this.progressListener = progressListener;
}

private String seed;
private Float temperature;
private Float topP;
private Integer topK;
private Integer maxTokens;
private List<String> stop;

//============= 以下为coze支持的参数 =====
private String botId;

private String conversationId;

private String userId;

private boolean stream;

public String getSeed() {
return seed;
}

public void setSeed(String seed) {
this.seed = seed;
}

public Float getTemperature() {
return temperature;
}

public void setTemperature(Float temperature) {
this.temperature = temperature;
}

public Float getTopP() {
return topP;
}

public void setTopP(Float topP) {
this.topP = topP;
}

public Integer getTopK() {
return topK;
}

public void setTopK(Integer topK) {
this.topK = topK;
}

public Integer getMaxTokens() {
return maxTokens;
}

public void setMaxTokens(Integer maxTokens) {
this.maxTokens = maxTokens;
}

public List<String> getStop() {
return stop;
}

public void setStop(List<String> stop) {
this.stop = stop;
}

public String getBotId() {
return botId;
}

public void setBotId(String botId) {
this.botId = botId;
}

public String getConversationId() {
return conversationId;
}

public void setConversationId(String conversationId) {
this.conversationId = conversationId;
}

public String getUserId() {
return userId;
}

public void setUserId(String userId) {
this.userId = userId;
}

public boolean isStream() {
return stream;
}

public void setStream(boolean stream) {
this.stream = stream;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
* Gitee: https://gitee.com/canonical-entropy/nop-entropy
* Github: https://github.com/entropy-cloud/nop-entropy
*/
package io.nop.gpt.core.api;
package io.nop.ai.core.api.chat;

import io.nop.ai.core.api.messages.AiMessage;

public interface IChatProgressListener {
void onRecvMessage(String message);
void onRecvMessage(AiMessage message);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
* Gitee: https://gitee.com/canonical-entropy/nop-entropy
* Github: https://github.com/entropy-cloud/nop-entropy
*/
package io.nop.gpt.core.api;
package io.nop.ai.core.api.chat;

import io.nop.ai.core.api.messages.AiMessage;
import io.nop.ai.core.api.messages.Prompt;

import java.util.concurrent.CompletionStage;

public interface IChatSession extends AutoCloseable {
String getSessionId();

CompletionStage<String> sendChatAsync(String role, String question, ChatOptions options);
CompletionStage<AiMessage> sendChatAsync(Prompt prompt, ChatOptions options);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
* Gitee: https://gitee.com/canonical-entropy/nop-entropy
* Github: https://github.com/entropy-cloud/nop-entropy
*/
package io.nop.gpt.core.api;
package io.nop.ai.core.api.chat;

import io.nop.ai.core.api.messages.Prompt;

public interface IChatSessionFactory {
IChatSession newSession(String initPrompt);
IChatSession newSession(Prompt prompt);

IChatSession getSession(String sessionId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2023-2025, Agents-Flex ([email protected]).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.nop.ai.core.api.document;

import io.nop.ai.core.api.support.VectorData;

public class Document extends VectorData {

/**
* Document ID
*/
private Object id;

/**
* Document Content
*/
private String content;


public Document() {
}

public Document(String content) {
this.content = content;
}

public Object getId() {
return id;
}

public void setId(Object id) {
this.id = id;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public static Document of(String content){
Document document = new Document();
document.setContent(content);
return document;
}

@Override
public String toString() {
return "Document{" +
"id=" + id +
", content='" + content + '\'' +
", metadataMap=" + metadataMap +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.nop.ai.core.api.embedding;

import io.nop.api.core.annotations.data.DataBean;

@DataBean
public class EmbeddingOptions {
private String model;

public String getModel() {
return model;
}

public void setModel(String model) {
this.model = model;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.nop.ai.core.api.embedding;

import io.nop.ai.core.api.support.VectorData;

import javax.swing.text.Document;
import java.util.concurrent.CompletionStage;

public interface IEmbeddingModel {
CompletionStage<VectorData> embedAsync(Document doc, EmbeddingOptions options);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.nop.ai.core.api.messages;

public class AbstractTextMessage extends Message{

protected String content;

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

@Override
public Object getMessageContent() {
return getContent();
}
}
Loading

0 comments on commit 67dff01

Please sign in to comment.