diff --git a/apps/python-sdk/.gitignore b/apps/python-sdk/.gitignore index d14f2353..60fce92b 100644 --- a/apps/python-sdk/.gitignore +++ b/apps/python-sdk/.gitignore @@ -1,3 +1,4 @@ __pycache__/ venv/ -.venv/ \ No newline at end of file +.venv/ +dist/ \ No newline at end of file diff --git a/apps/python-sdk/README.md b/apps/python-sdk/README.md new file mode 100644 index 00000000..b87a9861 --- /dev/null +++ b/apps/python-sdk/README.md @@ -0,0 +1,99 @@ +# Rowboat Python SDK + +A Python SDK for interacting with the Rowboat API. + +## Installation + +You can install the package using pip: + +```bash +pip install rowboat +``` + +## Usage + +### Basic Usage + +Initialize a client and create a chat session: + +```python +from rowboat import Client, StatefulChat + +# Initialize the client +client = Client( + host="", + project_id="", + project_secret="" +) + +# Create a chat session +chat = StatefulChat(client) + +# Send a message and get a response +response = chat.run("Hello, how are you?") +print(response) +``` + +### Using Tools + +The SDK supports function calling through tools. Here's how to use them: + +```python +def weather_lookup(city_name: str) -> str: + # Implement your weather lookup logic here + return f"The weather in {city_name} is 22°C." + +# Create a tools dictionary +tools = { + 'weather_lookup': weather_lookup +} + +# Initialize chat with tools +chat = StatefulChat(client, tools=tools) + +# The AI can now use the weather tool +response = chat.run("What's the weather in London?") +print(response) +``` + +### System Prompts + +You can initialize the chat with a system prompt to guide the AI's behavior: + +```python +chat = StatefulChat( + client, + tools=tools, + system_prompt="You are a helpful assistant who specializes in weather information." +) +``` + +## API Reference + +### Client + +The `Client` class handles communication with the Rowboat API. + +```python +Client(host: str, project_id: str, project_secret: str) +``` + +### StatefulChat + +The `StatefulChat` class maintains conversation state across multiple turns. + +```python +StatefulChat( + client: Client, + tools: Optional[Dict[str, Callable[..., str]]] = None, + system_prompt: Optional[str] = None +) +``` + +## License + +[Add your license information here] + +## Contributing + +[Add contribution guidelines here] diff --git a/apps/python-sdk/pyproject.toml b/apps/python-sdk/pyproject.toml new file mode 100644 index 00000000..a1ac7ed1 --- /dev/null +++ b/apps/python-sdk/pyproject.toml @@ -0,0 +1,26 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "rowboat" +version = "0.1.0" +authors = [ + { name = "Your Name", email = "your.email@example.com" }, +] +description = "Python sdk for the Rowboat API" +readme = "README.md" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", +] +dependencies = [ + "requests>=2.25.0", + "pydantic>=2.0.0", +] + +[project.urls] +"Homepage" = "https://github.com/rowboatlabs/rowboat/tree/main/apps/python-sdk" +"Bug Tracker" = "https://github.com/rowboatlabs/rowboat/issues" \ No newline at end of file diff --git a/apps/python-sdk/src/rowboat/__init__.py b/apps/python-sdk/src/rowboat/__init__.py new file mode 100644 index 00000000..6eff958d --- /dev/null +++ b/apps/python-sdk/src/rowboat/__init__.py @@ -0,0 +1,28 @@ +from .client import Client, StatefulChat +from .schema import ( + ApiMessage, + UserMessage, + SystemMessage, + AssistantMessage, + AssistantMessageWithToolCalls, + ToolMessage, + ApiRequest, + ApiResponse +) + +__version__ = "0.1.0" + +__all__ = [ + "Client", + "StatefulChat", + # Message types + "ApiMessage", + "UserMessage", + "SystemMessage", + "AssistantMessage", + "AssistantMessageWithToolCalls", + "ToolMessage", + # Request/Response types + "ApiRequest", + "ApiResponse", +] \ No newline at end of file diff --git a/apps/python-sdk/lib.py b/apps/python-sdk/src/rowboat/client.py similarity index 96% rename from apps/python-sdk/lib.py rename to apps/python-sdk/src/rowboat/client.py index 39464a8f..94bb6052 100644 --- a/apps/python-sdk/lib.py +++ b/apps/python-sdk/src/rowboat/client.py @@ -1,7 +1,16 @@ from typing import Dict, List, Optional, Any, Callable, Union, Tuple import requests import json -from schema import ApiRequest, ApiResponse, ApiMessage, ToolMessage, UserMessage, SystemMessage, AssistantMessage, AssistantMessageWithToolCalls +from .schema import ( + ApiRequest, + ApiResponse, + ApiMessage, + ToolMessage, + UserMessage, + SystemMessage, + AssistantMessage, + AssistantMessageWithToolCalls +) class Client: diff --git a/apps/python-sdk/schema.py b/apps/python-sdk/src/rowboat/schema.py similarity index 100% rename from apps/python-sdk/schema.py rename to apps/python-sdk/src/rowboat/schema.py