Aller au contenu principal

Class: Portkey

Unified language model interface

Implements

Constructors

constructor

new Portkey(init?)

Parameters

NameType
init?Partial<Portkey>

Defined in

packages/core/src/llm/LLM.ts:812

Properties

apiKey

Optional apiKey: string = undefined

Defined in

packages/core/src/llm/LLM.ts:805


baseURL

Optional baseURL: string = undefined

Defined in

packages/core/src/llm/LLM.ts:806


callbackManager

Optional callbackManager: CallbackManager

Defined in

packages/core/src/llm/LLM.ts:810


hasStreaming

hasStreaming: boolean = true

Implementation of

LLM.hasStreaming

Defined in

packages/core/src/llm/LLM.ts:803


llms

Optional llms: null | [LLMOptions] = undefined

Defined in

packages/core/src/llm/LLM.ts:808


mode

Optional mode: string = undefined

Defined in

packages/core/src/llm/LLM.ts:807


session

session: PortkeySession

Defined in

packages/core/src/llm/LLM.ts:809

Accessors

metadata

get metadata(): LLMMetadata

Returns

LLMMetadata

Implementation of

LLM.metadata

Defined in

packages/core/src/llm/LLM.ts:830

Methods

chat

chat<T, R>(messages, parentEvent?, streaming?, params?): Promise<R>

Get a chat response from the LLM

Type parameters

NameType
Textends undefined | boolean = undefined
RT extends true ? AsyncGenerator<string, void, unknown> : ChatResponse

Parameters

NameTypeDescription
messagesChatMessage[]The return type of chat() and complete() are set by the "streaming" parameter being set to True.
parentEvent?Event-
streaming?T-
params?Record<string, any>-

Returns

Promise<R>

Implementation of

LLM.chat

Defined in

packages/core/src/llm/LLM.ts:834


complete

complete<T, R>(prompt, parentEvent?, streaming?): Promise<R>

Get a prompt completion from the LLM

Type parameters

NameType
Textends undefined | boolean = undefined
RT extends true ? AsyncGenerator<string, void, unknown> : ChatResponse

Parameters

NameTypeDescription
promptstringthe prompt to complete
parentEvent?Event-
streaming?T-

Returns

Promise<R>

Implementation of

LLM.complete

Defined in

packages/core/src/llm/LLM.ts:858


streamChat

streamChat(messages, parentEvent?, params?): AsyncGenerator<string, void, unknown>

Parameters

NameType
messagesChatMessage[]
parentEvent?Event
params?Record<string, any>

Returns

AsyncGenerator<string, void, unknown>

Defined in

packages/core/src/llm/LLM.ts:873


streamComplete

streamComplete(query, parentEvent?): AsyncGenerator<string, void, unknown>

Parameters

NameType
querystring
parentEvent?Event

Returns

AsyncGenerator<string, void, unknown>

Defined in

packages/core/src/llm/LLM.ts:920


tokens

tokens(messages): number

Calculates the number of tokens needed for the given chat messages

Parameters

NameType
messagesChatMessage[]

Returns

number

Implementation of

LLM.tokens

Defined in

packages/core/src/llm/LLM.ts:826