✨ feat: add DEFAULT_MODEL environment variable (#280)
* ✨ feat: add DEFAULT_MODEL environment variable
* set the model maxLength setting in the models definition
* set the model tokenLimit setting in the models definition
This commit is contained in:
+1
-4
@@ -1,5 +1,4 @@
|
||||
import { ChatBody, Message } from '@/types/chat';
|
||||
import { OpenAIModelID } from '@/types/openai';
|
||||
import { DEFAULT_SYSTEM_PROMPT } from '@/utils/app/const';
|
||||
import { OpenAIStream } from '@/utils/server';
|
||||
import tiktokenModel from '@dqbd/tiktoken/encoders/cl100k_base.json';
|
||||
@@ -22,8 +21,6 @@ const handler = async (req: Request): Promise<Response> => {
|
||||
tiktokenModel.pat_str,
|
||||
);
|
||||
|
||||
const tokenLimit = model.id === OpenAIModelID.GPT_4 ? 6000 : 3000;
|
||||
|
||||
let promptToSend = prompt;
|
||||
if (!promptToSend) {
|
||||
promptToSend = DEFAULT_SYSTEM_PROMPT;
|
||||
@@ -38,7 +35,7 @@ const handler = async (req: Request): Promise<Response> => {
|
||||
const message = messages[i];
|
||||
const tokens = encoding.encode(message.content);
|
||||
|
||||
if (tokenCount + tokens.length > tokenLimit) {
|
||||
if (tokenCount + tokens.length > model.tokenLimit) {
|
||||
break;
|
||||
}
|
||||
tokenCount += tokens.length;
|
||||
|
||||
Reference in New Issue
Block a user