Python SDK for the Finance Agent API (chat & file management)
Project description
Finance Agent Python SDK
Python SDK for interacting with the Finance Agent API.
Installation
pip install vs-finance-agent-sdk
Usage
Initialize the SDK
from finance_agent_sdk import FinanceAgentSDK, FinanceAgentConfig
client = FinanceAgentSDK(FinanceAgentConfig(
base_url="https://your-app.cfapps.eu10.hana.ondemand.com",
))
File Operations
Upload a File
import asyncio
async def main():
# From a file path
result = await client.files.upload_file("document.pdf")
print("Uploaded:", result.file)
# From raw bytes
with open("document.pdf", "rb") as f:
content = f.read()
result = await client.files.upload_file(content, filename="document.pdf")
asyncio.run(main())
List All Files
files = await client.files.get_files()
print("Files:", files)
Delete a File
message = await client.files.delete_file("stored-filename.pdf")
print(message) # "File deleted successfully"
Chat Operations
Connect to Chat
from finance_agent_sdk.types import ChatEventHandlers
await client.chat.connect(ChatEventHandlers(
on_connected=lambda session: print("Connected to session:", session.sessionId),
on_agent_message=lambda message: print("Agent says:", message.text),
on_user_message=lambda message: print("User says:", message.text),
on_typing_start=lambda: print("Agent is typing..."),
on_typing_stop=lambda: print("Agent stopped typing"),
on_error=lambda error: print("Chat error:", error),
))
Send a Message
client.chat.send_message("Hello, how can you help me?")
Get All Messages
client.chat.get_messages()
Start New Session
client.chat.start_new_session()
Disconnect
client.chat.disconnect()
Complete Example
import asyncio
from finance_agent_sdk import FinanceAgentSDK, FinanceAgentConfig
from finance_agent_sdk.types import ChatEventHandlers
async def main():
# Initialize SDK
client = FinanceAgentSDK(FinanceAgentConfig(
base_url="https://your-app.cfapps.eu10.hana.ondemand.com",
))
# Connect to chat
await client.chat.connect(ChatEventHandlers(
on_agent_message=lambda message: print("Agent:", message.text),
))
# Send a message
client.chat.send_message("What files do I have?")
# List files
files = await client.files.get_files()
print("Available files:", len(files))
# Disconnect when done
await asyncio.sleep(30)
client.chat.disconnect()
asyncio.run(main())
API Reference
FinanceAgentSDK
Main SDK class that provides access to file and chat clients.
Constructor
FinanceAgentSDK(config: FinanceAgentConfig)
Config options:
base_url(required): Base URL of the Finance Agent APIauth_token(optional): Sent asAuthorization: Bearer <token>headers(optional): Custom headers merged into every request
FileClient
Handles file operations over HTTP. Accessed via sdk.files.
Methods
upload_file(source, *, filename=None): Upload a file.sourcecan be a path (str/Path) or rawbytes(requiresfilename)get_files(): Get list of all uploaded filesdelete_file(filename): Delete a file by its stored name
ChatClient
Handles WebSocket-based chat communication. Accessed via sdk.chat.
Methods
connect(handlers): Connect to the chat WebSocket and start listeningsend_message(text): Send a chat messageget_messages(): Request all messages from the serverget_typing_status(): Get the current typing statusstart_new_session(): Start a new chat sessiondisconnect(): Disconnect from the WebSocketis_connected: Property —Truewhen the connection is open
Types
from dataclasses import dataclass
from typing import Literal
@dataclass
class Message:
id: str
text: str
sender: Literal["user", "agent"]
timestamp: str
@dataclass
class Session:
sessionId: str
createdAt: str
@dataclass
class FileInfo:
fileName: str
storedName: str
type: str
size: str
uploadDate: str
path: str | None = None
See finance_agent_sdk/types.py for all type definitions.
Requirements
- Python 3.11+
httpx >= 0.27websockets >= 13.0
Roadmap
Authentication (Coming Soon)
Future versions will include built-in support for SAP Identity and Access Management (IAS) and XSUAA authentication flows:
- Client Credentials Flow — for server-to-server integrations where the application authenticates directly using a client ID and secret, without user involvement.
- Authorization Code Flow — for user-facing applications where end users authenticate via IAS/XSUAA and the SDK exchanges the authorization code for an access token automatically.
These additions will make it straightforward to integrate the SDK securely into SAP BTP environments without manually managing tokens.
License
MIT
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 vs_finance_agent_sdk-0.1.1.tar.gz.
File metadata
- Download URL: vs_finance_agent_sdk-0.1.1.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ead552a005f5adb43ff608ed1381f0e15c707b21a8ab478c49dc35b5a319efa
|
|
| MD5 |
feade6351df87dd5860810bb71d2b693
|
|
| BLAKE2b-256 |
e9ecc3e212eb373a3f289dbc7b742065d125d8969945d40ec0d4fec93cf35d5a
|
File details
Details for the file vs_finance_agent_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: vs_finance_agent_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e5fdadd1f13a010979ede9924cbeedb9b94b16a2075f3f510f9925f07e20b8a
|
|
| MD5 |
9bfacf9ee31eb4987fdde0ec0543705f
|
|
| BLAKE2b-256 |
f683d073c64cdb728e1b40c553518cfd0bb5014ac31ddba62d6fe501bf3be4fc
|