Skip to content

Commit

Permalink
-增加GPT-4o模型
Browse files Browse the repository at this point in the history
-增加Gemini 1.5 Flash模型 fix #16
  • Loading branch information
flyun committed May 19, 2024
1 parent de755f6 commit 479da5f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5767,6 +5767,8 @@ protected void performSendMessageRequest(final TLObject req, final MessageObject
boolean isGemini;
boolean isGeminiProVision;

boolean isOpenAIVision;

if ((user.flags2 & MessagesController.UPDATE_MASK_CHAT_AIR_PROMPT) != 0
&& !TextUtils.isEmpty(user.prompt)) {
prompt = user.prompt;
Expand All @@ -5788,6 +5790,8 @@ protected void performSendMessageRequest(final TLObject req, final MessageObject
isGemini = UserConfig.getInstance(currentAccount).isJudgeByModelGemini(aiModel);
isGeminiProVision = UserConfig.getInstance(currentAccount).isJudgeByModelGeminiProVision(aiModel);

isOpenAIVision = UserConfig.getInstance(currentAccount).isJudgeByModelOpenAIVision(aiModel);


if ((user.flags2 & MessagesController.UPDATE_MASK_CHAT_AIR_AI_TEMPERATURE) != 0
&& user.flags2 != -1) {
Expand Down Expand Up @@ -5816,7 +5820,7 @@ protected void performSendMessageRequest(final TLObject req, final MessageObject
ChatCompletionRequest chatCompletionRequest;

// 发送请求格式切换,多模态请求,以及旧模态请求(只能发送文本)
if (isMultiCompletionRequest(aiModelReal)) {
if (isMultiCompletionRequest(aiModelReal, isOpenAIVision)) {
List<ChatMultiMessage> chatMessageList = getChatMultiCompletionRequest(prompt, msgObj);

chatCompletionRequest = ChatCompletionRequest.builder()
Expand Down Expand Up @@ -6527,7 +6531,7 @@ private List<ChatMessage> getChatCompletionRequest(
}

// 控制多模态与旧模态切换
private boolean isMultiCompletionRequest(String aiModelReal) {
private boolean isMultiCompletionRequest(String aiModelReal, boolean isOpenAIVision) {

boolean isMulti = false;

Expand All @@ -6539,9 +6543,9 @@ private boolean isMultiCompletionRequest(String aiModelReal) {
// 截止2023.11.11 openAi官方的聊天模型都适配多模态
// 对于只是转发openAi的网站,没有问题。但比如OpenRouter,还是使用旧的模型,没有针对openAi所有模型进行更新
boolean isModelReal = false;
if (!TextUtils.isEmpty(aiModelReal)) isModelReal = aiModelReal.contains("gpt-4-vision");
if (!TextUtils.isEmpty(aiModelReal)) isModelReal = UserConfig.isOpenAiMulti(aiModelReal);

isMulti = !isOpenRouter && isModelReal;
isMulti = !isOpenRouter && (isModelReal || isOpenAIVision);

return isMulti;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,11 @@ private void initAiModelList() {
aiModelList.put(8, new AiModelBean("GPT-4-32k-0613", "gpt-4-32k-0613", false));
aiModelList.put(9, new AiModelBean("GPT-4-1106-preview", "gpt-4-1106-preview", false));
aiModelList.put(11, new AiModelBean("GPT-4-0125-preview", "gpt-4-0125-preview", true));
aiModelList.put(13, new AiModelBean("GPT-4o", "gpt-4o", true));
aiModelList.put(10, new AiModelBean("GPT-4-vision-preview", "gpt-4-vision-preview",
"GPT-4-vision-preview (Picture model)", true));
aiModelList.put(14, new AiModelBean("GPT-4o-Picture", "gpt-4o",
"GPT-4o (Picture model)", true));
// initOpenrouter();
initGoogle();
aiModelList.put(0, new AiModelBean(LocaleController.getString("CustomModel", R.string.CustomModel), "custom Model", true));
Expand Down Expand Up @@ -545,13 +548,29 @@ public void initGoogle() {
if (aiModelList == null) return;
aiModelList.put(801, new AiModelBean("Gemini Pro 1.0", "gemini-pro", true));
aiModelList.put(803, new AiModelBean("Gemini Pro 1.5", "gemini-1.5-pro-latest", true));
aiModelList.put(804, new AiModelBean("Gemini Pro 1.5 Flash", "gemini-1.5-flash-latest", true));
aiModelList.put(802, new AiModelBean("Gemini Pro Vision", "gemini-pro-vision",
"Gemini Pro Vision (Picture model)", true));
aiModelList.put(805, new AiModelBean("Gemini Pro 1.5 Picture", "gemini-1.5-pro-latest",
"Gemini Pro 1.5 (Picture model)", true));
aiModelList.put(806, new AiModelBean("Gemini 1.5 Flash Picture", "gemini-1.5-flash-latest",
"Gemini 1.5 Flash (Picture model)", true));

}

public static boolean isOpenAiMulti(String model) {
if (!TextUtils.isEmpty(model)
&& (model.equals("gpt-4-vision-preview")
)) {
return true;
}
return false;
}
public static String getGoogleVersion(String model) {
if (!TextUtils.isEmpty(model) && model.equals("gemini-1.5-pro-latest")) {
if (!TextUtils.isEmpty(model)
&& (model.equals("gemini-1.5-pro-latest")
|| model.equals("gemini-1.5-flash-latest")
)) {
return "v1beta";
}
return "v1";
Expand Down Expand Up @@ -699,6 +718,9 @@ public boolean isJudgeByModelGemini(int aiModel) {
if (aiModel == 801) return true;
if (aiModel == 802) return true;
if (aiModel == 803) return true;
if (aiModel == 804) return true;
if (aiModel == 805) return true;
if (aiModel == 806) return true;

return false;
}
Expand All @@ -719,6 +741,16 @@ public static boolean isUserGeminiProVision(int currentAccount, long userId) {
public boolean isJudgeByModelGeminiProVision(int aiModel) {

if (aiModel == 802) return true;
if (aiModel == 805) return true;
if (aiModel == 806) return true;

return false;
}

public boolean isJudgeByModelOpenAIVision(int aiModel) {

if (aiModel == 10) return true;
if (aiModel == 14) return true;

return false;
}
Expand All @@ -740,7 +772,10 @@ public static boolean isUserVision(int currentAccount, long userId) {
public boolean isJudgeByModelVision(int aiModel) {

if (aiModel == 802) return true;
if (aiModel == 805) return true;
if (aiModel == 806) return true;
if (aiModel == 10) return true;
if (aiModel == 14) return true;

return false;
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Mar 12 05:53:50 MSK 2016
APP_VERSION_CODE=5
APP_VERSION_NAME=1.0.5
APP_VERSION_CODE=6
APP_VERSION_NAME=1.0.6
APP_PACKAGE=info.flyun.chatair
RELEASE_KEY_PASSWORD=android
RELEASE_KEY_ALIAS=androidkey
Expand Down

0 comments on commit 479da5f

Please sign in to comment.