mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +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', {
|
col_interfaces.set('puter-chat-completion', {
|
||||||
description: 'Chatbot.',
|
description: 'Chatbot.',
|
||||||
methods: {
|
methods: {
|
||||||
|
list: {
|
||||||
|
description: 'List supported models',
|
||||||
|
result: { type: 'json' },
|
||||||
|
parameters: {},
|
||||||
|
},
|
||||||
complete: {
|
complete: {
|
||||||
description: 'Get completions for a chat log.',
|
description: 'Get completions for a chat log.',
|
||||||
parameters: {
|
parameters: {
|
||||||
|
@ -26,6 +26,12 @@ class ClaudeService extends BaseService {
|
|||||||
|
|
||||||
static IMPLEMENTS = {
|
static IMPLEMENTS = {
|
||||||
['puter-chat-completion']: {
|
['puter-chat-completion']: {
|
||||||
|
async list () {
|
||||||
|
return [
|
||||||
|
'claude-3-5-sonnet-20240620',
|
||||||
|
'claude-3-haiku-20240307',
|
||||||
|
];
|
||||||
|
},
|
||||||
async complete ({ messages, stream, model }) {
|
async complete ({ messages, stream, model }) {
|
||||||
const adapted_messages = [];
|
const adapted_messages = [];
|
||||||
|
|
||||||
|
@ -23,6 +23,12 @@ class OpenAICompletionService extends BaseService {
|
|||||||
|
|
||||||
static IMPLEMENTS = {
|
static IMPLEMENTS = {
|
||||||
['puter-chat-completion']: {
|
['puter-chat-completion']: {
|
||||||
|
async list () {
|
||||||
|
return [
|
||||||
|
'gpt-4o',
|
||||||
|
'gpt-4o-mini',
|
||||||
|
];
|
||||||
|
},
|
||||||
async complete ({ messages, test_mode, stream, model }) {
|
async complete ({ messages, test_mode, stream, model }) {
|
||||||
if ( test_mode ) {
|
if ( test_mode ) {
|
||||||
const { LoremIpsum } = require('lorem-ipsum');
|
const { LoremIpsum } = require('lorem-ipsum');
|
||||||
|
@ -22,6 +22,14 @@ class TogetherAIService extends BaseService {
|
|||||||
|
|
||||||
static IMPLEMENTS = {
|
static IMPLEMENTS = {
|
||||||
['puter-chat-completion']: {
|
['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 }) {
|
async complete ({ messages, stream, model }) {
|
||||||
console.log('model?', model);
|
console.log('model?', model);
|
||||||
const completion = await this.together.chat.completions.create({
|
const completion = await this.together.chat.completions.create({
|
||||||
|
Loading…
Reference in New Issue
Block a user