Skip to content

Commit

Permalink
Merge pull request #2 from janhq/chore/add-start-model-api
Browse files Browse the repository at this point in the history
feat: add threads page and stop model
  • Loading branch information
louis-jan committed May 28, 2024
2 parents 1175b06 + cbd1ee0 commit ad978f7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@janhq/openai-node",
"name": "@janhq/cortex-node",
"version": "4.47.1",
"description": "Forked version of the OpenAI Node.js client library",
"author": "Jan <[email protected]>",
Expand Down
4 changes: 2 additions & 2 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ node scripts/utils/postprocess-files.cjs

# make sure that nothing crashes when we require the output CJS or
# import the output ESM
(cd dist && node -e 'require("openai")')
(cd dist && node -e 'import("openai")' --input-type=module)
# (cd dist && node -e 'require("@janhq/cortex-node")')
# (cd dist && node -e 'import("@janhq/cortex-node")' --input-type=module)

if command -v deno &> /dev/null && [ -e ./scripts/build-deno ]
then
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,4 @@ const API_KEY_SENTINEL = '<Missing Key>';
// ---------------------- End Azure ----------------------

export default OpenAI;
export { OpenAI as Cortex };
13 changes: 13 additions & 0 deletions src/resources/beta/threads/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import * as AssistantsAPI from '../assistants';
import * as MessagesAPI from './messages';
import * as RunsAPI from './runs/runs';
import { Stream } from '../../../streaming';
import { Page } from 'openai/pagination';

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

export class Threads extends APIResource {
runs: RunsAPI.Runs = new RunsAPI.Runs(this._client);
Expand All @@ -34,6 +40,13 @@ export class Threads extends APIResource {
});
}

/**
* Lists threads
*/
list(options?: Core.RequestOptions): Core.PagePromise<ThreadsPage, Thread> {
return this._client.getAPIList('/threads', ThreadsPage, options);
}

/**
* Retrieves a thread.
*/
Expand Down
13 changes: 10 additions & 3 deletions src/resources/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ export class Models extends APIResource {
return this._client.delete(`/models/${model}`, options);
}

/**
* Start a model instance, providing basic information about the model such as the
/**
* Start a model instance, providing basic information about the model
*/
start(model: string, options?: Core.RequestOptions): Core.APIPromise<Model> {
start(model: string, options?: Core.RequestOptions): Core.APIPromise<Model> {
return this._client.post(`/models/${model}/start`, options);
}

/**
* Stop a model instance, providing basic information about the model
*/
stop(model: string, options?: Core.RequestOptions): Core.APIPromise<Model> {
return this._client.post(`/models/${model}/stop`, options);
}
}

/**
Expand Down

0 comments on commit ad978f7

Please sign in to comment.