Using the SDK Getting started with our SDK
Basic example
Since we provide the entire UI and streaming for you, you only have to listen for messages from the front end and send messages from your backend.
Here's a dead simple example of a ping-pong app. Indeed, you can make much more complex applications with multiple agents streaming in real time.
Typescript Python
Copy import { Project } from 'agentlabs-sdk' ;
const project = new Project ({
projectId : 'you-project-id' ,
secret : 'your-secret' ,
url : 'provided-in-your-console'
});
const agent = project .agent ( 'agent-id' );
project .onChatMessage ((message) => {
if ( message .text === 'ping' ) {
agent .send ({
conversationId : message .conversationId ,
text : 'pong'
})
} else {
agent .send ({
conversationId : message .conversationId ,
text : 'I do not understand'
})
}
});
project .connect ()
Copy from agentlabs . project import IncomingChatMessage , MessageFormat , Project
def handle_message ( message : IncomingChatMessage):
if message . text == 'ping' :
agent . send (
conversation_id = message.conversation_id,
text = "pong"
)
else :
agent . send (
conversation_id = message.conversation_id,
text = "I did not get that"
)
project = Project (
project_id = 'your-project-id' ,
secret = 'your-secret' ,
url = 'provided-in-your-console'
)
agent = project . agent ( 'agent-id' )
project . on_chat_message (handle_message)
project . connect ()
project . wait () ;
Next
Learn more about our core concepts and follow some recipes to get started.
Core Concepts Recipes Last updated 10 months ago