Skip to content

Commit

Permalink
✨ feat: Add new model info
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Mar 24, 2024
1 parent 2151fa7 commit cbe785e
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ export enum LanguageModel {
* GPT 3.5 Turbo
*/
GPT3_5 = 'gpt-3.5-turbo',
GPT3_5_0125 = 'gpt-3.5-turbo-0125',
GPT3_5_1106 = 'gpt-3.5-turbo-1106',
GPT3_5_16K = 'gpt-3.5-turbo-16k',
/**
* GPT 4
*/
GPT4 = 'gpt-4',
GPT4_0125_PREVIEW = 'gpt-4-0125-preview',
GPT4_32K = 'gpt-4-32k',
GPT4_PREVIEW = 'gpt-4-1106-preview',
GPT4_VISION_PREVIEW = 'gpt-4-vision-preview',
Expand All @@ -18,8 +20,12 @@ export const ModelTokens: Record<LanguageModel, number> = {
[LanguageModel.GPT3_5]: 4096,
[LanguageModel.GPT3_5_1106]: 16_385,
[LanguageModel.GPT3_5_16K]: 16_385,
[LanguageModel.GPT3_5_0125]: 16_385,
[LanguageModel.GPT4]: 8196,
[LanguageModel.GPT4_PREVIEW]: 128_000,
[LanguageModel.GPT4_VISION_PREVIEW]: 128_000,
[LanguageModel.GPT4_0125_PREVIEW]: 128_000,
[LanguageModel.GPT4_32K]: 32_768,
};

export const defaultModel = LanguageModel.GPT3_5_0125;
3 changes: 2 additions & 1 deletion packages/lobe-commit/src/commands/Config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { memo, useMemo, useState } from 'react';
import { BASE_PROMPT } from '@/constants/template';
import { useConfStore } from '@/store';
import type { ConfigKeys, Config as LocalConfig } from '@/types/config';
import { LanguageModel } from '@/types/models';

import { LanguageModel } from '../../../../common/models';

const Config = memo(() => {
const [active, setActive] = useState<string>();
Expand Down
3 changes: 2 additions & 1 deletion packages/lobe-commit/src/core/Commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { execSync } from 'node:child_process';
import { SUMMARY_PROMPT, SUMMARY_REFINE_PROMPT, promptCommits } from '@/prompts/commits';
import { selectors } from '@/store';
import { Config } from '@/types/config';
import { ModelTokens } from '@/types/models';
import { calcToken } from '@/utils/calcToken';
import { addEmojiToMessage } from '@/utils/genCommitMessage';

import { ModelTokens } from '../../../common/models';

export interface GenAiCommitProps {
cacheSummary?: string;
setLoadingInfo: (text: string) => void;
Expand Down
7 changes: 4 additions & 3 deletions packages/lobe-commit/src/store/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import Conf from 'conf';

import { ConfigSchema } from '@/types/config';
import { LanguageModel, ModelTokens } from '@/types/models';

import { ModelTokens, defaultModel } from '../../../common/models';

export const schema: ConfigSchema = {
apiBaseUrl: {
default: '',
type: 'string',
},
diffChunkSize: {
default: ModelTokens[LanguageModel.GPT3_5] - 512,
default: ModelTokens[defaultModel] - 512,
type: 'number',
},
emoji: {
Expand All @@ -29,7 +30,7 @@ export const schema: ConfigSchema = {
type: 'number',
},
modelName: {
default: LanguageModel.GPT3_5,
default: defaultModel,
type: 'string',
},
openaiToken: {
Expand Down
2 changes: 1 addition & 1 deletion packages/lobe-commit/src/store/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import dotenv from 'dotenv';

import { Config, ConfigKeys } from '@/types/config';
import { ModelTokens } from '@/types/models';

import { ModelTokens } from '../../../common/models';
import { config, schema } from './config';

dotenv.config();
Expand Down
2 changes: 1 addition & 1 deletion packages/lobe-commit/src/types/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LanguageModel } from './models';
import { LanguageModel } from '../../../common/models';

export interface Config {
apiBaseUrl: string;
Expand Down
5 changes: 3 additions & 2 deletions packages/lobe-i18n/src/store/initialState.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { I18nConfig, MarkdownModeType } from '@/types/config';
import { LanguageModel } from '@/types/models';
import { getDefaultExtension } from '@/utils/getDefaultExtension';

import { defaultModel } from '../../../common/models';

export const DEFAULT_CONFIG: Partial<I18nConfig> = {
concurrency: 5,
markdown: {
entry: [],
mode: MarkdownModeType.STRING,
outputExtensions: getDefaultExtension,
},
modelName: LanguageModel.GPT3_5,
modelName: defaultModel,
temperature: 0,
};
2 changes: 1 addition & 1 deletion packages/lobe-i18n/src/types/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LanguageModel } from './models';
import { LanguageModel } from '../../../common/models';

export interface I18nConfigLocale {
/**
Expand Down
25 changes: 0 additions & 25 deletions packages/lobe-i18n/src/types/models.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/lobe-i18n/src/utils/splitJsonToChunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { isPlainObject, reduce } from 'lodash-es';

import { LocaleObj } from '@/types';
import { I18nConfig } from '@/types/config';
import { LanguageModel, ModelTokens } from '@/types/models';

import { ModelTokens, defaultModel } from '../../../common/models';
import {
KEY_EXTRA_TOKENS,
OBJECT_EXTRA_TOKENS,
Expand Down Expand Up @@ -38,7 +38,7 @@ const splitJSONtoSmallChunks = (object: LocaleObj, splitToken: number) =>
).map(([chunk]) => chunk);

export const getSplitToken = (config: I18nConfig, prompt: string) => {
let splitToken = (ModelTokens[config.modelName || LanguageModel.GPT3_5] - calcToken(prompt)) / 3;
let splitToken = (ModelTokens[config.modelName || defaultModel] - calcToken(prompt)) / 3;
if (config.splitToken && config.splitToken < splitToken) {
splitToken = config.splitToken;
}
Expand Down
5 changes: 3 additions & 2 deletions packages/lobe-seo/src/store/initialState.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { SeoConfig } from '@/types/config';
import { LanguageModel } from '@/types/models';

import { defaultModel } from '../../../common/models';

export const DEFAULT_CONFIG: Partial<SeoConfig> = {
concurrency: 5,
entryExtension: '.mdx',
modelName: LanguageModel.GPT3_5,
modelName: defaultModel,
temperature: 0,
};
2 changes: 1 addition & 1 deletion packages/lobe-seo/src/types/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LanguageModel } from './models';
import { LanguageModel } from '../../../common/models';

export interface SeoConfig {
/**
Expand Down
25 changes: 0 additions & 25 deletions packages/lobe-seo/src/types/models.ts

This file was deleted.

0 comments on commit cbe785e

Please sign in to comment.