main
黄海 7 months ago
parent 31601d9844
commit 7405a02aad

@ -11,6 +11,7 @@ import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.kit.Kv;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.ext.interceptor.GET;
@ -70,16 +71,14 @@ public class MaxKbController extends Controller {
String person_name = rPerson.getStr("person_name");
//1、拷贝生成应用
String sourceApplicationName = "应用【模板】";
String targetApplicationName = person_name;
String sourceApplicationName = PropKit.get("MaxKB_sourceApplicationName");
mkm.delApplication(person_id);//先删除后插入
String applicationId = mkm.addApplication(person_id, sourceApplicationName, targetApplicationName);
String applicationId = mkm.addApplication(person_id, sourceApplicationName, person_name);
//2、拷贝生成知识库
String sourceDataSetName = "知识库【模板】";
String targetDataSetName = person_name;
String sourceDataSetName = PropKit.get("MaxKB_sourceDataSetName");
mkm.delZsk(person_id);
String zskId = mkm.addZsk(person_id,sourceDataSetName, targetDataSetName);
String zskId = mkm.addZsk(person_id, sourceDataSetName, person_name);
//3、应用与知识库关联
mkm.saveApplicationZskId(applicationId, zskId);
@ -89,7 +88,7 @@ public class MaxKbController extends Controller {
String authCode = MaxKbImpl.getAuthorization();
String documentId = service.uploadQA(authCode, person_id, uploadFile);
//5、手动生成问题
String modelName = "DeepSeek";//使用哪个模型
String modelName = PropKit.get("MaxKB_modelName");//使用哪个模型
JSONObject res = service.manualQuestion(authCode, person_id, modelName, documentId);
System.out.println(CommonUtil.getCurrentTime() + " 人工生成问题完毕!");

@ -17,8 +17,8 @@ public class MaxKbModel {
* @return
*/
public List<Record> getDocumentListByZskId(String zskId) {
String sql = "select * from document where dataset_id=?::uuid order by create_time desc";
return Db.use(DbConst.MAXKB).find(sql, zskId);
String sql = "select * from document where dataset_id=? order by create_time desc";
return Db.use(DbConst.MAXKB).find(sql, UUID.fromString(zskId));
}
/**
@ -28,16 +28,16 @@ public class MaxKbModel {
*/
public void delDocumentProblem(String documentId) {
//根据文档id查找它相关有哪些问题id,并且删除问题
String sql = "select * from problem_paragraph_mapping where document_id=?::uuid";
List<Record> recordList = Db.use(DbConst.MAXKB).find(sql, documentId);
String sql = "select * from problem_paragraph_mapping where document_id=?";
List<Record> recordList = Db.use(DbConst.MAXKB).find(sql, UUID.fromString(documentId));
for (Record record : recordList) {
String problem_id = record.getStr("problem_id");
sql = "delete from problem where id=?::uuid";
Db.use(DbConst.MAXKB).update(sql, problem_id);
sql = "delete from problem where id=?";
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(problem_id));
}
//相关的都删除掉了,需要删除问题与段落的关联关系了
sql = "delete from problem_paragraph_mapping where document_id=?::uuid";
Db.use(DbConst.MAXKB).update(sql, documentId);
sql = "delete from problem_paragraph_mapping where document_id=?";
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(documentId));
}
/**
@ -73,7 +73,7 @@ public class MaxKbModel {
Record record = getApplication(sourceApplicationName);
if (record == null) {
System.out.println(sourceApplicationName + "应用不存在!");
System.exit(0);
return null;
}
//克隆出对象
record = new Record().setColumns(record.getColumns());
@ -121,7 +121,7 @@ public class MaxKbModel {
Record record = getZsk(sourceZskName);
if (record == null) {
System.out.println(sourceZskName + "数据集不存在!");
System.exit(0);
return null;
}
//克隆出对象
record = new Record().setColumns(record.getColumns());

@ -140,20 +140,22 @@ public class Start extends JFinalConfig {
hp.setMaximumPoolSize(this.maxPoolSize);
me.add(hp);
HikariCpPlugin hpMaxKB = new HikariCpPlugin(PropKit.get("MaxKB_jdbcUrl"), PropKit.get("MaxKB_user"), PropKit.get("MaxKB_password").trim(),
PropKit.get("driverClassName"));
hpMaxKB.setConnectionTestQuery(this.connectionTestQuery);
hpMaxKB.setConnectionTimeout(this.connectionTimeoutMs);
hpMaxKB.setIdleTimeout(this.idleTimeoutMs);
hpMaxKB.setMaxLifetime(this.maxLifetimeMs);
hpMaxKB.setMaximumPoolSize(this.maxPoolSize);
me.add(hpMaxKB);
if(PropKit.get("MaxKB_jdbcUrl")!=null){
HikariCpPlugin hpMaxKB = new HikariCpPlugin(PropKit.get("MaxKB_jdbcUrl"), PropKit.get("MaxKB_user"), PropKit.get("MaxKB_password").trim(),
PropKit.get("driverClassName"));
hpMaxKB.setConnectionTestQuery(this.connectionTestQuery);
hpMaxKB.setConnectionTimeout(this.connectionTimeoutMs);
hpMaxKB.setIdleTimeout(this.idleTimeoutMs);
hpMaxKB.setMaxLifetime(this.maxLifetimeMs);
hpMaxKB.setMaximumPoolSize(this.maxPoolSize);
me.add(hpMaxKB);
ActiveRecordPlugin maxkbArp = new ActiveRecordPlugin(DbConst.MAXKB, hpMaxKB);
maxkbArp.setDialect(new PostgreSqlDialect());
me.add(maxkbArp);
}
ActiveRecordPlugin arp = new ActiveRecordPlugin(DbConst.SZJZ, hp);
arp.setDialect(new PostgreSqlDialect());
ActiveRecordPlugin slaveArp = new ActiveRecordPlugin(DbConst.MAXKB, hpMaxKB);
slaveArp.setDialect(new PostgreSqlDialect());
String basePath = Start.class.getClassLoader().getResource(".").getPath();
File sqlDir = new File(basePath + "/Sql");
File[] sqlFiles = sqlDir.listFiles();
@ -164,12 +166,11 @@ public class Start extends JFinalConfig {
File sqlFile = var10[i];
if (sqlFile.getName().indexOf(".sql") > 0) {
arp.addSqlTemplate("/Sql/" + sqlFile.getName());
slaveArp.addSqlTemplate("/Sql/" + sqlFile.getName());
}
}
me.add(arp);
me.add(slaveArp);
RedisPlugin redis = new RedisPlugin("Redis", PropKit.get("redis_ip"), PropKit.getInt("redis_port"), 10000);
me.add(redis);
if (!StrKit.isBlank(PropKit.get("pika_ip")) && !StrKit.isBlank(PropKit.get("pika_port"))) {

@ -14,7 +14,9 @@ MaxKB_baseUrl=http://10.10.14.206:8080
# MaxKB系统的管理员账号
MaxKBUsername=admin
MaxKBPassword=Dsideal4r5t6y7u!@#
MaxKB_sourceApplicationName=应用【模板】
MaxKB_sourceDataSetName=知识库【模板】
MaxKB_modelName=DeepSeek
# redis
redis_ip=10.10.14.14

Loading…
Cancel
Save