Skip to content

asterai-io/asterai-client-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@asterai/client

TypeScript/JavaScript client for asterai

Have a look at the asterai documentation here.

Examples

Query an agent and obtain a full text response back

import { AsteraiAgent } from "@asterai/client";

const agent = new AsteraiAgent({
  appId: ASTERAI_APP_ID,
  queryKey: ASTERAI_PUBLIC_QUERY_KEY,
});

const response = await agent.query({
  query: "how's the weather like in NY?"
});

console.log(await response.text());

Query an agent and obtain a response back token by token

import { AsteraiAgent } from "@asterai/client";

const agent = new AsteraiAgent({
  appId: ASTERAI_APP_ID,
  queryKey: ASTERAI_PUBLIC_QUERY_KEY,
});

const response = await agent.query({
  query: "how's the weather like in NY?"
});

let llmResponse = "";
response.onToken(token => {
  llmResponse += token;
});

response.onEnd(() => {
  // The full response has been received.
  console.log(llmResponse);
});

About

Client for querying asterai apps in TypeScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •