NanoGPT: Expose additional samplers
| @@ -732,7 +732,7 @@ | ||
| 732 | 732 | </div> |
| 733 | 733 | </div> |
| 734 | 734 | </div> |
| 735 | 735 | <div class="range-block" data-source="claude,aimlapi,openrouter,makersuite,vertexai,cohere,perplexity,electronhub,nanogpt"> |
| 736 | 736 | <div class="range-block-title" data-i18n="Top K"> |
| 737 | 737 | Top K |
| 738 | 738 | </div> |
| @@ -758,7 +758,7 @@ | ||
| 758 | 758 | </div> |
| 759 | 759 | </div> |
| 760 | 760 | </div> |
| 761 | 761 | <div class="range-block" data-source="openrouter,nanogpt"> |
| 762 | 762 | <div class="range-block-title" data-i18n="Repetition Penalty"> |
| 763 | 763 | Repetition Penalty |
| 764 | 764 | </div> |
| @@ -771,7 +771,7 @@ | ||
| 771 | 771 | </div> |
| 772 | 772 | </div> |
| 773 | 773 | </div> |
| 774 | 774 | <div class="range-block" data-source="openrouter,nanogpt"> |
| 775 | 775 | <div class="range-block-title" data-i18n="Min P"> |
| 776 | 776 | Min P |
| 777 | 777 | </div> |
| @@ -784,7 +784,7 @@ | ||
| 784 | 784 | </div> |
| 785 | 785 | </div> |
| 786 | 786 | </div> |
| 787 | 787 | <div class="range-block" data-source="openrouter,nanogpt"> |
| 788 | 788 | <div class="range-block-title" data-i18n="Top A"> |
| 789 | 789 | Top A |
| 790 | 790 | </div> |
| @@ -2290,6 +2290,7 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } = | ||
| 2290 | 2290 | const isMoonshot = oai_settings.chat_completion_source == chat_completion_sources.MOONSHOT; |
| 2291 | 2291 | const isAzureOpenAI = oai_settings.chat_completion_source == chat_completion_sources.AZURE_OPENAI; |
| 2292 | 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 | 2294 | const isTextCompletion = isOAI && textCompletionModels.includes(oai_settings.openai_model); |
| 2294 | 2295 | const isQuiet = type === 'quiet'; |
| 2295 | 2296 | const isImpersonate = type === 'impersonate'; |
| @@ -2499,6 +2500,14 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } = | ||
| 2499 | 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 | 2511 | const seedSupportedSources = [ |
| 2503 | 2512 | chat_completion_sources.OPENAI, |
| 2504 | 2513 | chat_completion_sources.AZURE_OPENAI, |
| @@ -1933,6 +1933,15 @@ router.post('/generate', function (request, response) { | ||
| 1933 | 1933 | if (request.body.enable_web_search && !/:online$/.test(request.body.model)) { |
| 1934 | 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 | 1945 | const enableSystemPromptCache = getConfigValue('claude.enableSystemPromptCache', false, 'boolean'); |
| 1937 | 1946 | const isClaude3or4 = /claude-(3|opus-4|sonnet-4)/.test(request.body.model); |
| 1938 | 1947 | const cacheTTL = getConfigValue('claude.extendedTTL', false, 'boolean') ? '1h' : '5m'; |