Hello World
this section is a work in progress
This step-by-step guide describes how to create a new asterai application that simply exposes a hardcoded name to the LLM via a plugin. When you ask the LLM who to give hello to, it will have access to the name within the plugin.
Think of this like sending a message to a pre-defined person in a contacts list. Except, in this example plugin the actual HTTP request for sending the DM is not sent.
- Sign into the asterai console
- Create a new application
- Install the asterai CLI:
npm install -g @asterai/cli
- Generate a new API key in asterai, and authenticate with it into the CLI:
asterai auth <your_api_key>
- Initialise a new project called
hello-world
:
asterai init hello-world
- Install dependencies on the new project:
cd hello-world
npm i
- Inspect the contents of
plugin.asterai.proto
, the plugin manifest file - Inspect the contents of
plugin.ts
, the plugin file - Modify the contents of
plugin.asterai.proto
so that it has a function calledsayHello
instead oforderBurger
. - Modify the function comment to "say hello to a pre-defined person".
- This function call does not require any arguments, therefore update the
input and output types to
Empty
, defined asmessage Empty {}
. - Run
asterai codegen
. Here, this has no effect because there are no arguments (they are empty), but it is good practice to always run codegen after modifying the manifest file to ensure the types are up to date. - Modify the
plugin.ts
file to have the new function name,sayHello
. - Modify the return statement to return
"said hello to Alice"
- Get your app ID from the cloud console
- Deploy the plugin:
asterai deploy --app <your_app_id>
- Refresh the page in the cloud console. Now you should see the new, active plugin that was just deployed.
- In the playground section, ask "who should I say hello to?". The app should reply with "Alice".
- You can also make a POST request to https://api.asterai.io/app/:your_app_id/query with a raw text body containing the user query. The response will be an SSE of token streams.
Hopefully this hello world example illustrates how asterai can be used to connect AI to applications. Within plugins, it is possible to access LLMs, Vector DBs, make HTTP calls and even use WebSockets.