From 4ded47c62e8e9dc53e7716d51d870a4db1e6c71d Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Mon, 24 Jun 2024 12:46:23 -0700 Subject: [PATCH] Rename classes in OpenAI models --- CHANGELOG.md | 4 ++++ src/models/openai/chat.ts | 10 +++++----- src/models/openai/embeddings.ts | 13 ++++++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41382f4..2bb4826 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## UNRELEASED + +- Rename classes in OpenAI models [#11](https://github.com/hypermodeAI/models-as/pull/11) + ## 2024-06-24 - Version 0.2.0 - Update OpenAI Embeddings model to support all allowed types of input [#6](https://github.com/hypermodeAI/models-as/pull/6) diff --git a/src/models/openai/chat.ts b/src/models/openai/chat.ts index d0c30bb..d330cb1 100644 --- a/src/models/openai/chat.ts +++ b/src/models/openai/chat.ts @@ -5,16 +5,16 @@ import { Model } from "../.."; * * Reference: https://platform.openai.com/docs/api-reference/chat */ -export class ChatModel extends Model { +export class OpenAIChatModel extends Model { /** * Creates an input object for the OpenAI Chat API. * * @param messages: An array of messages to send to the chat model. * @returns An input object that can be passed to the `invoke` method. */ - createInput(messages: Message[]): ChatInput { + createInput(messages: Message[]): OpenAIChatInput { const model = this.info.fullName; - return { model, messages }; + return { model, messages }; } } @@ -22,7 +22,7 @@ export class ChatModel extends Model { * The input object for the OpenAI Chat API. */ @json -class ChatInput { +class OpenAIChatInput { /** * The name of the model to use for the chat. * Must be the exact string expected by the model provider. @@ -234,7 +234,7 @@ export type ServiceTier = string; * The output object for the OpenAI Chat API. */ @json -class ChatOutput { +class OpenAIChatOutput { /** * A unique identifier for the chat completion. */ diff --git a/src/models/openai/embeddings.ts b/src/models/openai/embeddings.ts index 7cfc45f..8061c5b 100644 --- a/src/models/openai/embeddings.ts +++ b/src/models/openai/embeddings.ts @@ -5,7 +5,10 @@ import { Model } from "../.."; * * Reference: https://platform.openai.com/docs/api-reference/embeddings */ -export class EmbeddingsModel extends Model { +export class OpenAIEmbeddingsModel extends Model< + OpenAIEmbeddingsInput, + OpenAIEmbeddingsOutput +> { /** * Creates an input object for the OpenAI Embeddings API. * @@ -20,7 +23,7 @@ export class EmbeddingsModel extends Model { * @remarks * The input content must not exceed the maximum token limit of the model. */ - createInput(content: T): EmbeddingsInput { + createInput(content: T): OpenAIEmbeddingsInput { const model = this.info.fullName; switch (idof()) { @@ -53,7 +56,7 @@ export class EmbeddingsModel extends Model { * The input object for the OpenAI Embeddings API. */ @json -class EmbeddingsInput { +class OpenAIEmbeddingsInput { /** * The name of the model to use for the embeddings. * Must be the exact string expected by the model provider. @@ -97,7 +100,7 @@ class EmbeddingsInput { * The input object for the OpenAI Embeddings API. */ @json -class TypedEmbeddingsInput extends EmbeddingsInput { +class TypedEmbeddingsInput extends OpenAIEmbeddingsInput { /** * The input content to vectorize. */ @@ -108,7 +111,7 @@ class TypedEmbeddingsInput extends EmbeddingsInput { * The output object for the OpenAI Embeddings API. */ @json -class EmbeddingsOutput { +class OpenAIEmbeddingsOutput { /** * The name of the output object type returned by the API. * Always `"list"`.