A powerful and user-friendly Python client for interacting with the Jumpad AI Agent SDK
Project description
Jumpad SDK Client
A powerful and user-friendly Python client for interacting with the Jumpad AI Agent SDK.
Features
- Easy-to-use SDK with simplified API that abstracts away complexity
- Automatic handling of chat sessions and message sequences
- Two supported approaches: simplified for ease of use, traditional for detailed control
- Automatic tracking of conversation history
- Duplicate message prevention
- Helper methods for extracting different types of messages
- Pretty-formatted conversation output
Installation
Make sure you have the latest version of pip before installing:
pip install --upgrade pip
Install from PyPI:
pip install jumpad-sdk-client
Quick Start
from jumpad_sdk_client import LLMAgentClient
# Initialize the client with your API key and Agent ID
BASE_URL = "your_fusion_workspace_instance_URL"
API_KEY = "your_api_key_here"
AGENT_ID = "your_agent_id_here"
client = LLMAgentClient(endpoint=BASE_URL, api_key=API_KEY, agent_id=AGENT_ID)
# Simply send a message and get a response - the SDK handles everything
agent_response = client.get_agent_response("Hi Agent, can you introduce yourself?")
print(f"Agent says: {agent_response}")
# Send a follow-up message - no need to manage chat IDs
follow_up_response = client.get_agent_response("Thanks! Now tell me a fun fact.")
print(f"Agent's reply: {follow_up_response}")
# If you need the chat ID for any reason, you can get it anytime
chat_id = client.get_chat_id()
print(f"Chat ID: {chat_id}")
# If you need the raw response data
raw_response = client.get_raw_agent_response()
print(f"Raw response: {raw_response}")
Working with Conversations
Viewing the Complete Conversation
# Get nicely formatted conversation history
formatted_history = client.get_tracked_messages(chat_id, format_output=True)
print(formatted_history)
# Output example:
# ===== Conversation History =====
#
# 1. 👤 You: Hi Agent, can you introduce yourself?
#
# 2. 🤖 Agent: Hello! I'm the Jumpad AI assistant...
#
# 3. 👤 You: Thanks! Now tell me a fun fact.
#
# 4. 🤖 Agent: Here's a fun fact: Honey never spoils...
Working with User Messages
# Get all user messages in formatted output
try:
user_messages = client.get_tracked_user_messages(chat_id, format_output=True)
print(user_messages)
except ValueError as e:
print(f"Error: {e}")
# Get raw user message data for processing
try:
user_messages_data = client.get_tracked_user_messages(chat_id)
for msg in user_messages_data:
print(f"ID: {msg.get('id')}, Message: {msg.get('message')}")
except ValueError as e:
print(f"Error: {e}")
Working with Agent Messages
# Get all agent responses in formatted output
try:
agent_messages = client.get_tracked_agent_messages(chat_id, format_output=True)
print(agent_messages)
except ValueError as e:
print(f"Error: {e}")
# Get raw agent message data for processing
try:
agent_messages_data = client.get_tracked_agent_messages(chat_id)
for msg in agent_messages_data:
print(f"ID: {msg.get('id')}, Message: {msg.get('message')}")
except ValueError as e:
print(f"Error: {e}")
Advanced Usage
Traditional API Usage (Still Supported)
If you prefer the previous style of explicit chat management:
# Start a chat session explicitly
response = client.start_chat(initial_message="Hello agent!")
# Extract the chat ID
chat_id = client.get_chat_id_from_response(response)
# Get the agent's response
agent_response = client.get_agent_response_from_chat(response)
# Send a follow-up message to the specific chat
send_response = client.send_message(chat_id=chat_id, message="Follow up question")
# Get the agent's reply
agent_reply = client.get_agent_reply_to_message(send_response)
Getting Chat Details
# Get chat metadata without messages
chat_details = client.get_chat_history(chat_id)
print(f"Chat title: {chat_details.get('title')}")
print(f"Chat created at: {chat_details.get('created_at')}")
# Get chat with messages
chat_with_messages = client.get_chat_with_messages(chat_id)
Extracting Message Details
# After sending a message either with the simplified or traditional API
# you can extract specific details if needed
# Extract the sent message content
message_content = client.get_sent_message_content(client.get_raw_agent_response())
# Extract the sent message ID
message_id = client.get_sent_message_id(client.get_raw_agent_response())
Getting Raw SDK Responses
# Get the raw SDK response
raw_response = client.get_raw_response(response)
print(json.dumps(raw_response, indent=2))
Error Handling
The client includes comprehensive error handling:
from jumpad_sdk_client import LLMAgentClient, LLMAgentError
try:
# Your code here
response = client.send_message(chat_id, "Hello")
except LLMAgentError as e:
print(f"SDK Error: {e.status_code} - {e.error_message}")
if e.response_body:
print(f"Response Body: {e.response_body}")
except ValueError as e:
print(f"Value Error: {e}")
except Exception as e:
print(f"Unexpected Error: {e}")
Getting Help
You can use Python's built-in help system to learn more about the package:
import jumpad_sdk_client
help(jumpad_sdk_client) # Show module documentation
from jumpad_sdk_client import LLMAgentClient
help(LLMAgentClient) # Show class documentation
help(LLMAgentClient.send_message) # Show method documentation
Complete Example
import os
import json
from jumpad_sdk_client import LLMAgentClient, LLMAgentError
# Configuration
BASE_URL = "https://fusion-workspace.jumpad.ai"
API_KEY = "your_api_key_here" # Replace with your actual API key
AGENT_ID = "your_agent_id_here" # Replace with your actual agent ID
def main():
try:
# Initialize the client with your agent ID
client = LLMAgentClient(endpoint=BASE_URL, api_key=API_KEY, agent_id=AGENT_ID)
print("Client initialized.")
# Send the first message and get the agent's response
agent_response = client.get_agent_response("Hi Agent, can you introduce yourself?")
print(f"Agent says: {agent_response}")
# Send a follow-up message
follow_up_response = client.get_agent_response("Thanks! Tell me about your capabilities.")
print(f"Agent reply: {follow_up_response}")
# Get the chat ID if needed for reference
chat_id = client.get_chat_id()
print(f"Conversation is happening in chat: {chat_id}")
# Display the complete conversation
print("\nComplete conversation:")
conversation = client.get_tracked_messages(chat_id, format_output=True)
print(conversation)
except LLMAgentError as e:
print(f"SDK Error: {e.status_code} - {e.error_message}")
if e.response_body:
print(f"Response: {json.dumps(e.response_body, indent=2)}")
except ValueError as e:
print(f"Value Error: {e}")
except Exception as e:
print(f"Unexpected Error: {e}")
if __name__ == "__main__":
main()
SDK Reference
LLMAgentClient
__init__(endpoint: str, api_key: str, agent_id: Optional[str] = None)- Initialize the client with optional agent_idstart_chat(agent_id: Optional[str] = None, initial_message: str)- Start a new chatsend_message(chat_id: Optional[str] = None, message: str)- Send a message to a chat
Simplified API Methods
get_agent_response(message: Optional[str] = None)- Get agent's response (handles chat initiation automatically)get_chat_id()- Get current chat ID without needing parametersget_raw_agent_response()- Get raw response data from last interaction
Traditional Helper Methods
get_chat_id_from_response(response)- Extract chat ID from responseget_agent_response_from_chat(response)- Extract agent responseget_sent_message_content(response)- Get content of sent messageget_sent_message_id(response)- Get ID of sent messageget_agent_reply_to_message(response)- Get agent's reply to a message
Message Tracking
get_tracked_messages(chat_id, format_output=False)- Get all messagesget_tracked_user_messages(chat_id, format_output=False)- Get user messagesget_tracked_agent_messages(chat_id, format_output=False)- Get agent messages
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jumpad_sdk_client-0.1.1.tar.gz.
File metadata
- Download URL: jumpad_sdk_client-0.1.1.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e889880d17311813dd4f0400e136a6a1eb38437e528b0500961ed68dfc6127b0
|
|
| MD5 |
6b1a1c228bbf7e7c26db3ee80cf39850
|
|
| BLAKE2b-256 |
519f3dc579db2244e01ed8db87cb4879cf2efead73b26987d22091110693e457
|
File details
Details for the file jumpad_sdk_client-0.1.1-py3-none-any.whl.
File metadata
- Download URL: jumpad_sdk_client-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdd1b1d14f7109d9ce57b650b66f7862e6bf441ed55140e65793b13d065f70f8
|
|
| MD5 |
956d1afe7b8893cf651ba31a04309dc8
|
|
| BLAKE2b-256 |
2a32dd9c5b0508b727cb18a662ff378446e7e49e9e3aefd8091c57a6a2bf229b
|