diff --git a/src/main/java/org/b3log/symphony/ai/AIRequest.java b/src/main/java/org/b3log/symphony/ai/AIRequest.java new file mode 100644 index 00000000..a96fb37c --- /dev/null +++ b/src/main/java/org/b3log/symphony/ai/AIRequest.java @@ -0,0 +1,4 @@ +package org.b3log.symphony.ai; + +public class AIRequest { +} diff --git a/src/main/java/org/b3log/symphony/ai/Model.java b/src/main/java/org/b3log/symphony/ai/Model.java new file mode 100644 index 00000000..d8198800 --- /dev/null +++ b/src/main/java/org/b3log/symphony/ai/Model.java @@ -0,0 +1,30 @@ +/* + * Rhythm - A modern community (forum/BBS/SNS/blog) platform written in Java. + * Modified version from Symphony, Thanks Symphony :) + * Copyright (C) 2012-present, b3log.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.b3log.symphony.ai; + +public interface Model { + String getName(); + + Provider getProvider(); + + sealed interface Supported permits Supported.Text, Supported.Image { + non-sealed interface Text extends Model, Supported {} + non-sealed interface Image extends Model, Supported {} + } +} diff --git a/src/main/java/org/b3log/symphony/ai/OpenAIProvider.java b/src/main/java/org/b3log/symphony/ai/OpenAIProvider.java new file mode 100644 index 00000000..e061e05a --- /dev/null +++ b/src/main/java/org/b3log/symphony/ai/OpenAIProvider.java @@ -0,0 +1,54 @@ +/* + * Rhythm - A modern community (forum/BBS/SNS/blog) platform written in Java. + * Modified version from Symphony, Thanks Symphony :) + * Copyright (C) 2012-present, b3log.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.b3log.symphony.ai; + +public class OpenAIProvider implements Provider { + private String token; + + OpenAIProvider(String token) { + this.token = token; + } + + public String toJSONString() { + return "Base " + this.token; + } + + sealed interface MessageType permits MessageType.System, MessageType.User, MessageType.Assistant { + record System(String content) implements MessageType { + @Override + public String toString() { + return "system"; + } + }; + + record User(String content) implements MessageType { + @Override + public String toString() { + return "user"; + } + }; + + record Assistant() implements MessageType { + @Override + public String toString() { + return "assistant"; + } + }; + }; +} diff --git a/src/main/java/org/b3log/symphony/ai/Provider.java b/src/main/java/org/b3log/symphony/ai/Provider.java new file mode 100644 index 00000000..e05b0b0b --- /dev/null +++ b/src/main/java/org/b3log/symphony/ai/Provider.java @@ -0,0 +1,41 @@ +/* + * Rhythm - A modern community (forum/BBS/SNS/blog) platform written in Java. + * Modified version from Symphony, Thanks Symphony :) + * Copyright (C) 2012-present, b3log.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.b3log.symphony.ai; + +import java.util.List; + +import org.json.JSONString; + +public interface Provider extends JSONString { + sealed interface ContentType permits ContentType.Text, ContentType.Image { + final record Text(String text) implements ContentType {}; + final record Image(String data, String mimetype) implements ContentType {}; + } + + sealed interface Content permits Content.Text, Content.Array { + final record Text(String text) implements Content {}; + final record Array(List content) implements Content {}; + } + + sealed interface Authorize permits Authorize.Token { + final record Token(String token) implements Authorize {}; + } + + public String toJSONString(); +} diff --git a/src/main/java/org/b3log/symphony/ai/QwenModel.java b/src/main/java/org/b3log/symphony/ai/QwenModel.java new file mode 100644 index 00000000..3056769b --- /dev/null +++ b/src/main/java/org/b3log/symphony/ai/QwenModel.java @@ -0,0 +1,50 @@ +/* + * Rhythm - A modern community (forum/BBS/SNS/blog) platform written in Java. + * Modified version from Symphony, Thanks Symphony :) + * Copyright (C) 2012-present, b3log.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.b3log.symphony.ai; + +public sealed interface QwenModel permits QwenModel.Qwen3, QwenModel.Qwen { + sealed abstract class Base implements Model { + private Provider provider = new OpenAIProvider(); + + abstract public String getName(); + + @Override + public Provider getProvider() { + return this.provider; + } + } + + sealed interface Qwen extends QwenModel { + final class VlOcr extends QwenModel.Base implements Qwen, Model.Supported.Image { + @Override + public String getName() { + return "qwen3-vl-plus"; + } + } + } + + sealed interface Qwen3 extends QwenModel { + final class VlPlus extends QwenModel.Base implements Qwen3, Model.Supported.Text, Model.Supported.Image { + @Override + public String getName() { + return "qwen3-vl-plus"; + } + } + } +}