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>",
    api_key="<API_KEY>"
)

# 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?

Advanced Usage

Using a specific workflow

response_messages, state = client.chat(
    messages=messages,
    workflow_id="<WORKFLOW_ID>"
)

# or

chat = StatefulChat(
    client,
    workflow_id="<WORKFLOW_ID>"
)

Using a test profile

You can specify a test profile ID to use a specific test configuration:

response_messages, state = client.chat(
    messages=messages,
    test_profile_id="<TEST_PROFILE_ID>"
)

# or

chat = StatefulChat(
    client,
    test_profile_id="<TEST_PROFILE_ID>"
)

Skip tool call runs

This will surface the tool calls to the SDK instead of running them automatically on the Rowboat server.

response_messages, state = client.chat(
    messages=messages,
    skip_tool_calls=True
)

# or

chat = StatefulChat(
    client,
    skip_tool_calls=True
)

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-2.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

rowboat-2.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rowboat-2.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for rowboat-2.1.0.tar.gz
Algorithm Hash digest
SHA256 ec98a837ecd05dd55e7f97f0e4d4ad1939c297de364001a498e671059045dcbd
MD5 4e13ba289a51995dd2b005ea44cacea6
BLAKE2b-256 d70a60e635871ed699000e5823da227ceb9281cf8cb8f6f94f40a7fefe20db1f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rowboat-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for rowboat-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7aa7c9a2ff44449ef0d17c46e273bdab7206799ba481456bc3ea4e66e784dd6a
MD5 d53cc9327e9a9586dc68af363d99eba3
BLAKE2b-256 c6b499c9476a3cf2f02743a35abc69578f388f5027ff4ff92020965bedba3337

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