Passer au contenu principal
weave / WeaveClient

Table des matières

Constructeurs

Propriétés

Méthodes

Constructeurs

constructeur

new WeaveClient(«destructured»): WeaveClient

Paramètres

NomType
«destructured»objet
› projectIdstring
› settings?Partial<Settings>
› traceServerApiApi<any>

Renvoie

WeaveClient

Défini dans

src/weaveClient.ts:459

Propriétés

projectId

projectId: string

Défini dans

src/weaveClient.ts:456

settings

settings: Settings

Défini dans

src/weaveClient.ts:457

traceServerApi

traceServerApi: Api<any>

Défini dans

src/weaveClient.ts:455

Méthodes

addScore

addScore(predictCallId, scorerCallId, runnableRefUri, scorerOutput): Promise<string> Ajoute un résultat de scorer (par ex. la sortie du scorer) à un appel. Utilisé dans l’évaluation impérative pour associer les résultats du scorer aux appels de prédiction.

Paramètres

NomTypeDescription
predictCallIdstringID de l’appel predict auquel associer le retour
scorerCallIdstringID de l’appel du scorer ayant généré le retour
runnableRefUristringURI du scorer (op ou réf. d’objet)
scorerOutputanyRésultat du scorer

Renvoie

Promise<string>

Défini dans

src/weaveClient.ts:1727

createCall

createCall(internalCall, opRef, params, parameterNames, thisArg, currentCall, parentCall, startTime, displayName?, attributes?): Promise<void>

Paramètres

NomType
internalCallInternalCall
opRefany
paramsany[]
parameterNamesParameterNamesOption
thisArgany
currentCallCallStackEntry
parentCallundefinedCallStackEntry
startTimeDate
displayName?string
attributes?Record<string, any>

Renvoie

Promise<void>

Défini dans

src/weaveClient.ts:1570

finishCall

finishCall(call, result, currentCall, parentCall, summarize, endTime, startCallPromise): Promise<void>

Paramètres

NomType
callInternalCall
resultany
currentCallCallStackEntry
parentCallundefinedCallStackEntry
summarizeundefined(result: any) => Record<string, any>
endTimeDate
startCallPromisePromise<void>

Renvoie

Promise<void>

Défini dans

src/weaveClient.ts:1630

finishCallWithException

finishCallWithException(call, error, currentCall, parentCall, endTime, startCallPromise): Promise<void>

Paramètres

NomType
callInternalCall
errorany
currentCallCallStackEntry
parentCallundefinedCallStackEntry
endTimeDate
startCallPromisePromise<void>

Renvoie

Promise<void>

Défini dans

src/weaveClient.ts:1672

get

get(ref): Promise<any>

Paramètres

NomType
refObjectRef

Renvoie

Promise<any>

Défini dans

src/weaveClient.ts:1025

getAgentCustomAttributes

getAgentCustomAttributes(options): Promise<Réponse<GetAgentCustomAttributesResult>> Découvrez les clés d’attributs personnalisés typés observées sur les spans d’agent dans le projet. Chaque ligne de résultat correspond à un triplet (source, key, value_type), ainsi qu’au nombre de spans qui le portent ; c’est ce qu’utilisent les API de requête/groupe/stats des spans pour référencer les attributs personnalisés. Filtrez les spans pris en compte en transmettant query (un filtre de span structuré), startedAfter / startedBefore (ISO-8601), ou les deux. Utilisez limit / offset pour parcourir les clés découvertes par pages.

Paramètres

NomType
optionsGetAgentCustomAttributesOptions

Renvoie

Promise<Réponse<GetAgentCustomAttributesResult>> Exemple
const  = await weave.init('entity/project');
const  = await .getAgentCustomAttributes({
  : {
    : {
      : [{: 'agent_name'}, {: 'my-agent'}],
    },
  },
  : '2026-06-15T00:00:00Z',
  : 200,
});

for (const  of .data.attributes ?? []) {
  .(`${.source}.${.key} (${.value_type}): ${.span_count}`);
}

Défini dans

src/weaveClient.ts:772

getAgentSpanStats

getAgentSpanStats(options): Promise<Réponse<GetAgentSpanStatsResult>> Agrégations sur les spans d’agent dans le projet, renvoyées sous forme de lignes + métadonnées de colonne adaptées aux visualisations de séries chronologiques / en buckets. start (requis) et end définissent la fenêtre temporelle. Chaque entrée de metrics déclare un champ à extraire et la façon de l’agréger (sum, avg, count, percentiles, etc.). Transmettez granularity (secondes) pour regrouper les lignes par bucket temporel, ou groupBy pour ventiler les résultats par agent / provider / model / etc. query filtre les spans correspondants avant l’agrégation.

Paramètres

NomType
optionsGetAgentSpanStatsOptions

Renvoie

Promise<Réponse<GetAgentSpanStatsResult>> Exemple
const  = await weave.init('entity/project');
const  = await .getAgentSpanStats({
  : '2026-06-10T00:00:00Z',
  : '2026-06-23T00:00:00Z',
  : 86400, // une ligne par jour
  : [
    {
      : 'total_input_tokens',
      : 'number',
      : ['sum'],
      : {: 'field', : 'input_tokens'},
    },
  ],
  : [{: 'agent_name'}],
});

for (const  of .data.rows ?? []) {
  .(.started_at_bucket, .agent_name, .total_input_tokens);
}

Défini dans

src/weaveClient.ts:621

getAgentSpans

getAgentSpans(options): Promise<Réponse<GetAgentSpansResult>> Interroge les spans des agents, avec un filtrage facultatif par nom d’agent et/ou via une expression de requête de type Mongo.

Paramètres

NomType
optionsGetAgentSpansOptions

Renvoie

Promise<Réponse<GetAgentSpansResult>> Exemple
const  = await weave.init('entity/project');
const  = await .getAgentSpans({: 'my-agent', : 20});

for (const  of .data.spans) {
  .(.span_id, .span_name, .input_tokens);
}
Exemple
const  = await weave.init('entity/project');

const  = await .getAgentSpans({
  : 'my-agent',
  : {
    : {: [{: 'input_tokens'}, {: 1000}]},
  },
});

for (const  of .data.spans) {
  .(.span_id, .span_name, .input_tokens);
}

Défini dans

src/weaveClient.ts:566

getAgentTurn

getAgentTurn(options): Promise<Réponse<AgentTraceChatRes>> Obtenez les données (y compris les messages) d’un seul tour de conversation (par traceId).

Paramètres

NomType
optionsGetAgentTurnOptions

Renvoie

Promise<Réponse<AgentTraceChatRes>> Exemple
const  = await weave.init('entity/project');
const  = await .getAgentTurn({
  : '01997b8a-2c89-7c4d-9d0e-2f7e5b9a1b2c',
  : true,
});

.(.data.root_span_name, .data.total_duration_ms);

for (const  of .data.messages ?? []) {
  if (.user_message) .('user:', .user_message);
  if (.assistant_message) .('assistant:', .assistant_message);
}

Défini dans

src/weaveClient.ts:655

getAgentTurns

getAgentTurns(options): Promise<Réponse<GetAgentTurnsResult>> Obtenir les données (y compris les messages) de plusieurs tours de conversation (par conversationId).

Paramètres

NomType
optionsGetAgentTurnsOptions

Renvoie

Promise<Réponse<GetAgentTurnsResult>> Exemple
const  = await weave.init('entity/project');
const  = await .getAgentTurns({
  : 'trace_c50312356de3487fa90e381c9399b5b4',
  : 20,
  : true,
});

for (const  of .data.turns ?? []) {
  .(.trace_id, .root_span_name);
  for (const  of .messages ?? []) {
    if (.user_message) .('user:', .user_message);
    if (.assistant_message) .('assistant:', .assistant_message);
  }
}

.(`total turns: ${.data.total_turns}, has more: ${.data.has_more}`);

Défini dans

src/weaveClient.ts:688

getAgentVersions

getAgentVersions(options): Promise<Réponse<GetAgentVersionsResult>> Répertorie les versions d’un agent donné.

Paramètres

Renvoie

Promise<Réponse<GetAgentVersionsResult>> Exemple
const  = await weave.init('entity/project');
const  = await .getAgentVersions({: 'my-agent', : 20});

for (const  of .data.versions) {
  .(.agent_version, .total_input_tokens);
}

.(`total count: ${.data.total_count}`)

Défini dans

src/weaveClient.ts:522

getAgents

getAgents(options?): Promise<Réponse<GetAgentsResult>> Renvoie la liste des agents avec des statistiques agrégées.

Paramètres

NomType
optionsGetAgentsOptions

Renvoie

Promise<Réponse<GetAgentsResult>> Exemple
const  = await weave.init('entity/project');
const  = await .getAgents({: 20});

for (const  of .data.agents) {
  .(.agent_name, .total_input_tokens);
}

.(`total count: ${.data.total_count}`)

Défini dans

src/weaveClient.ts:488

getCall

getCall(callId, includeCosts?): Promise<Appel>

Paramètres

NomTypeValeur par défaut
callIdstringundefined
includeCostsbooleanfalse

Renvoie

Promise<Appel>

Défini dans

src/weaveClient.ts:902

getCallStack

getCallStack(): CallStack

Renvoie

CallStack

Défini dans

src/weaveClient.ts:1482

getCalls

getCalls(options?): Promise<Appel[]>

Paramètres

NomType
options?GetCallsOptions

Renvoie

Promise<Appel[]>

Défini dans

src/weaveClient.ts:935 getCalls(options?, includeCosts?, limit?): Promise<Appel[]>

Paramètres

NomType
options?CallsFilter
includeCosts?boolean
limit?number

Renvoie

Promise<Appel[]>

Défini dans

src/weaveClient.ts:936

getCallsIterator

getCallsIterator(options?, includeCosts?, limit?): AsyncIterableIterator<CallSchema, any, any>

Paramètres

NomType
options?CallsFilter
includeCosts?boolean
limit?number

Renvoie

AsyncIterableIterator<CallSchema, any, any>

Défini dans

src/weaveClient.ts:957 getCallsIterator(options?): AsyncIterableIterator<CallSchema, any, any>

Paramètres

NomType
options?GetCallsOptions

Renvoie

AsyncIterableIterator<CallSchema, any, any>

Défini dans

src/weaveClient.ts:962

getCurrentAttributes

getCurrentAttributes(): Record<string, any>

Renvoie

Record<string, any>

Défini dans

src/weaveClient.ts:1486

linkPromptToRegistry

linkPromptToRegistry(prompt, options): Promise<LinkAssetToRegistryRes> Lie une version publiée du prompt à un portefeuille du registre.

Paramètres

NomType
promptRegistryLinkable
optionsLinkPromptToRegistryOptions

Renvoie

Promise<LinkAssetToRegistryRes>

Défini dans

src/weaveClient.ts:1181

publish

publish(obj, objId?): Promise<ObjectRef>

Paramètres

NomType
objany
objId?string

Renvoie

Promise<ObjectRef>

Défini dans

src/weaveClient.ts:890

pushNewCall

pushNewCall(): objet

Renvoie

objet
NomType
currentCallCallStackEntry
newStackCallStack
parentCall?CallStackEntry

Défini dans

src/weaveClient.ts:1490

runWithAttributes

runWithAttributes<T>(attributes, fn): T

Paramètres de type

Nom
T

Paramètres

NomType
attributesRecord<string, any>
fn() => T

Renvoie

T

Défini dans

src/weaveClient.ts:1498

runWithCallStack

runWithCallStack<T>(callStack, fn): T

Paramètres de type

Nom
T

Paramètres

NomType
callStackCallStack
fn() => T

Renvoie

T

Défini dans

src/weaveClient.ts:1494

saveCallEnd

saveCallEnd(callEnd): void

Paramètres

NomType
callEndEndedCallSchemaForInsert

Renvoie

void

Défini dans

src/weaveClient.ts:1477

saveCallStart

saveCallStart(callStart): void

Paramètres

NomType
callStartStartedCallSchemaForInsert

Renvoie

void

Défini dans

src/weaveClient.ts:1472

saveOp

saveOp(op, objId?): Promise<OpRef>

Paramètres

NomType
opOp<(…args: any[]) => any>
objId?string

Renvoie

Promise<OpRef>

Défini dans

src/weaveClient.ts:1537

searchAgents

searchAgents(options): Promise<Réponse<SearchAgentsResult>> Recherche en texte intégral dans les messages des agents du projet. Renvoie les correspondances regroupées par conversation, avec un aperçu de chaque message correspondant. query est le terme de recherche en texte intégral. Passez une chaîne vide pour récupérer tous les messages correspondant aux filtres structurés (agentName, conversationId, traceId) sans tenir compte d’une correspondance textuelle. Utilisez limit / offset pour paginer les résultats.

Paramètres

NomType
optionsSearchAgentsOptions

Renvoie

Promise<Réponse<SearchAgentsResult>> Exemple
const  = await weave.init('entity/project');
const  = await .searchAgents({
  : 'Liverpool',
  : 'Assistant',
  : 20,
});

for (const  of .data.results ?? []) {
  .(`${.conversation_id} (${.agent_name})`);
  for (const  of .matched_messages) {
    .(`  [${.role}] ${.content_preview}`);
  }
}

.(`total conversations: ${.data.total_conversations}`);

Défini dans

src/weaveClient.ts:730

serializeAudio

serializeAudio(data, audioType?): Promise<SerializedFileBlob> Téléversez des octets audio bruts dans le stockage de contenu Weave, puis renvoyez l’espace réservé CustomWeaveType qui peut être intégré dans la sortie d’un appel. Utilisez cette méthode lorsque vous créez manuellement des sorties d’appel (par ex. via saveCallEnd) et que le pipeline de sérialisation automatique de finishCall n’est pas utilisé.

Paramètres

NomTypeValeur par défautDescription
dataBuffer<ArrayBufferLike>undefinedOctets audio bruts (WAV pour une compatibilité optimale avec les navigateurs)
audioType"wav"DEFAULT_AUDIO_TYPEFormat de fichier — actuellement, seul « wav » est pris en charge

Renvoie

Promise<SerializedFileBlob>

Défini dans

src/weaveClient.ts:1424

updateCall

updateCall(callId, displayName): Promise<void>

Paramètres

NomType
callIdstring
displayNamestring

Renvoie

Promise<void>

Défini dans

src/weaveClient.ts:1710

waitForBatchProcessing

waitForBatchProcessing(): Promise<void>

Renvoie

Promise<void>

Défini dans

src/weaveClient.ts:801