Skip to main content

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 API
  • auth_token (optional): Sent as Authorization: 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. source can be a path (str/Path) or raw bytes (requires filename)
  • get_files(): Get list of all uploaded files
  • delete_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 listening
  • send_message(text): Send a chat message
  • get_messages(): Request all messages from the server
  • get_typing_status(): Get the current typing status
  • start_new_session(): Start a new chat session
  • disconnect(): Disconnect from the WebSocket
  • is_connected: Property — True when 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.27
  • websockets >= 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vs_finance_agent_sdk-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

vs_finance_agent_sdk-0.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

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

Hashes for vs_finance_agent_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4ead552a005f5adb43ff608ed1381f0e15c707b21a8ab478c49dc35b5a319efa
MD5 feade6351df87dd5860810bb71d2b693
BLAKE2b-256 e9ecc3e212eb373a3f289dbc7b742065d125d8969945d40ec0d4fec93cf35d5a

See more details on using hashes here.

File details

Details for the file vs_finance_agent_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for vs_finance_agent_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e5fdadd1f13a010979ede9924cbeedb9b94b16a2075f3f510f9925f07e20b8a
MD5 9bfacf9ee31eb4987fdde0ec0543705f
BLAKE2b-256 f683d073c64cdb728e1b40c553518cfd0bb5014ac31ddba62d6fe501bf3be4fc

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