Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## UNRELEASED

- Export all model interfaces classes [#37](https://github.com/hypermodeAI/models-as/pull/37)

## 2024-08-09 - Version 0.2.3

- Add support for Gemini models [#24](https://github.com/hypermodeAI/models-as/pull/24)
Expand Down
10 changes: 5 additions & 5 deletions src/models/anthropic/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AssistantMessage extends Message {
* The input object for the Anthropic Messages API.
*/
@json
class AnthropicMessagesInput {
export class AnthropicMessagesInput {
/**
* The model that will complete your prompt.
* Must be the exact string expected by the model provider.
Expand Down Expand Up @@ -258,7 +258,7 @@ export class Tool {


@json
class ToolChoice {
export class ToolChoice {
constructor(type: string, name: string | null = null) {
this._type = type;
this._name = name;
Expand Down Expand Up @@ -296,7 +296,7 @@ export const ToolChoiceTool = (name: string): ToolChoice =>
* The output object for the Anthropic Messages API.
*/
@json
class AnthropicMessagesOutput {
export class AnthropicMessagesOutput {
/**
* Unique object identifier.
*/
Expand Down Expand Up @@ -348,7 +348,7 @@ class AnthropicMessagesOutput {


@json
class ContentBlock {
export class ContentBlock {
type!: string;

// Text block
Expand All @@ -370,7 +370,7 @@ class ContentBlock {


@json
class Usage {
export class Usage {
/**
* The number of input tokens which were used.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/models/experimental/classification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ClassificationModel extends Model<
* An input object for the classification model.
*/
@json
class ClassificationInput {
export class ClassificationInput {
/**
* A list of one or more text strings of text to classify.
*/
Expand All @@ -37,7 +37,7 @@ class ClassificationInput {
* An output object for the classification model.
*/
@json
class ClassificationOutput {
export class ClassificationOutput {
/**
* A list of prediction results that correspond to each input text string.
*/
Expand Down Expand Up @@ -69,7 +69,7 @@ export class ClassifierResult {
* A classification label with its corresponding probability.
*/
@json
class ClassifierLabel {
export class ClassifierLabel {
/**
* The classification label.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/models/experimental/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class EmbeddingsModel extends Model<EmbeddingsInput, EmbeddingsOutput> {
* An input object for the embeddings model.
*/
@json
class EmbeddingsInput {
export class EmbeddingsInput {
/**
* A list of one or more text strings to create vector embeddings for.
*/
Expand All @@ -34,7 +34,7 @@ class EmbeddingsInput {
* An output object for the embeddings model.
*/
@json
class EmbeddingsOutput {
export class EmbeddingsOutput {
/**
* A list of vector embeddings that correspond to each input text string.
*/
Expand Down
20 changes: 10 additions & 10 deletions src/models/gemini/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class PromptContent {


@json
class Part {
export class Part {
text!: string;
}

Expand Down Expand Up @@ -141,7 +141,7 @@ export class ModelTextContent extends ModelContent {
* The input object for the Gemini Generate Content API.
*/
@json
class GeminiGenerateInput {
export class GeminiGenerateInput {
/**
* The content of the current conversation with the model.
*/
Expand Down Expand Up @@ -257,7 +257,7 @@ export class GenerationConfig {
* Safety setting, affecting the safety-blocking behavior.
*/
@json
class SafetySetting {
export class SafetySetting {
category!: HarmCategory;
threshold!: HarmBlockThreshold;
}
Expand Down Expand Up @@ -312,7 +312,7 @@ export type HarmBlockThreshold = string;
* The output object for the Gemini Generate Content API.
*/
@json
class GeminiGenerateOutput {
export class GeminiGenerateOutput {
/**
* Candidate responses from the model.
*/
Expand All @@ -334,7 +334,7 @@ class GeminiGenerateOutput {
*
*/
@json
class Candidate {
export class Candidate {
/**
* Index of the candidate in the list of candidates.
*/
Expand Down Expand Up @@ -425,7 +425,7 @@ export type FinishReason = string;
* Safety setting, affecting the safety-blocking behavior.
*/
@json
class SafetyRating {
export class SafetyRating {
category!: HarmCategory;
probability!: HarmProbability;
}
Expand Down Expand Up @@ -466,15 +466,15 @@ export type HarmProbability = string;
* Citation metadata that may be found on a {@link Candidate}.
*/
@json
class CitationMetadata {
export class CitationMetadata {
citationSources!: CitationSource[];
}

/**
* A single citation source.
*/
@json
class CitationSource {
export class CitationSource {
/**
* Start of segment of the response that is attributed to this source.
*/
Expand Down Expand Up @@ -505,7 +505,7 @@ class CitationSource {
* @public
*/
@json
class PromptFeedback {
export class PromptFeedback {
blockReason!: BlockReason;
safetyRatings!: SafetyRating[];
}
Expand Down Expand Up @@ -536,7 +536,7 @@ export type BlockReason = string;
* Metadata on the generation request's token usage.
*/
@json
class UsageMetadata {
export class UsageMetadata {
/**
* Number of tokens in the prompt.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/models/meta/llama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class TextGenerationModel extends Model<


@json
class TextGenerationInput {
export class TextGenerationInput {
/**
* The prompt text to pass to the model.
* May contain special tokens to control the behavior of the model.
Expand Down Expand Up @@ -58,7 +58,7 @@ class TextGenerationInput {


@json
class TextGenerationOutput {
export class TextGenerationOutput {
/**
* The generated text.
*/
Expand Down
20 changes: 10 additions & 10 deletions src/models/openai/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class OpenAIChatModel extends Model<OpenAIChatInput, OpenAIChatOutput> {
* The input object for the OpenAI Chat API.
*/
@json
class OpenAIChatInput {
export class OpenAIChatInput {
/**
* The name of the model to use for the chat.
* Must be the exact string expected by the model provider.
Expand Down Expand Up @@ -238,7 +238,7 @@ export type ServiceTier = string;
* The output object for the OpenAI Chat API.
*/
@json
class OpenAIChatOutput {
export class OpenAIChatOutput {
/**
* A unique identifier for the chat completion.
*/
Expand Down Expand Up @@ -317,7 +317,7 @@ export class ResponseFormat {
* Additionally, if you need an array you must ask for an object that wraps the array,
* because the model will not reliably produce arrays directly (ie., there is no `json_array` option).
*/
static Json: ResponseFormat = { type: "json_object" };
static Json: ResponseFormat = { type: "json_object", jsonSchema: null };

/**
* Enables Structured Outputs which guarantees the model will match your supplied JSON schema.
Expand All @@ -339,7 +339,7 @@ export class ResponseFormat {
* @remarks
* This is the default response format.
*/
static Text: ResponseFormat = { type: "text" };
static Text: ResponseFormat = { type: "text", jsonSchema: null };
}

// @json
Expand Down Expand Up @@ -459,7 +459,7 @@ export class FunctionCall {
* The usage statistics for the request.
*/
@json
class Usage {
export class Usage {
/**
* The number of completion tokens used in the response.
*/
Expand All @@ -483,7 +483,7 @@ class Usage {
* A completion choice object returned in the response.
*/
@json
class Choice {
export class Choice {
/**
* The reason the model stopped generating tokens.
*
Expand Down Expand Up @@ -516,7 +516,7 @@ class Choice {
* Log probability information for a choice.
*/
@json
class Logprobs {
export class Logprobs {
/**
* A list of message content tokens with log probability information.
*/
Expand All @@ -527,7 +527,7 @@ class Logprobs {
* Log probability information for a message content token.
*/
@json
class LogprobsContent {
export class LogprobsContent {
/**
* The token.
*/
Expand Down Expand Up @@ -560,7 +560,7 @@ class LogprobsContent {
* Log probability information for the most likely tokens at a given position.
*/
@json
class TopLogprobsContent {
export class TopLogprobsContent {
/**
* The token.
*/
Expand Down Expand Up @@ -713,7 +713,7 @@ export class ToolMessage extends Message {
* A chat completion message generated by the model.
*/
@json
class CompletionMessage extends Message {
export class CompletionMessage extends Message {
/**
* Creates a new completion message object.
*
Expand Down
14 changes: 9 additions & 5 deletions src/models/openai/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class OpenAIEmbeddingsModel extends Model<
* The input object for the OpenAI Embeddings API.
*/
@json
class OpenAIEmbeddingsInput {
export class OpenAIEmbeddingsInput {
/**
* The name of the model to use for the embeddings.
* Must be the exact string expected by the model provider.
Expand Down Expand Up @@ -100,7 +100,7 @@ class OpenAIEmbeddingsInput {
* The input object for the OpenAI Embeddings API.
*/
@json
class TypedEmbeddingsInput<T> extends OpenAIEmbeddingsInput {
export class TypedEmbeddingsInput<T> extends OpenAIEmbeddingsInput {
/**
* The input content to vectorize.
*/
Expand All @@ -111,7 +111,7 @@ class TypedEmbeddingsInput<T> extends OpenAIEmbeddingsInput {
* The output object for the OpenAI Embeddings API.
*/
@json
class OpenAIEmbeddingsOutput {
export class OpenAIEmbeddingsOutput {
/**
* The name of the output object type returned by the API.
* Always `"list"`.
Expand Down Expand Up @@ -160,7 +160,7 @@ export type EncodingFormat = string;
* The output vector embeddings data.
*/
@json
class Embedding {
export class Embedding {
/**
* The name of the output object type returned by the API.
* Always `"embedding"`.
Expand All @@ -172,14 +172,18 @@ class Embedding {
* Used when requesting embeddings for multiple texts.
*/
index!: i32;

/**
* The vector embedding of the input text.
*/
embedding!: f32[]; // TODO: support `f32[] | string` based on input encoding format
}

/**
* The usage statistics for the request.
*/
@json
class Usage {
export class Usage {
/**
* The number of prompt tokens used in the request.
*/
Expand Down
Loading