mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 14:03:42 +00:00
feat: add method to list models
This commit is contained in:
parent
702618f81d
commit
fd86934bc9
@ -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: {
|
||||
|
@ -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 = [];
|
||||
|
||||
|
@ -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');
|
||||
|
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user