llm.ts

Overview

The llm.ts file defines TypeScript interfaces and types that model the data structures related to third-party large language models (LLMs), factories producing or managing these models, and the user's own LLM usage. This file primarily serves as a type definition module to ensure consistent and type-safe handling of LLM metadata and collections across the application.

It does not contain executable logic or functions but provides structured data contracts used throughout the system, particularly where LLM configurations, statuses, and usage metrics are involved.


Interfaces and Types

IThirdOAIModel

Represents the metadata and status information for a third-party OpenAI-compatible large language model.

Property

Type

Description

available

boolean

Indicates if the model is currently available for use.

create_date

string

Date when the model record was created (format typically YYYY-MM-DD).

create_time

number

Timestamp or numeric representation of creation time (likely Unix epoch or similar).

fid

string

A unique identifier (possibly a foreign ID) for the model.

id

number

Internal numeric identifier for the model.

llm_name

string

The name of the large language model.

max_tokens

number

Maximum number of tokens the model can process or generate in one request.

model_type

string

Type or category of the model (e.g., "GPT", "BERT", "Custom").

status

string

Current operational status of the model (e.g., "active", "deprecated").

tags

string

Comma-separated tags or keywords associated with the model.

update_date

string

Date when the model record was last updated.

update_time

number

Numeric timestamp of the last update time.

tenant_id?

string

(Optional) Identifier of the tenant or organization owning or using the model.

tenant_name?

string

(Optional) Name of the tenant or organization.

is_tools

boolean

Indicates whether the model supports tool integrations or additional capabilities.

Usage Example:

const model: IThirdOAIModel = {
  available: true,
  create_date: "2023-05-01",
  create_time: 1682899200,
  fid: "model-fid-123",
  id: 42,
  llm_name: "GPT-4",
  max_tokens: 8192,
  model_type: "GPT",
  status: "active",
  tags: "chat,completion",
  update_date: "2023-06-01",
  update_time: 1685596800,
  tenant_id: "tenant-001",
  tenant_name: "Acme Corp",
  is_tools: false,
};

IThirdOAIModelCollection

Type alias representing a collection of third-party LLM models grouped by a string key.

export type IThirdOAIModelCollection = Record<string, IThirdOAIModel[]>;

Usage Example:

const modelsByTenant: IThirdOAIModelCollection = {
  "tenant-001": [model1, model2],
  "tenant-002": [model3],
};

IFactory

Describes metadata about a factory or organization responsible for producing or managing LLM models.

Property

Type

Description

create_date

string

Factory record creation date (YYYY-MM-DD)

create_time

number

Numeric timestamp of factory record creation

logo

string

URL or path to the factory's logo image

name

string

Factory or organization name

status

string

Current status (e.g., "active", "inactive")

tags

string

Comma-separated tags associated with the factory

update_date

string

Date when the factory record was last updated

update_time

number

Numeric timestamp of the last update

Usage Example:

const factory: IFactory = {
  create_date: "2022-01-01",
  create_time: 1640995200,
  logo: "https://example.com/logo.png",
  name: "OpenAI Factory",
  status: "active",
  tags: "AI,LLM,OpenAI",
  update_date: "2023-06-01",
  update_time: 1685596800,
};

IMyLlmValue

Represents the user's personalized LLM data including a list of LLMs and associated tags.

Property

Type

Description

llm

Llm[]

Array of user's LLM usage or configurations

tags

string

Comma-separated tags or labels for the user's LLM data


Llm

Describes individual LLM usage or configuration by the user.

Property

Type

Description

name

string

Name of the LLM

type

string

Type or category of the LLM

used_token

number

Number of tokens used by the user with this LLM

Usage Example:

const myLlmValue: IMyLlmValue = {
  llm: [
    { name: "GPT-4", type: "GPT", used_token: 12000 },
    { name: "CustomAI", type: "Custom", used_token: 5000 }
  ],
  tags: "personal,default"
};

Implementation Details


Interaction with Other Parts of the System


Visual Diagram

classDiagram
    class IThirdOAIModel {
        +available: boolean
        +create_date: string
        +create_time: number
        +fid: string
        +id: number
        +llm_name: string
        +max_tokens: number
        +model_type: string
        +status: string
        +tags: string
        +update_date: string
        +update_time: number
        +tenant_id?: string
        +tenant_name?: string
        +is_tools: boolean
    }
    class IFactory {
        +create_date: string
        +create_time: number
        +logo: string
        +name: string
        +status: string
        +tags: string
        +update_date: string
        +update_time: number
    }
    class IMyLlmValue {
        +llm: Llm[]
        +tags: string
    }
    class Llm {
        +name: string
        +type: string
        +used_token: number
    }

    IMyLlmValue --> Llm : contains

Summary

The llm.ts file defines core TypeScript interfaces for representing third-party LLM models, factories managing those models, and user-specific LLM usage data. It provides a strongly typed foundation that ensures consistent handling of LLM metadata, status, and usage across the system, supporting multi-tenant environments and enabling clean integration with APIs and UI components.