Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
12 changes: 7 additions & 5 deletions packages/global/core/ai/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,30 @@ export const defaultProvider: ModelProviderItemType = {
order: 999
};

export const formatModelProviders = (data: { provider: string; value: I18nStringStrictType }[]) => {
export const formatModelProviders = (
data: { provider: string; value: I18nStringStrictType; avatar: string }[]
) => {
const getLocalizedName = (translations: I18nStringStrictType, language = 'en'): string => {
return translations[language as langType] || translations.en;
};

const formatModelProviderList = (language?: string): ModelProviderItemType[] => {
return data.map(({ provider, value }, index) => ({
return data.map(({ provider, value, avatar }, index) => ({
id: provider,
name: getLocalizedName(value, language),
avatar: `/api/system/plugin/models/${provider}.svg`,
avatar,
order: index
}));
};

const formatModelProviderMap = (language?: string) => {
const provider = {} as Record<string, ModelProviderItemType>;

data.forEach(({ provider: id, value }, index) => {
data.forEach(({ provider: id, value, avatar }, index) => {
provider[id] = {
id,
name: getLocalizedName(value, language),
avatar: `/api/system/plugin/models/${id}.svg`,
avatar,
order: index
};
});
Expand Down
2 changes: 1 addition & 1 deletion packages/global/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@fastgpt/global",
"version": "1.0.0",
"dependencies": {
"@fastgpt-sdk/plugin": "0.2.13",
"@fastgpt-sdk/plugin": "0.2.15",
"@apidevtools/swagger-parser": "^10.1.0",
"@bany/curl-to-json": "^1.2.8",
"axios": "^1.12.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/service/core/ai/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type SystemDefaultModelType = {
};

declare global {
var ModelProviderRawCache: { provider: string; value: I18nStringStrictType }[];
var ModelProviderRawCache: { provider: string; value: I18nStringStrictType; avatar: string }[];
var ModelProviderListCache: Record<langType, ModelProviderItemType[]>;
var ModelProviderMapCache: Record<langType, Record<string, ModelProviderItemType>>;
var aiproxyIdMapCache: AiproxyMapProviderType;
Expand Down
37 changes: 21 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/app/src/pages/api/common/system/getInitData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type InitDateResponse = {

activeModelList?: SystemModelItemType[];
defaultModels?: SystemDefaultModelType;
modelProviders?: { provider: string; value: I18nStringStrictType }[];
modelProviders?: { provider: string; value: I18nStringStrictType; avatar: string }[];
aiproxyIdMap?: AiproxyMapProviderType;
};

Expand Down
10 changes: 8 additions & 2 deletions projects/app/src/pages/api/system/plugin/[...path].ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ import type { NextApiRequest, NextApiResponse } from 'next';
import { jsonRes } from '@fastgpt/service/common/response';
import { request } from 'http';
import { FastGPTPluginUrl } from '@fastgpt/service/common/system/constants';
import { S3Buckets } from '@fastgpt/service/common/s3/constants';
import type { S3PublicBucket } from '@fastgpt/service/common/s3/buckets/public';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const { path = [] } = req.query as any;
const requestPath = `/imgs/${path?.join('/')}`;
const { path = [] } = req.query as { path: ['plugin', 'models' | 'tools'] };

const requestPath = (global.s3BucketMap[S3Buckets.public] as S3PublicBucket).createPublicUrl(
// !hack: waiting s3 migrate to SDK
`/system/${path.join('/')}`
);

if (!requestPath) {
throw new Error('url is empty');
Expand Down
Loading