Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/earlybird/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
kiritoko1029 committed Dec 28, 2024
2 parents 281b6e9 + e730c69 commit c738294
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 18 deletions.
35 changes: 32 additions & 3 deletions app/client/platforms/glm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import {
SpeechOptions,
} from "../api";
import { getClientConfig } from "@/app/config/client";
import { getMessageTextContent } from "@/app/utils";
import { getMessageTextContent, isVisionModel } from "@/app/utils";
import { RequestPayload } from "./openai";
import { fetch } from "@/app/utils/stream";
import { preProcessImageContent } from "@/app/utils/chat";

interface BasePayload {
model: string;
Expand Down Expand Up @@ -53,6 +54,32 @@ interface VideoGenerationPayload extends BasePayload {

type ModelType = "chat" | "image" | "video";

interface BasePayload {
model: string;
}

interface ChatPayload extends BasePayload {
messages: ChatOptions["messages"];
stream?: boolean;
temperature?: number;
presence_penalty?: number;
frequency_penalty?: number;
top_p?: number;
}

interface ImageGenerationPayload extends BasePayload {
prompt: string;
size?: string;
user_id?: string;
}

interface VideoGenerationPayload extends BasePayload {
prompt: string;
duration?: number;
resolution?: string;
user_id?: string;
}

export class ChatGLMApi implements LLMApi {
private disableListModels = true;

Expand Down Expand Up @@ -154,9 +181,12 @@ export class ChatGLMApi implements LLMApi {
}

async chat(options: ChatOptions) {
const visionModel = isVisionModel(options.config.model);
const messages: ChatOptions["messages"] = [];
for (const v of options.messages) {
const content = getMessageTextContent(v);
const content = visionModel
? await preProcessImageContent(v.content)
: getMessageTextContent(v);
messages.push({ role: v.role, content });
}

Expand All @@ -168,7 +198,6 @@ export class ChatGLMApi implements LLMApi {
providerName: options.config.providerName,
},
};

const modelType = this.getModelType(modelConfig.model);
const requestPayload = this.createPayload(messages, modelConfig, options);
const path = this.path(this.getModelPath(modelType));
Expand Down
3 changes: 3 additions & 0 deletions app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ export const VISION_MODEL_REGEXES = [
/qwen2-vl/,
/gpt-4-turbo(?!.*preview)/, // Matches "gpt-4-turbo" but not "gpt-4-turbo-preview"
/^dall-e-3$/, // Matches exactly "dall-e-3"
/glm-4v-plus/,
/glm-4v/,
/glm-4v-flash/,
];

export const EXCLUDE_VISION_MODEL_REGEXES = [/claude-3-5-haiku-20241022/];
Expand Down
4 changes: 2 additions & 2 deletions app/styles/themes/coral.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* 珊瑚橙主题 */
@mixin coral-light {
--primary: rgb(255, 127, 80);
--second: rgba(255, 127, 80, 0.1);
--second: rgb(253, 246, 243);
--hover-color: rgb(255, 248, 245);
--bar-color: rgba(255, 127, 80, 0.1);
}

@mixin coral-dark {
--primary: rgb(255, 147, 100);
--second: rgba(255, 147, 100, 0.1);
--second: rgb(46, 42, 41);
--hover-color: rgb(38, 35, 34);
--bar-color: rgba(255, 147, 100, 0.1);
}
4 changes: 2 additions & 2 deletions app/styles/themes/mint.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* 薄荷绿主题 */
@mixin mint-light {
--primary: rgb(22, 177, 155);
--second: rgba(22, 177, 155, 0.1);
--second: rgb(242, 249, 247);
--hover-color: rgb(245, 250, 248);
--bar-color: rgba(22, 177, 155, 0.1);
}

@mixin mint-dark {
--primary: rgb(42, 197, 175);
--second: rgba(42, 197, 175, 0.1);
--second: rgb(41, 46, 45);
--hover-color: rgb(36, 38, 37);
--bar-color: rgba(42, 197, 175, 0.1);
}
16 changes: 8 additions & 8 deletions app/styles/themes/ocean.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* 海洋蓝主题 */
@mixin ocean-light {
--primary: rgb(0, 128, 128);
--second: rgba(0, 128, 128, 0.1);
--hover-color: rgb(245, 250, 250);
--bar-color: rgba(0, 128, 128, 0.1);
--primary: #315ef8;
--second: #f3f3f6;
--hover-color: #f3f3f3;
--bar-color: rgba(0, 0, 0, .1);
}

@mixin ocean-dark {
--primary: rgb(20, 148, 148);
--second: rgba(20, 148, 148, 0.1);
--hover-color: rgb(35, 38, 38);
--bar-color: rgba(20, 148, 148, 0.1);
--primary: #315ef8;
--second: #26262c;
--hover-color: #323232;
--bar-color: hsla(0, 0%, 100%, .1);
}
4 changes: 2 additions & 2 deletions app/styles/themes/purple.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* 深邃紫主题 */
@mixin purple-light {
--primary: rgb(125, 95, 255);
--second: rgba(125, 95, 255, 0.1);
--second: rgb(245, 244, 252);
--hover-color: rgb(247, 245, 255);
--bar-color: rgba(125, 95, 255, 0.1);
}

@mixin purple-dark {
--primary: rgb(145, 115, 255);
--second: rgba(145, 115, 255, 0.1);
--second: rgb(43, 41, 46);
--hover-color: rgb(37, 35, 38);
--bar-color: rgba(145, 115, 255, 0.1);
}
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ console.log("[Next] build mode", mode);
const disableChunk = !!process.env.DISABLE_CHUNK || mode === "export";
console.log("[Next] build with chunk: ", !disableChunk);

const theme = process.env.THEME_COLOR ?? "coral";
const theme = process.env.THEME_COLOR ?? "mint";
console.log("[Next] build with theme: ", theme);

/** @type {import('next').NextConfig} */
Expand Down

0 comments on commit c738294

Please sign in to comment.