Class: Portkey
Unified language model interface
Implements
Constructors
constructor
• new Portkey(init?
)
Parameters
Name | Type |
---|---|
init? | Partial <Portkey > |
Defined in
packages/core/src/llm/LLM.ts:814
Properties
apiKey
• Optional
apiKey: string
= undefined
Defined in
packages/core/src/llm/LLM.ts:807
baseURL
• Optional
baseURL: string
= undefined
Defined in
packages/core/src/llm/LLM.ts:808
callbackManager
• Optional
callbackManager: CallbackManager
Defined in
packages/core/src/llm/LLM.ts:812
hasStreaming
• hasStreaming: boolean
= true
Implementation of
Defined in
packages/core/src/llm/LLM.ts:805
llms
• Optional
llms: null
| [LLMOptions
] = undefined
Defined in
packages/core/src/llm/LLM.ts:810
mode
• Optional
mode: string
= undefined
Defined in
packages/core/src/llm/LLM.ts:809
session
• session: PortkeySession
Defined in
packages/core/src/llm/LLM.ts:811
Accessors
metadata
• get
metadata(): LLMMetadata
Returns
Implementation of
Defined in
packages/core/src/llm/LLM.ts:832
Methods
chat
▸ chat<T
, R
>(messages
, parentEvent?
, streaming?
, params?
): Promise
<R
>
Get a chat response from the LLM
Type parameters
Name | Type |
---|---|
T | extends undefined | boolean = undefined |
R | T extends true ? AsyncGenerator <string , void , unknown > : ChatResponse |
Parameters
Name | Type | Description |
---|---|---|
messages | ChatMessage [] | 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
Defined in
packages/core/src/llm/LLM.ts:836
complete
▸ complete<T
, R
>(prompt
, parentEvent?
, streaming?
): Promise
<R
>
Get a prompt completion from the LLM
Type parameters
Name | Type |
---|---|
T | extends undefined | boolean = undefined |
R | T extends true ? AsyncGenerator <string , void , unknown > : ChatResponse |
Parameters
Name | Type | Description |
---|---|---|
prompt | string | the prompt to complete |
parentEvent? | Event | - |
streaming? | T | - |
Returns
Promise
<R
>
Implementation of
Defined in
packages/core/src/llm/LLM.ts:860
streamChat
▸ streamChat(messages
, parentEvent?
, params?
): AsyncGenerator
<string
, void
, unknown
>
Parameters
Name | Type |
---|---|
messages | ChatMessage [] |
parentEvent? | Event |
params? | Record <string , any > |
Returns
AsyncGenerator
<string
, void
, unknown
>
Defined in
packages/core/src/llm/LLM.ts:875
streamComplete
▸ streamComplete(query
, parentEvent?
): AsyncGenerator
<string
, void
, unknown
>
Parameters
Name | Type |
---|---|
query | string |
parentEvent? | Event |
Returns
AsyncGenerator
<string
, void
, unknown
>
Defined in
packages/core/src/llm/LLM.ts:922
tokens
▸ tokens(messages
): number
Calculates the number of tokens needed for the given chat messages
Parameters
Name | Type |
---|---|
messages | ChatMessage [] |
Returns
number