Skip to main content

Python sdk for the Rowboat API

Project description

Rowboat Python SDK

A Python SDK for interacting with the Rowboat API.

Installation

You can install the package using pip:

pip install rowboat

Usage

Basic Usage

Initialize a client and use the chat method directly:

from rowboat import Client
from rowboat.schema import UserMessage, SystemMessage

# Initialize the client
client = Client(
    host="<HOST>",
    project_id="<PROJECT_ID>",
    project_secret="<PROJECT_SECRET>"
)

# Create messages
messages = [
    SystemMessage(role='system', content="You are a helpful assistant"),
    UserMessage(role='user', content="Hello, how are you?")
]

# Get response
response_messages, state = client.chat(messages=messages)
print(response_messages[-1].content)

# For subsequent messages, include previous messages and state
messages.extend(response_messages)
messages.append(UserMessage(role='user', content="What's your name?"))
response_messages, state = client.chat(messages=messages, state=state)

Using Tools

The SDK supports function calling through tools:

def weather_lookup(city_name: str) -> str:
    return f"The weather in {city_name} is 22°C."

# Create a tools dictionary
tools = {
    'weather_lookup': weather_lookup
}

# Use tools with the chat method
response_messages, state = client.chat(
    messages=messages,
    tools=tools
)

Stateful Chat (Convenience Wrapper)

For simpler use cases, the SDK provides a StatefulChat class that maintains conversation state automatically:

from rowboat import StatefulChat

# Initialize stateful chat
chat = StatefulChat(
    client,
    tools=tools,
    system_prompt="You are a helpful assistant."
)

# Simply send messages and get responses
response = chat.run("Hello, how are you?")
print(response)
# I'm good, thanks! How can I help you today?

API Reference

Client

The Client class handles communication with the Rowboat API.

Client(host: str, project_id: str, project_secret: str)

StatefulChat

The StatefulChat class maintains conversation state across multiple turns.

StatefulChat(
    client: Client,
    tools: Optional[Dict[str, Callable[..., str]]] = None,
    system_prompt: Optional[str] = None
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rowboat-1.0.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rowboat-1.0.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file rowboat-1.0.0.tar.gz.

File metadata

  • Download URL: rowboat-1.0.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for rowboat-1.0.0.tar.gz
Algorithm Hash digest
SHA256 aae4d0e9b73ae6246716da7137e6fe62f3efbaeb39b6b0cfafb6793e76939b77
MD5 1de35b8e7436a98dcaedbaa86e1feb78
BLAKE2b-256 ab9731ab3c086a926d6fd9e04683d8887b86940b1c6cbd0d1f30ee5bd7bd0554

See more details on using hashes here.

File details

Details for the file rowboat-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: rowboat-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for rowboat-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0eabb2649ff76d0fa6f0f512cd8806196eb68a40cb657cff4cf878ebeedb8933
MD5 d59e3b1be69a8fc84edddbe0590769f6
BLAKE2b-256 f1250d832ab72ff43fd19cc7820c6acebd4b4004d35187181e2f12257bd99db5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page