Compare commits
No commits in common. "a398641172fae4755781cc7d46223c1c36dfa5e6" and "7d4ff3ce64aea2d776eb0bced9acef2e895763cc" have entirely different histories.
a398641172
...
7d4ff3ce64
20 changed files with 57 additions and 75 deletions
|
@ -56,7 +56,7 @@ public class DiscordBot implements Runnable {
|
|||
if (server.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
var tokens = this.serverDBService.tokensOfLast30Days(String.valueOf(server.get().getId()));
|
||||
var tokens = this.serverDBService.tokensOfLast30Days(server.get().getId());
|
||||
interactionOriginalResponseUpdater.setContent("" + tokens).update();
|
||||
});
|
||||
return;
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ServerDBService {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
public Optional<ServerConfig> getConfig(String serverId) {
|
||||
public Optional<ServerConfig> getConfig(long serverId) {
|
||||
var getServerConfig = """
|
||||
SELECT * FROM server_configs WHERE server_id = ?
|
||||
""";
|
||||
|
@ -32,7 +32,7 @@ public class ServerDBService {
|
|||
.getConnection(this.jdbcConnectionString, this.username, this.password);
|
||||
PreparedStatement pstmt = con.prepareStatement(getServerConfig)
|
||||
) {
|
||||
pstmt.setString(1, serverId);
|
||||
pstmt.setLong(1, serverId);
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
Iterable<ServerConfig> iterable = () -> new ResultSetIterator<>(resultSet, new ServerConfig.ServerConfigResultSetTransformer());
|
||||
return StreamSupport.stream(iterable.spliterator(), false).findFirst();
|
||||
|
@ -89,7 +89,7 @@ public class ServerDBService {
|
|||
.getConnection(this.jdbcConnectionString, this.username, this.password);
|
||||
PreparedStatement pstmt = con.prepareStatement(getServerConfig)
|
||||
) {
|
||||
pstmt.setString(1, newServerConfig.serverId());
|
||||
pstmt.setLong(1, newServerConfig.serverId());
|
||||
pstmt.setString(2, newServerConfig.systemMessage());
|
||||
pstmt.setInt(3, newServerConfig.rateLimit());
|
||||
int affectedRows = pstmt.executeUpdate();
|
||||
|
@ -111,7 +111,7 @@ public class ServerDBService {
|
|||
) {
|
||||
pstmt.setString(1, newServerConfig.systemMessage());
|
||||
pstmt.setInt(2, newServerConfig.rateLimit());
|
||||
pstmt.setString(3, newServerConfig.serverId());
|
||||
pstmt.setLong(3, newServerConfig.serverId());
|
||||
pstmt.setLong(4, id);
|
||||
int affectedRows = pstmt.executeUpdate();
|
||||
if (affectedRows == 0) {
|
||||
|
@ -140,7 +140,7 @@ public class ServerDBService {
|
|||
}
|
||||
}
|
||||
|
||||
public int countMessagesInLastMinute(String serverId) {
|
||||
public int countMessagesInLastMinute(long serverId) {
|
||||
var getServerConfig = """
|
||||
SELECT count(*) FROM server_messages WHERE server_id = ? AND time <= ? and time >= ?
|
||||
""";
|
||||
|
@ -148,7 +148,7 @@ public class ServerDBService {
|
|||
.getConnection(this.jdbcConnectionString, this.username, this.password);
|
||||
PreparedStatement pstmt = con.prepareStatement(getServerConfig)
|
||||
) {
|
||||
pstmt.setString(1, serverId);
|
||||
pstmt.setLong(1, serverId);
|
||||
var now = Instant.now();
|
||||
pstmt.setTimestamp(2, Timestamp.from(now));
|
||||
pstmt.setTimestamp(3, Timestamp.from(now.minus(1, ChronoUnit.MINUTES)));
|
||||
|
@ -172,7 +172,7 @@ public class ServerDBService {
|
|||
.getConnection(this.jdbcConnectionString, this.username, this.password);
|
||||
PreparedStatement pstmt = con.prepareStatement(getServerConfig)
|
||||
) {
|
||||
pstmt.setString(1, serverMessage.serverId());
|
||||
pstmt.setLong(1, serverMessage.serverId());
|
||||
pstmt.setLong(2, serverMessage.userId());
|
||||
pstmt.setInt(3, serverMessage.tokens());
|
||||
int affectedRows = pstmt.executeUpdate();
|
||||
|
@ -184,7 +184,7 @@ public class ServerDBService {
|
|||
}
|
||||
}
|
||||
|
||||
public long tokensOfLast30Days(String serverId) {
|
||||
public long tokensOfLast30Days(long serverId) {
|
||||
var countTokensOfLast30Days = """
|
||||
SELECT sum(tokens) FROM server_messages WHERE server_id = ? AND time < ? AND time >= ?
|
||||
""";
|
||||
|
@ -192,7 +192,7 @@ public class ServerDBService {
|
|||
.getConnection(this.jdbcConnectionString, this.username, this.password);
|
||||
PreparedStatement pstmt = con.prepareStatement(countTokensOfLast30Days)
|
||||
) {
|
||||
pstmt.setString(1, serverId);
|
||||
pstmt.setLong(1, serverId);
|
||||
var now = Instant.now();
|
||||
pstmt.setTimestamp(2, Timestamp.from(now));
|
||||
pstmt.setTimestamp(3, Timestamp.from(now.minus(30, ChronoUnit.DAYS)));
|
||||
|
|
|
@ -24,7 +24,7 @@ public class UserDBService {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
public Optional<UserConfig> getConfig(String userId) {
|
||||
public Optional<UserConfig> getConfig(long userId) {
|
||||
var getServerConfig = """
|
||||
SELECT * FROM user_configs WHERE user_id = ?
|
||||
""";
|
||||
|
@ -32,7 +32,7 @@ public class UserDBService {
|
|||
.getConnection(this.jdbcConnectionString, this.username, this.password);
|
||||
PreparedStatement pstmt = con.prepareStatement(getServerConfig)
|
||||
) {
|
||||
pstmt.setString(1, userId);
|
||||
pstmt.setLong(1, userId);
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
Iterable<UserConfig> iterable = () -> new ResultSetIterator<>(resultSet, new UserConfig.UserConfigResultSetTransformer());
|
||||
return StreamSupport.stream(iterable.spliterator(), false).findFirst();
|
||||
|
@ -90,7 +90,7 @@ public class UserDBService {
|
|||
.getConnection(this.jdbcConnectionString, this.username, this.password);
|
||||
PreparedStatement pstmt = con.prepareStatement(getServerConfig)
|
||||
) {
|
||||
pstmt.setString(1, newUserConfig.userId());
|
||||
pstmt.setLong(1, newUserConfig.userId());
|
||||
pstmt.setString(2, newUserConfig.systemMessage());
|
||||
pstmt.setInt(3, newUserConfig.contextLength());
|
||||
pstmt.setInt(4, newUserConfig.rateLimit());
|
||||
|
@ -105,7 +105,7 @@ public class UserDBService {
|
|||
|
||||
public void updateConfig(long id, UserConfig.NewUserConfig newUserConfig) throws DBException {
|
||||
var getServerConfig = """
|
||||
UPDATE user_configs SET system_message = ?, context_length = ?, rate_limit = ?, user_id = ? WHERE id = ?
|
||||
UPDATE user_configs SET system_message = ?, context_length = ?, rate_limit = ? WHERE id = ?
|
||||
""";
|
||||
try (Connection con = DriverManager
|
||||
.getConnection(this.jdbcConnectionString, this.username, this.password);
|
||||
|
@ -114,8 +114,7 @@ public class UserDBService {
|
|||
pstmt.setString(1, newUserConfig.systemMessage());
|
||||
pstmt.setInt(2, newUserConfig.rateLimit());
|
||||
pstmt.setLong(3, newUserConfig.contextLength());
|
||||
pstmt.setString(4, newUserConfig.userId());
|
||||
pstmt.setLong(5, id);
|
||||
pstmt.setLong(4, id);
|
||||
int affectedRows = pstmt.executeUpdate();
|
||||
if (affectedRows == 0) {
|
||||
logger.error("No config update with id: " + id);
|
||||
|
@ -143,7 +142,7 @@ public class UserDBService {
|
|||
}
|
||||
}
|
||||
|
||||
public int countMessagesInLastMinute(String userId) {
|
||||
public int countMessagesInLastMinute(long userId) {
|
||||
var getServerConfig = """
|
||||
SELECT count(*) FROM user_messages WHERE user_id = ? AND time <= ? and time >= ?
|
||||
""";
|
||||
|
@ -151,7 +150,7 @@ public class UserDBService {
|
|||
.getConnection(this.jdbcConnectionString, this.username, this.password);
|
||||
PreparedStatement pstmt = con.prepareStatement(getServerConfig)
|
||||
) {
|
||||
pstmt.setString(1, userId);
|
||||
pstmt.setLong(1, userId);
|
||||
var now = Instant.now();
|
||||
pstmt.setTimestamp(2, Timestamp.from(now));
|
||||
pstmt.setTimestamp(3, Timestamp.from(now.minus(1, ChronoUnit.MINUTES)));
|
||||
|
@ -175,7 +174,7 @@ public class UserDBService {
|
|||
.getConnection(this.jdbcConnectionString, this.username, this.password);
|
||||
PreparedStatement pstmt = con.prepareStatement(getServerConfig)
|
||||
) {
|
||||
pstmt.setString(1, newUserMessage.userId());
|
||||
pstmt.setLong(1, newUserMessage.userId());
|
||||
pstmt.setString(2, newUserMessage.question());
|
||||
pstmt.setString(3, newUserMessage.answer());
|
||||
pstmt.setInt(4, newUserMessage.tokens());
|
||||
|
@ -188,7 +187,7 @@ public class UserDBService {
|
|||
}
|
||||
}
|
||||
|
||||
public long tokensOfLast30Days(String userId) {
|
||||
public long tokensOfLast30Days(long userId) {
|
||||
var countTokensOfLast30Days = """
|
||||
SELECT sum(tokens) FROM user_messages WHERE user_id = ? AND time < ? AND time >= ?
|
||||
""";
|
||||
|
@ -196,7 +195,7 @@ public class UserDBService {
|
|||
.getConnection(this.jdbcConnectionString, this.username, this.password);
|
||||
PreparedStatement pstmt = con.prepareStatement(countTokensOfLast30Days)
|
||||
) {
|
||||
pstmt.setString(1, userId);
|
||||
pstmt.setLong(1, userId);
|
||||
var now = Instant.now();
|
||||
pstmt.setTimestamp(2, Timestamp.from(now));
|
||||
pstmt.setTimestamp(3, Timestamp.from(now.minus(30, ChronoUnit.DAYS)));
|
||||
|
|
|
@ -8,14 +8,14 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.time.Instant;
|
||||
|
||||
public record ServerConfig(long id, String serverId, String systemMessage, int rateLimit, Instant time) {
|
||||
public record ServerConfig(long id, long serverId, String systemMessage, int rateLimit, Instant time) {
|
||||
|
||||
public static class ServerConfigResultSetTransformer implements ResultSetTransformer<ServerConfig> {
|
||||
|
||||
@Override
|
||||
public ServerConfig transform(ResultSet resultSet) throws SQLException {
|
||||
var id = resultSet.getLong("id");
|
||||
var serverId = resultSet.getString("server_id");
|
||||
var serverId = resultSet.getLong("server_id");
|
||||
var systemMessage = resultSet.getString("system_message");
|
||||
var rateLimit = resultSet.getInt("rate_limit");
|
||||
var time = resultSet.getTimestamp("time").toInstant();
|
||||
|
@ -24,6 +24,6 @@ public record ServerConfig(long id, String serverId, String systemMessage, int r
|
|||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record NewServerConfig(String serverId, String systemMessage, @Nullable int rateLimit) {
|
||||
public record NewServerConfig(long serverId, String systemMessage, @Nullable int rateLimit) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.time.Instant;
|
||||
|
||||
public record ServerMessage(long id, String serverId, long userId, int tokens, Instant time) {
|
||||
public record ServerMessage(long id, long serverId, long userId, int tokens, Instant time) {
|
||||
|
||||
public static class ServerMessageResultSetTransformer implements ResultSetTransformer<ServerMessage> {
|
||||
|
||||
@Override
|
||||
public ServerMessage transform(ResultSet resultSet) throws SQLException {
|
||||
var id = resultSet.getLong("id");
|
||||
var serverId = resultSet.getString("server_id");
|
||||
var serverId = resultSet.getLong("server_id");
|
||||
var userId = resultSet.getLong("user_id");
|
||||
var tokens = resultSet.getInt("tokens");
|
||||
var time = resultSet.getTimestamp("time").toInstant();
|
||||
|
@ -23,6 +23,6 @@ public record ServerMessage(long id, String serverId, long userId, int tokens, I
|
|||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record NewServerMessage(String serverId, long userId, int tokens) {
|
||||
public record NewServerMessage(long serverId, long userId, int tokens) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.time.Instant;
|
||||
|
||||
public record UserConfig(long id, String userId, String systemMessage, int contextLength, int rateLimit, Instant time) {
|
||||
public record UserConfig(long id, long userId, String systemMessage, int contextLength, int rateLimit, Instant time) {
|
||||
|
||||
public static class UserConfigResultSetTransformer implements ResultSetTransformer<UserConfig> {
|
||||
|
||||
@Override
|
||||
public UserConfig transform(ResultSet resultSet) throws SQLException {
|
||||
var id = resultSet.getLong("id");
|
||||
var userId = resultSet.getString("user_id");
|
||||
var userId = resultSet.getLong("user_id");
|
||||
var systemMessage = resultSet.getString("system_message");
|
||||
var contextLength = resultSet.getInt("context_length");
|
||||
var rateLimit = resultSet.getInt("rate_limit");
|
||||
|
@ -25,7 +25,7 @@ public record UserConfig(long id, String userId, String systemMessage, int conte
|
|||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record NewUserConfig(String userId, String systemMessage, @Nullable int contextLength,
|
||||
public record NewUserConfig(long userId, String systemMessage, @Nullable int contextLength,
|
||||
@Nullable int rateLimit) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.time.Instant;
|
||||
|
||||
public record UserMessage(long id, String userId, String question, String answer, int tokens, Instant time) {
|
||||
public record UserMessage(long id, long userId, String question, String answer, int tokens, Instant time) {
|
||||
|
||||
public static class UserMessageResultSetTransformer implements ResultSetTransformer<UserMessage> {
|
||||
|
||||
@Override
|
||||
public UserMessage transform(ResultSet resultSet) throws SQLException {
|
||||
var id = resultSet.getLong("id");
|
||||
var userId = resultSet.getString("user_id");
|
||||
var userId = resultSet.getLong("user_id");
|
||||
var question = resultSet.getString("question");
|
||||
var answer = resultSet.getString("answer");
|
||||
var tokens = resultSet.getInt("tokens");
|
||||
|
@ -24,6 +24,6 @@ public record UserMessage(long id, String userId, String question, String answer
|
|||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record NewUserMessage(String userId, String question, String answer, int tokens) {
|
||||
public record NewUserMessage(long userId, String question, String answer, int tokens) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class MessageCreateHandler implements MessageCreateListener {
|
|||
return;
|
||||
}
|
||||
if (this.messageHandler.exceedsRate(event)) {
|
||||
event.getChannel().sendMessage("Rate limit hit - cooling down...");
|
||||
event.getChannel().sendMessage("Rate limit hit - cooling down now...");
|
||||
return;
|
||||
}
|
||||
this.messageHandler.handle(event);
|
||||
|
|
|
@ -29,8 +29,6 @@ public class ServerMessageHandler implements MessageHandler {
|
|||
@Override
|
||||
public void handle(MessageCreateEvent event) {
|
||||
String content = extractContent(event);
|
||||
var serverId = event.getServer().get().getId();
|
||||
var systemMessage = this.serverDBService.getConfig(String.valueOf(serverId)).get().systemMessage();
|
||||
var request = event.getMessage().getType() == MessageType.REPLY ?
|
||||
new ChatGPTRequestBuilder()
|
||||
.contextRequest(event.getMessage()
|
||||
|
@ -39,8 +37,8 @@ public class ServerMessageHandler implements MessageHandler {
|
|||
.flatMap(m -> m)
|
||||
.map(Message::getReadableContent)
|
||||
.stream().toList(),
|
||||
content, systemMessage) :
|
||||
new ChatGPTRequestBuilder().simpleRequest(content, systemMessage);
|
||||
content) :
|
||||
new ChatGPTRequestBuilder().simpleRequest(content);
|
||||
try {
|
||||
var response = this.chatGPTService.submit(request);
|
||||
if (response.choices().size() < 1) {
|
||||
|
@ -63,7 +61,7 @@ public class ServerMessageHandler implements MessageHandler {
|
|||
}
|
||||
|
||||
var serverId = event.getServer().get().getId();
|
||||
var config = this.serverDBService.getConfig(String.valueOf(serverId));
|
||||
var config = this.serverDBService.getConfig(serverId);
|
||||
if (config.isEmpty()) {
|
||||
logger.debug("Not allowed with id: " + serverId);
|
||||
return false;
|
||||
|
@ -73,7 +71,7 @@ public class ServerMessageHandler implements MessageHandler {
|
|||
|
||||
@Override
|
||||
public boolean exceedsRate(MessageCreateEvent event) {
|
||||
var serverId = String.valueOf(event.getServer().get().getId());
|
||||
var serverId = event.getServer().get().getId();
|
||||
var config = this.serverDBService.getConfig(serverId);
|
||||
if (config.isEmpty()) {
|
||||
logger.error("Missing configuration for server with id: " + serverId);
|
||||
|
@ -94,7 +92,7 @@ public class ServerMessageHandler implements MessageHandler {
|
|||
var serverId = event.getServer().map(DiscordEntity::getId).get();
|
||||
var userId = event.getMessageAuthor().getId();
|
||||
|
||||
var serverMessage = new ServerMessage.NewServerMessage(String.valueOf(serverId), userId, tokens);
|
||||
var serverMessage = new ServerMessage.NewServerMessage(serverId, userId, tokens);
|
||||
this.serverDBService.addMessage(serverMessage);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,7 @@ public class UserMessageHandler implements MessageHandler {
|
|||
@Override
|
||||
public void handle(MessageCreateEvent event) {
|
||||
String content = event.getReadableMessageContent();
|
||||
var userId = event.getMessageAuthor().getId();
|
||||
var systemMessage = this.userDBService.getConfig(String.valueOf(userId)).get().systemMessage();
|
||||
var request = new ChatGPTRequestBuilder().simpleRequest(content, systemMessage);
|
||||
var request = new ChatGPTRequestBuilder().simpleRequest(content);
|
||||
try {
|
||||
var response = this.chatGPTService.submit(request);
|
||||
if (response.choices().size() < 1) {
|
||||
|
@ -49,7 +47,7 @@ public class UserMessageHandler implements MessageHandler {
|
|||
}
|
||||
|
||||
var userId = event.getMessageAuthor().getId();
|
||||
var config = this.userDBService.getConfig(String.valueOf(userId));
|
||||
var config = this.userDBService.getConfig(userId);
|
||||
if (config.isEmpty()) {
|
||||
logger.debug("Not allowed with id: " + userId);
|
||||
return false;
|
||||
|
@ -59,7 +57,7 @@ public class UserMessageHandler implements MessageHandler {
|
|||
|
||||
@Override
|
||||
public boolean exceedsRate(MessageCreateEvent event) {
|
||||
var userId = String.valueOf(event.getMessageAuthor().getId());
|
||||
var userId = event.getMessageAuthor().getId();
|
||||
var config = this.userDBService.getConfig(userId);
|
||||
if (config.isEmpty()) {
|
||||
logger.error("Missing configuration for userId with id: " + userId);
|
||||
|
@ -79,7 +77,7 @@ public class UserMessageHandler implements MessageHandler {
|
|||
private void logUserMessage(MessageCreateEvent event, String question, String answer, int tokens) {
|
||||
var userId = event.getMessageAuthor().getId();
|
||||
|
||||
var userMessage = new UserMessage.NewUserMessage(String.valueOf(userId), question, answer, tokens);
|
||||
var userMessage = new UserMessage.NewUserMessage(userId, question, answer, tokens);
|
||||
this.userDBService.addMessage(userMessage);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,14 @@ import java.util.List;
|
|||
|
||||
public class ChatGPTRequestBuilder {
|
||||
private final String model = "gpt-3.5-turbo";
|
||||
private final String systemMessage = """
|
||||
You are Jarvis, a helpful and friendly AI. People interact with you over Discord, a chatting platform. Your default language to answer is German. You format your responses in markdown and your answers don´t need to be formal.
|
||||
""";
|
||||
|
||||
public ChatGPTRequestBuilder() {
|
||||
}
|
||||
|
||||
public ChatGPTRequest simpleRequest(String content, String systemMessage) {
|
||||
public ChatGPTRequest simpleRequest(String content) {
|
||||
return new ChatGPTRequest(
|
||||
model,
|
||||
List.of(new ChatGPTRequest.Message("system", systemMessage), new ChatGPTRequest.Message("user", content)),
|
||||
|
@ -19,7 +22,7 @@ public class ChatGPTRequestBuilder {
|
|||
);
|
||||
}
|
||||
|
||||
public ChatGPTRequest contextRequest(List<String> contextMessages, String message, String systemMessage) {
|
||||
public ChatGPTRequest contextRequest(List<String> contextMessages, String message) {
|
||||
List<ChatGPTRequest.Message> messages = new ArrayList<>();
|
||||
messages.add(new ChatGPTRequest.Message("system", systemMessage));
|
||||
var context = contextMessages.stream()
|
||||
|
|
|
@ -106,19 +106,3 @@ DROP TABLE IF EXISTS allowed_servers;
|
|||
DROP TABLE IF EXISTS allowed_users;
|
||||
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE server_configs
|
||||
ALTER COLUMN server_id TYPE text USING server_id::text;
|
||||
|
||||
ALTER TABLE server_messages
|
||||
ALTER COLUMN server_id TYPE text USING server_id::text;
|
||||
|
||||
ALTER TABLE user_configs
|
||||
ALTER COLUMN user_id TYPE text USING user_id::text;
|
||||
|
||||
ALTER TABLE user_messages
|
||||
ALTER COLUMN user_id TYPE text USING user_id::text;
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -20,7 +20,7 @@ const submitAction = async () => {
|
|||
<h1 class="text-xl normal-case">Add Server Config</h1>
|
||||
<div class="m-2">
|
||||
<label class="mr-4">Server ID</label>
|
||||
<input v-model="newConfig.serverId" class="input input-bordered w-full max-w-xs" />
|
||||
<input v-model.number="newConfig.serverId" class="input input-bordered w-full max-w-xs" />
|
||||
</div>
|
||||
<div class="m-2">
|
||||
<label class="mr-4">System Message</label>
|
||||
|
|
|
@ -27,7 +27,7 @@ const modalId = "edit-" + id
|
|||
</div>
|
||||
<div class="m-2">
|
||||
<label class="mr-4">Server ID</label>
|
||||
<input v-model="configToEdit.serverId" class="input input-bordered w-full max-w-xs" />
|
||||
<input v-model.number="configToEdit.serverId" class="input input-bordered w-full max-w-xs" />
|
||||
</div>
|
||||
<div class="m-2">
|
||||
<label class="mr-4">System Message</label>
|
||||
|
|
|
@ -17,7 +17,7 @@ const submitAction = async () => {
|
|||
<h1 class="text-xl normal-case">Add User Config</h1>
|
||||
<div class="m-2">
|
||||
<label class="mr-4">User ID</label>
|
||||
<input v-model="newConfig.userId" class="input input-bordered w-full max-w-xs" />
|
||||
<input v-model.number="newConfig.userId" class="input input-bordered w-full max-w-xs" />
|
||||
</div>
|
||||
<div class="m-2">
|
||||
<label class="mr-4">System Message</label>
|
||||
|
|
|
@ -19,14 +19,14 @@ const modalId = "edit-" + id
|
|||
<template>
|
||||
<ModalComponent :modalId="modalId" :openModal="{ class: 'btn btn-sm btn-info m-1', label: 'Edit' }"
|
||||
:submitAction="submitAction" :onLoadAction="onLoadAction">
|
||||
<h1 class="text-xl normal-case">Edit User Config</h1>
|
||||
<h1 class="text-xl normal-case">Edit Server Config</h1>
|
||||
<div class="m-2">
|
||||
<label class="mr-4">ID</label>
|
||||
<input v-model.number="configToEdit.id" class="input input-bordered w-full max-w-xs" disabled />
|
||||
</div>
|
||||
<div class="m-2">
|
||||
<label class="mr-4">User ID</label>
|
||||
<input v-model="configToEdit.userId" class="input input-bordered w-full max-w-xs" />
|
||||
<label class="mr-4">Server ID</label>
|
||||
<input v-model.number="configToEdit.userId" class="input input-bordered w-full max-w-xs" />
|
||||
</div>
|
||||
<div class="m-2">
|
||||
<label class="mr-4">System Message</label>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export type ServerConfig = {
|
||||
id: number,
|
||||
serverId: string,
|
||||
serverId: number,
|
||||
systemMessage: string,
|
||||
rateLimit: number,
|
||||
time: string
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export type UserConfig = {
|
||||
id: number,
|
||||
userId: string,
|
||||
userId: number,
|
||||
systemMessage: string,
|
||||
contextLength: number,
|
||||
rateLimit: number,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { ServerConfig } from "@/models/server";
|
||||
|
||||
const configUrl = "http://localhost:7070/api/servers/configs/"
|
||||
const configUrl = "/api/servers/configs/"
|
||||
|
||||
export async function getConfigs(): Promise<ServerConfig[]> {
|
||||
return fetch(configUrl)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { UserConfig } from '@/models/user'
|
||||
|
||||
const configUrl = "http://localhost:7070/api/users/configs/"
|
||||
const configUrl = "/api/users/configs/"
|
||||
|
||||
export async function getConfigs(): Promise<UserConfig[]> {
|
||||
return fetch(configUrl)
|
||||
|
|
Loading…
Reference in a new issue