AgentLabs - Docs
  • Introduction
    • What is AgentLabs?
    • Get Started with AgentLabs
    • Pricing
  • Getting Started
    • Installation
    • Secret Key
    • Using the SDK
  • Core Concepts
    • Frontend as a service
    • User Authentication
    • Project
    • Agents
    • Messages
      • Messages Format
      • One-off vs Stream
      • Typewriter animation
    • Attachments
  • Recipes
    • Before we start
    • Ping-Pong
    • ChatGPT with LangChain
    • Code Interpreter
    • Mutli-Agent with AutoGen
  • 🧙Community
    • Github
    • Discord
    • Support team
Powered by GitBook
On this page
  1. Getting Started

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.

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()
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.

PreviousSecret KeyNextFrontend as a service

Last updated 1 year ago

Core Concepts
Recipes