Add NanoGPT as chat completions provider
| @@ -48,6 +48,7 @@ const API_MAKERSUITE = 'https://generativelanguage.googleapis.com'; | |||
| 48 | const API_01AI = 'https://api.01.ai/v1'; | 48 | const API_01AI = 'https://api.01.ai/v1'; |
| 49 | const API_BLOCKENTROPY = 'https://api.blockentropy.ai/v1'; | 49 | const API_BLOCKENTROPY = 'https://api.blockentropy.ai/v1'; |
| 50 | const API_AI21 = 'https://api.ai21.com/studio/v1'; | 50 | const API_AI21 = 'https://api.ai21.com/studio/v1'; |
| 51 | const API_NANOGPT = 'https://nano-gpt.com/api/v1'; | ||
| 51 | 52 | ||
| 52 | /** | 53 | /** |
| 53 | * Applies a post-processing step to the generated messages. | 54 | * Applies a post-processing step to the generated messages. |
| @@ -656,6 +657,10 @@ router.post('/status', jsonParser, async function (request, response_getstatus_o | |||
| 656 | api_url = API_BLOCKENTROPY; | 657 | api_url = API_BLOCKENTROPY; |
| 657 | api_key_openai = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY); | 658 | api_key_openai = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY); |
| 658 | headers = {}; | 659 | headers = {}; |
| 660 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.NANOGPT) { | ||
| 661 | api_url = API_NANOGPT; | ||
| 662 | api_key_openai = readSecret(request.user.directories, SECRET_KEYS.NANOGPT); | ||
| 663 | headers = {}; | ||
| 659 | } else { | 664 | } else { |
| 660 | console.log('This chat completion source is not supported yet.'); | 665 | console.log('This chat completion source is not supported yet.'); |
| 661 | return response_getstatus_openai.status(400).send({ error: true }); | 666 | return response_getstatus_openai.status(400).send({ error: true }); |
| @@ -906,6 +911,11 @@ router.post('/generate', jsonParser, function (request, response) { | |||
| 906 | apiKey = readSecret(request.user.directories, SECRET_KEYS.GROQ); | 911 | apiKey = readSecret(request.user.directories, SECRET_KEYS.GROQ); |
| 907 | headers = {}; | 912 | headers = {}; |
| 908 | bodyParams = {}; | 913 | bodyParams = {}; |
| 914 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.NANOGPT) { | ||
| 915 | apiUrl = API_NANOGPT; | ||
| 916 | apiKey = readSecret(request.user.directories, SECRET_KEYS.NANOGPT); | ||
| 917 | headers = {}; | ||
| 918 | bodyParams = {}; | ||
| 909 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.ZEROONEAI) { | 919 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.ZEROONEAI) { |
| 910 | apiUrl = API_01AI; | 920 | apiUrl = API_01AI; |
| 911 | apiKey = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI); | 921 | apiKey = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI); |
| @@ -48,6 +48,7 @@ export const SECRET_KEYS = { | |||
| 48 | BLOCKENTROPY: 'api_key_blockentropy', | 48 | BLOCKENTROPY: 'api_key_blockentropy', |
| 49 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', | 49 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', |
| 50 | TAVILY: 'api_key_tavily', | 50 | TAVILY: 'api_key_tavily', |
| 51 | NANOGPT: 'api_key_nanogpt', | ||
| 51 | }; | 52 | }; |
| 52 | 53 | ||
| 53 | // These are the keys that are safe to expose, even if allowKeysExposure is false | 54 | // These are the keys that are safe to expose, even if allowKeysExposure is false |