mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
remove maxtokens
This commit is contained in:
parent
7dda4bdc08
commit
0589a2a5ec
8 changed files with 88 additions and 101 deletions
|
|
@ -1,58 +0,0 @@
|
|||
|
||||
|
||||
export const defaultAnthropicModels = [
|
||||
'claude-3-5-sonnet-20240620',
|
||||
// 'claude-3-opus-20240229',
|
||||
// 'claude-3-sonnet-20240229',
|
||||
// 'claude-3-haiku-20240307'
|
||||
]
|
||||
|
||||
|
||||
export const defaultOpenAIModels = [
|
||||
'o1-preview',
|
||||
'o1-mini',
|
||||
'gpt-4o',
|
||||
'gpt-4o-mini',
|
||||
// 'gpt-4o-2024-05-13',
|
||||
// 'gpt-4o-2024-08-06',
|
||||
// 'gpt-4o-mini-2024-07-18',
|
||||
// 'gpt-4-turbo',
|
||||
// 'gpt-4-turbo-2024-04-09',
|
||||
// 'gpt-4-turbo-preview',
|
||||
// 'gpt-4-0125-preview',
|
||||
// 'gpt-4-1106-preview',
|
||||
// 'gpt-4',
|
||||
// 'gpt-4-0613',
|
||||
// 'gpt-3.5-turbo-0125',
|
||||
// 'gpt-3.5-turbo',
|
||||
// 'gpt-3.5-turbo-1106',
|
||||
]
|
||||
|
||||
|
||||
|
||||
export const defaultGroqModels = [
|
||||
"mixtral-8x7b-32768",
|
||||
"llama2-70b-4096",
|
||||
"gemma-7b-it"
|
||||
]
|
||||
|
||||
|
||||
export const defaultGeminiModels = [
|
||||
'gemini-1.5-flash',
|
||||
'gemini-1.5-pro',
|
||||
'gemini-1.5-flash-8b',
|
||||
'gemini-1.0-pro'
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const dummyModelData = {
|
||||
anthropic: ['claude 3.5'],
|
||||
openAI: ['gpt 4o'],
|
||||
ollama: ['llama 3.2', 'codestral'],
|
||||
openRouter: ['qwen 2.5'],
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -4,7 +4,84 @@
|
|||
* Void Editor additions licensed under the AGPL 3.0 License.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { defaultAnthropicModels, defaultGeminiModels, defaultGroqModels, defaultOpenAIModels } from './voidConfigModelDefaults.js'
|
||||
|
||||
// https://docs.anthropic.com/en/docs/about-claude/models
|
||||
export const defaultAnthropicModels = [
|
||||
'claude-3-5-sonnet-20241022',
|
||||
'claude-3-5-haiku-20241022',
|
||||
'claude-3-opus-20240229',
|
||||
'claude-3-sonnet-20240229',
|
||||
// 'claude-3-haiku-20240307',
|
||||
]
|
||||
|
||||
|
||||
export const defaultOpenAIModels = [
|
||||
'o1-preview',
|
||||
'o1-mini',
|
||||
'gpt-4o',
|
||||
'gpt-4o-mini',
|
||||
// 'gpt-4o-2024-05-13',
|
||||
// 'gpt-4o-2024-08-06',
|
||||
// 'gpt-4o-mini-2024-07-18',
|
||||
// 'gpt-4-turbo',
|
||||
// 'gpt-4-turbo-2024-04-09',
|
||||
// 'gpt-4-turbo-preview',
|
||||
// 'gpt-4-0125-preview',
|
||||
// 'gpt-4-1106-preview',
|
||||
// 'gpt-4',
|
||||
// 'gpt-4-0613',
|
||||
// 'gpt-3.5-turbo-0125',
|
||||
// 'gpt-3.5-turbo',
|
||||
// 'gpt-3.5-turbo-1106',
|
||||
]
|
||||
|
||||
|
||||
|
||||
export const defaultGroqModels = [
|
||||
"mixtral-8x7b-32768",
|
||||
"llama2-70b-4096",
|
||||
"gemma-7b-it"
|
||||
]
|
||||
|
||||
|
||||
export const defaultGeminiModels = [
|
||||
'gemini-1.5-flash',
|
||||
'gemini-1.5-pro',
|
||||
'gemini-1.5-flash-8b',
|
||||
'gemini-1.0-pro'
|
||||
]
|
||||
|
||||
|
||||
|
||||
// export const parseMaxTokensStr = (maxTokensStr: string) => {
|
||||
// // parse the string but only if the full string is a valid number, eg parseInt('100abc') should return NaN
|
||||
// const int = isNaN(Number(maxTokensStr)) ? undefined : parseInt(maxTokensStr)
|
||||
// if (Number.isNaN(int))
|
||||
// return undefined
|
||||
// return int
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
export const anthropicMaxPossibleTokens = (modelName: string) => {
|
||||
if (modelName === 'claude-3-5-sonnet-20241022'
|
||||
|| modelName === 'claude-3-5-haiku-20241022')
|
||||
return 8192
|
||||
if (modelName === 'claude-3-opus-20240229'
|
||||
|| modelName === 'claude-3-sonnet-20240229'
|
||||
|| modelName === 'claude-3-haiku-20240307')
|
||||
return 4096
|
||||
return 1024 // return a reasonably small number if they're using a different model
|
||||
}
|
||||
|
||||
|
||||
export const dummyModelData = {
|
||||
anthropic: ['claude 3.5'],
|
||||
openAI: ['gpt 4o'],
|
||||
ollama: ['llama 3.2', 'codestral'],
|
||||
openRouter: ['qwen 2.5'],
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -74,7 +151,6 @@ export type SettingsOfProvider = {
|
|||
&
|
||||
{
|
||||
enabled: string, // 'true' | 'false'
|
||||
maxTokens: string,
|
||||
|
||||
models: string[], // if null, user can type in any string as a model
|
||||
})
|
||||
|
|
@ -137,13 +213,6 @@ export const displayInfoOfSettingName = (providerName: ProviderName, settingName
|
|||
: '(never)',
|
||||
}
|
||||
}
|
||||
else if (settingName === 'maxTokens') {
|
||||
return {
|
||||
title: 'Max Tokens',
|
||||
type: 'number',
|
||||
placeholder: '1024',
|
||||
}
|
||||
}
|
||||
else if (settingName === 'enabled') {
|
||||
return {
|
||||
title: 'Enabled?',
|
||||
|
|
@ -170,43 +239,36 @@ export const defaultVoidProviderState: SettingsOfProvider = {
|
|||
...voidProviderDefaults.anthropic,
|
||||
...voidInitModelOptions.anthropic,
|
||||
enabled: 'false',
|
||||
maxTokens: '',
|
||||
},
|
||||
openAI: {
|
||||
...voidProviderDefaults.openAI,
|
||||
...voidInitModelOptions.openAI,
|
||||
enabled: 'false',
|
||||
maxTokens: '',
|
||||
},
|
||||
ollama: {
|
||||
...voidProviderDefaults.ollama,
|
||||
...voidInitModelOptions.ollama,
|
||||
enabled: 'false',
|
||||
maxTokens: '',
|
||||
},
|
||||
openRouter: {
|
||||
...voidProviderDefaults.openRouter,
|
||||
...voidInitModelOptions.openRouter,
|
||||
enabled: 'false',
|
||||
maxTokens: '',
|
||||
},
|
||||
openAICompatible: {
|
||||
...voidProviderDefaults.openAICompatible,
|
||||
...voidInitModelOptions.openAICompatible,
|
||||
enabled: 'false',
|
||||
maxTokens: '',
|
||||
},
|
||||
gemini: {
|
||||
...voidProviderDefaults.gemini,
|
||||
...voidInitModelOptions.gemini,
|
||||
enabled: 'false',
|
||||
maxTokens: '',
|
||||
},
|
||||
groq: {
|
||||
...voidProviderDefaults.groq,
|
||||
...voidInitModelOptions.groq,
|
||||
enabled: 'false',
|
||||
maxTokens: '',
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import Anthropic from '@anthropic-ai/sdk';
|
||||
import { parseMaxTokensStr } from './util.js';
|
||||
import { _InternalSendLLMMessageFnType } from '../../common/llmMessageTypes.js';
|
||||
import { displayInfoOfSettingName } from '../../common/voidConfigTypes.js';
|
||||
import { anthropicMaxPossibleTokens } from '../../common/voidConfigTypes.js';
|
||||
|
||||
// Anthropic
|
||||
type LLMMessageAnthropic = {
|
||||
|
|
@ -17,9 +16,9 @@ export const sendAnthropicMsg: _InternalSendLLMMessageFnType = ({ messages, onTe
|
|||
|
||||
const thisConfig = settingsOfProvider.anthropic
|
||||
|
||||
const maxTokens = parseMaxTokensStr(thisConfig.maxTokens)
|
||||
const maxTokens = anthropicMaxPossibleTokens(modelName)
|
||||
if (maxTokens === undefined) {
|
||||
onError({ message: `Please set a value for ${displayInfoOfSettingName('anthropic', 'maxTokens').title}.`, fullError: null })
|
||||
onError({ message: `Please set a value for Max Tokens.`, fullError: null })
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
import Groq from 'groq-sdk';
|
||||
import { _InternalSendLLMMessageFnType } from '../../common/llmMessageTypes.js';
|
||||
import { parseMaxTokensStr } from './util.js';
|
||||
|
||||
// Groq
|
||||
export const sendGroqMsg: _InternalSendLLMMessageFnType = async ({ messages, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter }) => {
|
||||
|
|
@ -24,7 +23,7 @@ export const sendGroqMsg: _InternalSendLLMMessageFnType = async ({ messages, onT
|
|||
model: modelName,
|
||||
stream: true,
|
||||
temperature: 0.7,
|
||||
max_tokens: parseMaxTokensStr(thisConfig.maxTokens),
|
||||
// max_tokens: parseMaxTokensStr(thisConfig.maxTokens),
|
||||
})
|
||||
.then(async response => {
|
||||
_setAborter(() => response.controller.abort())
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
import { Ollama } from 'ollama';
|
||||
import { _InternalOllamaListFnType, _InternalSendLLMMessageFnType, ModelResponse } from '../../common/llmMessageTypes.js';
|
||||
import { parseMaxTokensStr } from './util.js';
|
||||
|
||||
export const ollamaList: _InternalOllamaListFnType = async ({ onSuccess: onSuccess_, onError: onError_, settingsOfProvider }) => {
|
||||
|
||||
|
|
@ -49,7 +48,7 @@ export const sendOllamaMsg: _InternalSendLLMMessageFnType = ({ messages, onText,
|
|||
model: modelName,
|
||||
messages: messages,
|
||||
stream: true,
|
||||
options: { num_predict: parseMaxTokensStr(thisConfig.maxTokens) } // this is max_tokens
|
||||
// options: { num_predict: parseMaxTokensStr(thisConfig.maxTokens) } // this is max_tokens
|
||||
})
|
||||
.then(async stream => {
|
||||
_setAborter(() => stream.abort())
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import OpenAI from 'openai';
|
||||
import { _InternalSendLLMMessageFnType } from '../../common/llmMessageTypes.js';
|
||||
import { parseMaxTokensStr } from './util.js';
|
||||
// import { parseMaxTokensStr } from './util.js';
|
||||
|
||||
|
||||
// OpenAI, OpenRouter, OpenAICompatible
|
||||
|
|
@ -20,7 +20,7 @@ export const sendOpenAIMsg: _InternalSendLLMMessageFnType = ({ messages, onText,
|
|||
if (providerName === 'openAI') {
|
||||
const thisConfig = settingsOfProvider.openAI
|
||||
openai = new OpenAI({ apiKey: thisConfig.apiKey, dangerouslyAllowBrowser: true });
|
||||
options = { model: modelName, messages: messages, stream: true, max_completion_tokens: parseMaxTokensStr(thisConfig.maxTokens) }
|
||||
options = { model: modelName, messages: messages, stream: true, /*max_completion_tokens: parseMaxTokensStr(thisConfig.maxTokens)*/ }
|
||||
}
|
||||
else if (providerName === 'openRouter') {
|
||||
const thisConfig = settingsOfProvider.openRouter
|
||||
|
|
@ -31,12 +31,12 @@ export const sendOpenAIMsg: _InternalSendLLMMessageFnType = ({ messages, onText,
|
|||
'X-Title': 'Void Editor', // Optional. Shows in rankings on openrouter.ai.
|
||||
},
|
||||
});
|
||||
options = { model: modelName, messages: messages, stream: true, max_completion_tokens: parseMaxTokensStr(thisConfig.maxTokens) }
|
||||
options = { model: modelName, messages: messages, stream: true, /*max_completion_tokens: parseMaxTokensStr(thisConfig.maxTokens)*/ }
|
||||
}
|
||||
else if (providerName === 'openAICompatible') {
|
||||
const thisConfig = settingsOfProvider.openAICompatible
|
||||
openai = new OpenAI({ baseURL: thisConfig.endpoint, apiKey: thisConfig.apiKey, dangerouslyAllowBrowser: true })
|
||||
options = { model: modelName, messages: messages, stream: true, max_completion_tokens: parseMaxTokensStr(thisConfig.maxTokens) }
|
||||
options = { model: modelName, messages: messages, stream: true, /*max_completion_tokens: parseMaxTokensStr(thisConfig.maxTokens)*/ }
|
||||
}
|
||||
else {
|
||||
console.error(`sendOpenAIMsg: invalid providerName: ${providerName}`)
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Glass Devtools, Inc. All rights reserved.
|
||||
* Void Editor additions licensed under the AGPL 3.0 License.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export const parseMaxTokensStr = (maxTokensStr: string) => {
|
||||
// parse the string but only if the full string is a valid number, eg parseInt('100abc') should return NaN
|
||||
const int = isNaN(Number(maxTokensStr)) ? undefined : parseInt(maxTokensStr)
|
||||
if (Number.isNaN(int))
|
||||
return undefined
|
||||
return int
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { FeatureName, featureNames, ProviderName, providerNames } from '../../../../../../../platform/void/common/voidConfigTypes.js'
|
||||
import { dummyModelData } from '../../../../../../../platform/void/common/voidConfigModelDefaults.js'
|
||||
import { dummyModelData } from '../../../../../../../platform/void/common/voidConfigTypes.js'
|
||||
import { useConfigState, useRefreshModelState, useService } from '../util/services.js'
|
||||
import { VoidSelectBox } from '../sidebar-tsx/inputs.js'
|
||||
import { SelectBox } from '../../../../../../../base/browser/ui/selectBox/selectBox.js'
|
||||
|
|
|
|||
Loading…
Reference in a new issue