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
Metadata
Release files for vs-finance-agent-sdk 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vs_finance_agent_sdk-0.1.1.tar.gz | 12.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vs_finance_agent_sdk-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.8 kB
Release files / vs_finance_agent_sdk-0.1.1.tar.gz
| Download URL | vs_finance_agent_sdk-0.1.1.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ead552a005f5adb43ff608ed1381f0e15c707b21a8ab478c49dc35b5a319efa
|
|
BLAKE2b-256 checksum How to use checksums |
e9ecc3e212eb373a3f289dbc7b742065d125d8969945d40ec0d4fec93cf35d5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / vs_finance_agent_sdk-0.1.1-py3-none-any.whl
| Download URL | vs_finance_agent_sdk-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e5fdadd1f13a010979ede9924cbeedb9b94b16a2075f3f510f9925f07e20b8a
|
|
BLAKE2b-256 checksum How to use checksums |
f683d073c64cdb728e1b40c553518cfd0bb5014ac31ddba62d6fe501bf3be4fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|