Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/org/b3log/symphony/ai/AIRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.b3log.symphony.ai;

public class AIRequest {
}
30 changes: 30 additions & 0 deletions src/main/java/org/b3log/symphony/ai/Model.java
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/
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 {}
}
}
54 changes: 54 additions & 0 deletions src/main/java/org/b3log/symphony/ai/OpenAIProvider.java
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/
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";
}
};
};
}
41 changes: 41 additions & 0 deletions src/main/java/org/b3log/symphony/ai/Provider.java
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/
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<ContentType> content) implements Content {};
}

sealed interface Authorize permits Authorize.Token {
final record Token(String token) implements Authorize {};
}

public String toJSONString();
}
50 changes: 50 additions & 0 deletions src/main/java/org/b3log/symphony/ai/QwenModel.java
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/
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";
}
}
}
}
Loading