NanoGPT: Add backend web search

f8f9ee8a0e9c2bd25387dbdf2a5f30576be8a604

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +4 -1Showing whitespace changes
public/index.html+1 -1
@@ -1970,7 +1970,7 @@
1970 </span>1970 </span>
1971 </div>1971 </div>
1972 </div>1972 </div>
1973 <div class="range-block" data-source="makersuite,vertexai,aimlapi,openrouter,claude,xai">1973 <div class="range-block" data-source="makersuite,vertexai,aimlapi,openrouter,claude,xai,nanogpt">
1974 <label for="openai_enable_web_search" class="checkbox_label flexWrap widthFreeExpand">1974 <label for="openai_enable_web_search" class="checkbox_label flexWrap widthFreeExpand">
1975 <input id="openai_enable_web_search" type="checkbox" />1975 <input id="openai_enable_web_search" type="checkbox" />
1976 <span data-i18n="Enable web search">Enable web search</span>1976 <span data-i18n="Enable web search">Enable web search</span>
src/endpoints/backends/chat-completions.js+3 -0
@@ -1641,6 +1641,9 @@ router.post('/generate', function (request, response) {
1641 apiKey = readSecret(request.user.directories, SECRET_KEYS.NANOGPT);1641 apiKey = readSecret(request.user.directories, SECRET_KEYS.NANOGPT);
1642 headers = {};1642 headers = {};
1643 bodyParams = {};1643 bodyParams = {};
1644 if (request.body.enable_web_search && !/:online$/.test(request.body.model)) {
1645 request.body.model = `${request.body.model}:online`;
1646 }
1644 } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.ZEROONEAI) {1647 } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.ZEROONEAI) {
1645 apiUrl = API_01AI;1648 apiUrl = API_01AI;
1646 apiKey = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI);1649 apiKey = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI);