Class: Leuria
Defined in: packages/client/src/leuria.ts:141
Constructors
Constructor
new Leuria(
options):Leuria
Defined in: packages/client/src/leuria.ts:153
Parameters
options
Returns
Leuria
Properties
providers
readonlyproviders:Provider[]
Defined in: packages/client/src/leuria.ts:142
Methods
chat()
chat<
T>(request):ChatRun<T>
Defined in: packages/client/src/leuria.ts:289
One request. Iterate the run for events, or await .text() / .object().
Type Parameters
T
T = unknown
Parameters
request
ChatRequest<T>
Returns
ChatRun<T>
chooseInstead()
chooseInstead(
providerId):void
Defined in: packages/client/src/leuria.ts:240
The visitor picked this provider instead of their own AI (see
fallback). Kept for this page only: their own AI is proposed again
next time. A provider that needs a download is then downloaded with
connect(id), from the same click.
Parameters
providerId
string
Returns
void
closeAll()
closeAll():
void
Defined in: packages/client/src/leuria.ts:217
End every provider session (agents stop); histories are kept.
Returns
void
connect()
connect(
providerId?):Promise<void>
Defined in: packages/client/src/leuria.ts:273
Resolve the visitor action of a provider (default: the first one that needs one). Call from a click: it may open a window.
Parameters
providerId?
string
Returns
Promise<void>
conversation()
conversation<
T>(options?):Conversation<T>
Defined in: packages/client/src/leuria.ts:351
A multi-turn conversation that keeps its history and follows the cascade.
Type Parameters
T
T = unknown
Parameters
options?
ConversationOptions<T> = {}
Returns
Conversation<T>
decide()
decide<
Q>(state,questions,options?):Promise<DecideResponse<Q>>
Defined in: packages/client/src/leuria.ts:333
Answer typed questions about state (a choice, a score, a yes/no
probability) with the first ready provider that can: a System One
model, which decides without writing text, in well under a second.
The visitor's own service, through Leuria, with their key.
Type Parameters
Q
Q extends Record<string, DecideQuestion>
Parameters
state
unknown
questions
Q
options?
DecideOptions = {}
Returns
Promise<DecideResponse<Q>>
destroy()
destroy():
void
Defined in: packages/client/src/leuria.ts:391
Stop watching providers.
Returns
void
detect()
detect():
Promise<LeuriaState>
Defined in: packages/client/src/leuria.ts:229
Re-check every provider.
Returns
Promise<LeuriaState>
disconnect()
disconnect(
providerId?):void
Defined in: packages/client/src/leuria.ts:282
Forget the visitor's grants in this browser.
Parameters
providerId?
string
Returns
void
embed()
embed(
texts,options?):Promise<EmbedResponse>
Defined in: packages/client/src/leuria.ts:308
Embed texts with the first ready provider that can (the visitor's
own model through Leuria, then a model in the page…). Vectors from
different models can't be compared: keep model with them.
Parameters
texts
string[]
options?
EmbedOptions = {}
Returns
Promise<EmbedResponse>
getState()
getState():
LeuriaState
Defined in: packages/client/src/leuria.ts:221
Returns
on()
on(
listener): () =>void
Defined in: packages/client/src/leuria.ts:211
Every event of every conversation and chat, e.g. for tracing or evals.
Parameters
listener
(event) => void
Returns
() => void
select()
select(
requirements,routing?):Provider
Defined in: packages/client/src/leuria.ts:363
The provider that would serve a request with these needs, or a NoProviderError explaining why none can.
Parameters
requirements
routing?
RoutingOptions = {}
Returns
subscribe()
subscribe(
listener): () =>void
Defined in: packages/client/src/leuria.ts:223
Parameters
listener
() => void
Returns
() => void