diff --git a/src/backend/src/modules/puterai/AIInterfaceService.js b/src/backend/src/modules/puterai/AIInterfaceService.js index 1abdbaf1..bd0d9083 100644 --- a/src/backend/src/modules/puterai/AIInterfaceService.js +++ b/src/backend/src/modules/puterai/AIInterfaceService.js @@ -28,6 +28,11 @@ class AIInterfaceService extends BaseService { col_interfaces.set('puter-chat-completion', { description: 'Chatbot.', methods: { + list: { + description: 'List supported models', + result: { type: 'json' }, + parameters: {}, + }, complete: { description: 'Get completions for a chat log.', parameters: { diff --git a/src/backend/src/modules/puterai/ClaudeService.js b/src/backend/src/modules/puterai/ClaudeService.js index 473ecd83..f171c466 100644 --- a/src/backend/src/modules/puterai/ClaudeService.js +++ b/src/backend/src/modules/puterai/ClaudeService.js @@ -26,6 +26,12 @@ class ClaudeService extends BaseService { static IMPLEMENTS = { ['puter-chat-completion']: { + async list () { + return [ + 'claude-3-5-sonnet-20240620', + 'claude-3-haiku-20240307', + ]; + }, async complete ({ messages, stream, model }) { const adapted_messages = []; diff --git a/src/backend/src/modules/puterai/OpenAICompletionService.js b/src/backend/src/modules/puterai/OpenAICompletionService.js index b280a10f..1de9d572 100644 --- a/src/backend/src/modules/puterai/OpenAICompletionService.js +++ b/src/backend/src/modules/puterai/OpenAICompletionService.js @@ -23,6 +23,12 @@ class OpenAICompletionService extends BaseService { static IMPLEMENTS = { ['puter-chat-completion']: { + async list () { + return [ + 'gpt-4o', + 'gpt-4o-mini', + ]; + }, async complete ({ messages, test_mode, stream, model }) { if ( test_mode ) { const { LoremIpsum } = require('lorem-ipsum'); diff --git a/src/backend/src/modules/puterai/TogetherAIService.js b/src/backend/src/modules/puterai/TogetherAIService.js index 851987ac..bf6b8c83 100644 --- a/src/backend/src/modules/puterai/TogetherAIService.js +++ b/src/backend/src/modules/puterai/TogetherAIService.js @@ -22,6 +22,14 @@ class TogetherAIService extends BaseService { static IMPLEMENTS = { ['puter-chat-completion']: { + async list () { + let models = this.modules.kv.get(`${this.kvkey}:models`); + if ( models ) return models; + models = await this.together.models.list(); + this.modules.kv.set( + `${this.kvkey}:models`, models, { EX: 5*60 }); + return models; + }, async complete ({ messages, stream, model }) { console.log('model?', model); const completion = await this.together.chat.completions.create({