mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-18 14:23:39 +00:00
Compare commits
4 Commits
158a0190b5
...
951524bff7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
951524bff7 | ||
|
|
c7d0e9337a | ||
|
|
6955f3c7dc | ||
|
|
a52b017e1a |
@@ -12,6 +12,17 @@ REDIS_PASSWORD=
|
||||
REDIS_DATABASE=0
|
||||
REDIS_TIMEOUT=10s
|
||||
|
||||
# Weaviate Configuration
|
||||
WEAVIATE_QUERY_LIMIT=25
|
||||
WEAVIATE_ANONYMOUS_ACCESS=true
|
||||
WEAVIATE_DATA_PATH=/var/lib/weaviate
|
||||
WEAVIATE_VECTORIZER_MODULE=none
|
||||
WEAVIATE_MODULES=text2vec-cohere,text2vec-huggingface,text2vec-palm,text2vec-openai,generative-openai,generative-cohere,generative-palm,ref2vec-centroid,reranker-cohere,qna-openai
|
||||
WEAVIATE_CLUSTER_HOSTNAME=node1
|
||||
WEAVIATE_PROTOCOL=http
|
||||
WEAVIATE_HOST=weaviate:8080
|
||||
WEAVIATE_CLASSNAME=LocalKnowledge
|
||||
|
||||
# Backend Configuration
|
||||
BACKEND_SERVER_PORT=6039
|
||||
DB_URL=jdbc:mysql://mysql:3306/ruoyi-ai?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
|
||||
@@ -38,6 +38,28 @@ services:
|
||||
networks:
|
||||
- ruoyi-net
|
||||
|
||||
weaviate:
|
||||
image: semitechnologies/weaviate:1.30.0
|
||||
container_name: ruoyi-ai-weaviate
|
||||
env_file:
|
||||
- ./.env
|
||||
environment:
|
||||
- QUERY_DEFAULTS_LIMIT=${WEAVIATE_QUERY_LIMIT}
|
||||
- AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=${WEAVIATE_ANONYMOUS_ACCESS}
|
||||
- PERSISTENCE_DATA_PATH=${WEAVIATE_DATA_PATH}
|
||||
- DEFAULT_VECTORIZER_MODULE=${WEAVIATE_VECTORIZER_MODULE}
|
||||
- ENABLE_MODULES=${WEAVIATE_MODULES}
|
||||
- CLUSTER_HOSTNAME=${WEAVIATE_CLUSTER_HOSTNAME}
|
||||
command: --host 0.0.0.0 --port 8080 --scheme http
|
||||
ports:
|
||||
- "50050:8080"
|
||||
- "50051:50051"
|
||||
volumes:
|
||||
- ./data/weaviate:/var/lib/weaviate
|
||||
restart: always
|
||||
networks:
|
||||
- ruoyi-net
|
||||
|
||||
ruoyi-backend:
|
||||
image: ruoyi-ai-backend:v2.0.5
|
||||
container_name: ruoyi-ai-backend
|
||||
|
||||
@@ -155,7 +155,7 @@ INSERT INTO `chat_config` VALUES (1813506141979254785, 'mail', 'mailTitle', '【
|
||||
INSERT INTO `chat_config` VALUES (1818270017648070657, 'stripe', 'prompt', 'This system is for demonstration only and does not currently support this feature!', '提示语', 103, '2024-07-30 20:58:49', '1', '1', '2024-08-11 12:02:42', NULL, NULL, '0', NULL, 0);
|
||||
INSERT INTO `chat_config` VALUES (1818270017966837761, 'stripe', 'enabled', 'true', '开启支付', 103, '2024-07-30 20:58:49', '1', '1', '2024-08-11 12:02:42', NULL, NULL, '0', NULL, 0);
|
||||
INSERT INTO `chat_config` VALUES (1897610056458412050, 'weaviate', 'protocol', 'http', '协议', 103, '2025-03-06 21:10:02', '1', '1', '2025-03-06 21:10:31', NULL, NULL, '0', NULL, 0);
|
||||
INSERT INTO `chat_config` VALUES (1897610056458412051, 'weaviate', 'host', '127.0.0.1:6038', '地址', 103, '2025-03-06 21:10:02', '1', '1', '2025-03-06 21:10:31', NULL, NULL, '0', NULL, 0);
|
||||
INSERT INTO `chat_config` VALUES (1897610056458412051, 'weaviate', 'host', 'weaviate:8080', '地址', 103, '2025-03-06 21:10:02', '1', '1', '2025-03-06 21:10:31', NULL, NULL, '0', NULL, 0);
|
||||
INSERT INTO `chat_config` VALUES (1897610056458412052, 'weaviate', 'classname', 'LocalKnowledge', '分类名称', 103, '2025-03-06 21:10:02', '1', '1', '2025-03-06 21:10:31', NULL, NULL, '0', NULL, 0);
|
||||
INSERT INTO `chat_config` VALUES (1897610056458412053, 'milvus', 'host', '127.0.0.1', '地址', 103, '2025-03-06 21:10:02', '1', '1', '2025-03-06 21:10:31', NULL, NULL, '0', NULL, 0);
|
||||
INSERT INTO `chat_config` VALUES (1897610056458412054, 'milvus', 'port', '19530', '端口', 103, '2025-03-06 21:10:02', '1', '1', '2025-03-06 21:10:31', NULL, NULL, '0', NULL, 0);
|
||||
|
||||
2
docker-deploy/deploy/update_ruoyi-qi-sql.sh
Executable file
2
docker-deploy/deploy/update_ruoyi-qi-sql.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
sed -i 's#127.0.0.1:6038#weaviate:8080#g' ./mysql-init/01_ruoyi-ai.sql
|
||||
@@ -43,6 +43,7 @@ public class ChatMessageBo extends BaseEntity {
|
||||
/**
|
||||
* 会话id
|
||||
*/
|
||||
@NotBlank(message = "会话id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long sessionId;
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,14 +54,18 @@ public class ChatCostServiceImpl implements IChatCostService {
|
||||
String modelName = chatRequest.getModel();
|
||||
|
||||
ChatMessageBo chatMessageBo = new ChatMessageBo();
|
||||
chatMessageBo.setSessionId(chatRequest.getSessionId());
|
||||
|
||||
if(chatRequest.getSessionId() == null){
|
||||
Object sessionId = LocalCache.CACHE.get("sessionId");
|
||||
chatRequest.setSessionId((Long) sessionId);
|
||||
}
|
||||
|
||||
Object userId = LocalCache.CACHE.get("userId");
|
||||
if(userId!=null){
|
||||
chatMessageBo.setUserId((Long) userId);
|
||||
}else {
|
||||
chatMessageBo.setUserId(getUserId());
|
||||
}
|
||||
chatMessageBo.setUserId((Long) userId);
|
||||
|
||||
chatMessageBo.setSessionId(chatRequest.getSessionId());
|
||||
chatMessageBo.setContent(chatRequest.getPrompt());
|
||||
|
||||
// 计算总token数
|
||||
ChatToken chatToken = chatTokenService.queryByUserId(chatMessageBo.getUserId(), modelName);
|
||||
if (chatToken == null) {
|
||||
@@ -95,7 +99,7 @@ public class ChatCostServiceImpl implements IChatCostService {
|
||||
deductUserBalance(chatMessageBo.getUserId(), numberCost);
|
||||
chatMessageBo.setDeductCost(numberCost);
|
||||
}
|
||||
chatMessageBo.setContent(chatRequest.getPrompt());
|
||||
|
||||
} else {
|
||||
deductUserBalance(chatMessageBo.getUserId(), 0.0);
|
||||
chatMessageBo.setDeductCost(0d);
|
||||
|
||||
@@ -89,6 +89,7 @@ public class SseServiceImpl implements ISseService {
|
||||
chatSessionService.insertByBo(chatSessionBo);
|
||||
chatRequest.setSessionId(chatSessionBo.getId());
|
||||
}
|
||||
LocalCache.CACHE.put("sessionId", chatRequest.getSessionId());
|
||||
// 保存消息记录 并扣除费用
|
||||
chatCostService.deductToken(chatRequest);
|
||||
// 根据模型分类调用不同的处理逻辑
|
||||
|
||||
Reference in New Issue
Block a user