NanoGPT: Expose additional samplers
| @@ -732,7 +732,7 @@ | |||
| 732 | </div> | 732 | </div> |
| 733 | </div> | 733 | </div> |
| 734 | </div> | 734 | </div> |
| 735 | <div class="range-block" data-source="claude,aimlapi,openrouter,makersuite,vertexai,cohere,perplexity,electronhub"> | 735 | <div class="range-block" data-source="claude,aimlapi,openrouter,makersuite,vertexai,cohere,perplexity,electronhub,nanogpt"> |
| 736 | <div class="range-block-title" data-i18n="Top K"> | 736 | <div class="range-block-title" data-i18n="Top K"> |
| 737 | Top K | 737 | Top K |
| 738 | </div> | 738 | </div> |
| @@ -758,7 +758,7 @@ | |||
| 758 | </div> | 758 | </div> |
| 759 | </div> | 759 | </div> |
| 760 | </div> | 760 | </div> |
| 761 | <div class="range-block" data-source="openrouter"> | 761 | <div class="range-block" data-source="openrouter,nanogpt"> |
| 762 | <div class="range-block-title" data-i18n="Repetition Penalty"> | 762 | <div class="range-block-title" data-i18n="Repetition Penalty"> |
| 763 | Repetition Penalty | 763 | Repetition Penalty |
| 764 | </div> | 764 | </div> |
| @@ -771,7 +771,7 @@ | |||
| 771 | </div> | 771 | </div> |
| 772 | </div> | 772 | </div> |
| 773 | </div> | 773 | </div> |
| 774 | <div class="range-block" data-source="openrouter"> | 774 | <div class="range-block" data-source="openrouter,nanogpt"> |
| 775 | <div class="range-block-title" data-i18n="Min P"> | 775 | <div class="range-block-title" data-i18n="Min P"> |
| 776 | Min P | 776 | Min P |
| 777 | </div> | 777 | </div> |
| @@ -784,7 +784,7 @@ | |||
| 784 | </div> | 784 | </div> |
| 785 | </div> | 785 | </div> |
| 786 | </div> | 786 | </div> |
| 787 | <div class="range-block" data-source="openrouter"> | 787 | <div class="range-block" data-source="openrouter,nanogpt"> |
| 788 | <div class="range-block-title" data-i18n="Top A"> | 788 | <div class="range-block-title" data-i18n="Top A"> |
| 789 | Top A | 789 | Top A |
| 790 | </div> | 790 | </div> |
| @@ -2290,6 +2290,7 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } = | |||
| 2290 | const isMoonshot = oai_settings.chat_completion_source == chat_completion_sources.MOONSHOT; | 2290 | const isMoonshot = oai_settings.chat_completion_source == chat_completion_sources.MOONSHOT; |
| 2291 | const isAzureOpenAI = oai_settings.chat_completion_source == chat_completion_sources.AZURE_OPENAI; | 2291 | const isAzureOpenAI = oai_settings.chat_completion_source == chat_completion_sources.AZURE_OPENAI; |
| 2292 | const isZai = oai_settings.chat_completion_source == chat_completion_sources.ZAI; | 2292 | const isZai = oai_settings.chat_completion_source == chat_completion_sources.ZAI; |
| 2293 | const isNanoGPT = oai_settings.chat_completion_source == chat_completion_sources.NANOGPT; | ||
| 2293 | const isTextCompletion = isOAI && textCompletionModels.includes(oai_settings.openai_model); | 2294 | const isTextCompletion = isOAI && textCompletionModels.includes(oai_settings.openai_model); |
| 2294 | const isQuiet = type === 'quiet'; | 2295 | const isQuiet = type === 'quiet'; |
| 2295 | const isImpersonate = type === 'impersonate'; | 2296 | const isImpersonate = type === 'impersonate'; |
| @@ -2499,6 +2500,14 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } = | |||
| 2499 | delete generate_data.frequency_penalty; | 2500 | delete generate_data.frequency_penalty; |
| 2500 | } | 2501 | } |
| 2501 | 2502 | ||
| 2503 | // https://docs.nano-gpt.com/api-reference/endpoint/chat-completion#temperature-&-nucleus | ||
| 2504 | if (isNanoGPT) { | ||
| 2505 | generate_data['top_k'] = Number(oai_settings.top_k_openai); | ||
| 2506 | generate_data['min_p'] = Number(oai_settings.min_p_openai); | ||
| 2507 | generate_data['repetition_penalty'] = Number(oai_settings.repetition_penalty_openai); | ||
| 2508 | generate_data['top_a'] = Number(oai_settings.top_a_openai); | ||
| 2509 | } | ||
| 2510 | |||
| 2502 | const seedSupportedSources = [ | 2511 | const seedSupportedSources = [ |
| 2503 | chat_completion_sources.OPENAI, | 2512 | chat_completion_sources.OPENAI, |
| 2504 | chat_completion_sources.AZURE_OPENAI, | 2513 | chat_completion_sources.AZURE_OPENAI, |
| @@ -1933,6 +1933,15 @@ router.post('/generate', function (request, response) { | |||
| 1933 | if (request.body.enable_web_search && !/:online$/.test(request.body.model)) { | 1933 | if (request.body.enable_web_search && !/:online$/.test(request.body.model)) { |
| 1934 | request.body.model = `${request.body.model}:online`; | 1934 | request.body.model = `${request.body.model}:online`; |
| 1935 | } | 1935 | } |
| 1936 | if (request.body.min_p !== undefined) { | ||
| 1937 | bodyParams['min_p'] = request.body.min_p; | ||
| 1938 | } | ||
| 1939 | if (request.body.top_a !== undefined) { | ||
| 1940 | bodyParams['top_a'] = request.body.top_a; | ||
| 1941 | } | ||
| 1942 | if (request.body.repetition_penalty !== undefined) { | ||
| 1943 | bodyParams['repetition_penalty'] = request.body.repetition_penalty; | ||
| 1944 | } | ||
| 1936 | const enableSystemPromptCache = getConfigValue('claude.enableSystemPromptCache', false, 'boolean'); | 1945 | const enableSystemPromptCache = getConfigValue('claude.enableSystemPromptCache', false, 'boolean'); |
| 1937 | const isClaude3or4 = /claude-(3|opus-4|sonnet-4)/.test(request.body.model); | 1946 | const isClaude3or4 = /claude-(3|opus-4|sonnet-4)/.test(request.body.model); |
| 1938 | const cacheTTL = getConfigValue('claude.extendedTTL', false, 'boolean') ? '1h' : '5m'; | 1947 | const cacheTTL = getConfigValue('claude.extendedTTL', false, 'boolean') ? '1h' : '5m'; |