Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
[feat/modelmanager] models added
Browse files Browse the repository at this point in the history
  • Loading branch information
toschoo committed Feb 19, 2024
1 parent cefc7b6 commit 33b5cc9
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 3 deletions.
4 changes: 1 addition & 3 deletions examples/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ const client = new Edgen();

async function main() {
// Non-streaming:
/*
const completion = await client.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Say this is a test' }],
messages: [{ role: 'user', content: 'What is the result of 1 + 2?' }],
});
console.log(completion.choices[0]?.message?.content);
*/

// Streaming:
const stream = await client.chat.completions.create({
Expand Down
43 changes: 43 additions & 0 deletions examples/models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env -S npm run tsn -T

import Edgen from 'edgen';

const client = new Edgen();

async function main() {
const models = await client.models.list();

console.log("Models Listing");
console.log("==============");
for await (const model of models) {
console.log("id : %s", model.id);
console.log("type : %s", model.object);
console.log("created: %s", model.created);
console.log("owner : %s", model.owned_by);
};

console.log("One Model");
console.log("=========");
try {
const model = await client.models.retrieve("TheFake%2fMy-fake-model-GGUF");
console.log("id : %s", model.id);
console.log("type : %s", model.object);
console.log("created: %s", model.created);
console.log("owner : %s", model.owned_by);
} catch (e) {
console.log("ERROR: %s", e)
}

console.log("Delete Model");
console.log("============");
try {
const model = await client.models.del("TheFake%2fMy-fake-model-GGUF");
console.log("id : %s", model.id);
console.log("type : %s", model.object);
console.log("deleted: %s", model.deleted);
} catch (e) {
console.log("ERROR: %s", e)
}
}

main();
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export class Edgen extends Core.APIClient {
completions: API.Completions = new API.Completions(this);
chat: API.Chat = new API.Chat(this);
audio: API.Audio = new API.Audio(this);
models: API.Models = new API.Models(this);
misc: API.Misc = new API.Misc(this);

protected override defaultQuery(): Core.DefaultQuery | undefined {
Expand Down
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export {
CompletionCreateParamsStreaming,
Completions,
} from './completions';
export { Model, ModelDeleted, ModelsPage, Models } from './models';
76 changes: 76 additions & 0 deletions src/resources/models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// File generated from our OpenAPI spec by Stainless.

import * as Core from 'edgen/core';
import { APIResource } from 'edgen/resource';
import * as ModelsAPI from 'edgen/resources/models';
import { Page } from 'edgen/pagination';

export class Models extends APIResource {
/**
* Retrieves a model instance, providing basic information about the model such as
* the owner and permissioning.
*/
retrieve(model: string, options?: Core.RequestOptions): Core.APIPromise<Model> {
return this._client.get(`/models/${model}`, options);
}

/**
* Lists the currently available models, and provides basic information about each
* one such as the owner and availability.
*/
list(options?: Core.RequestOptions): Core.PagePromise<ModelsPage, Model> {
return this._client.getAPIList('/models', ModelsPage, options);
}

/**
* Delete a fine-tuned model. You must have the Owner role in your organization to
* delete a model.
*/
del(model: string, options?: Core.RequestOptions): Core.APIPromise<ModelDeleted> {
return this._client.delete(`/models/${model}`, options);
}
}

/**
* Note: no pagination actually occurs yet, this is for forwards-compatibility.
*/
export class ModelsPage extends Page<Model> {}

/**
* Describes an OpenAI model offering that can be used with the API.
*/
export interface Model {
/**
* The model identifier, which can be referenced in the API endpoints.
*/
id: string;

/**
* The Unix timestamp (in seconds) when the model was created.
*/
created: number;

/**
* The object type, which is always "model".
*/
object: 'model';

/**
* The organization that owns the model.
*/
owned_by: string;
}

export interface ModelDeleted {
id: string;

deleted: boolean;

object: string;
}

export namespace Models {
export import Model = ModelsAPI.Model;
export import ModelDeleted = ModelsAPI.ModelDeleted;
export import ModelsPage = ModelsAPI.ModelsPage;
}

0 comments on commit 33b5cc9

Please sign in to comment.