Skip to main content

A client for the MARA conversational agent for cheminformatics.

Project description

mara client module

This package provides a Python interface for the MARA conversational agent for cheminformatics.

Installation

pip install mara-client

Usage

To use the MARA client, you need to have an API key. You can create one at https://mara.nanome.ai/settings/api-keys.

MARA chats are created using the new_chat method, or retrieved with the get_chat method of the client. You can then interact with the chat using the prompt method. The prompt method returns a ChatResult object, which contains the response from MARA, intermediate messages such as tool runs, and any files that were generated during the conversation. You can download these files using the download_file method of the chat. Chat will be visible as conversations in the MARA web interface, and can be deleted using the delete method.

from mara_client import MARAClient

API_KEY = "..."
URL = "https://mara.example.com" # optional
client = MARAClient(API_KEY, URL)

chat = client.new_chat()
# or, chat = client.get_chat("chat_id")

result = chat.prompt('Download SDF of aspirin')
print(result.response)
# The SDF file for the compound aspirin has been downloaded successfully. You can access it [here](CHEMBL25.sdf).
print(result.files)
# [ChatFile(id='...', name='CHEMBL25.sdf', size=1203, date=...)]

chat.files.download('CHEMBL25.sdf', 'aspirin.sdf')
# downloaded as aspirin.sdf in current working directory

result = chat.prompt('Calculate chem props')
print(result.response)
# The chemical properties of the compound with ChEMBL ID CHEMBL25 (aspirin) are as follows:
#
# | Property | Value |
# | --- | --- |
# | Molecular Weight (MW) | 180.159 |
# | LogP | 1.310 |
# | Total Polar Surface Area (TPSA) | 63.600 |
# | Hydrogen Bond Acceptors (HBA) | 3 |
# | Hydrogen Bond Donors (HBD) | 1 |
# | Rotatable Bonds (RB) | 2 |

chat.delete()
# remove chat from history, delete associated files and data

Files

The chat object contains a files attribute for working with files.

# Upload a file as part of a prompt
file_path = './example.sdf'
result = chat.prompt('Convert this to SMILES', files=[file_path])

# List all files
file_list = chat.files.list()

# Download a file
file_name = file_list[0].name
chat.files.download(file_name, 'output.sdf')

# Upload a file directly
file_path = './example.sdf'
file = chat.files.upload(file_path)
print(file.id)

Data Tables

The chat object contains a datatables attribute for working with DataTables.

# Create a data table from already uploaded file
csv_file = './example.csv'
datatable: DataTable = chat.datatables.create(csv_file)

# List all data tables
table_list = chat.datatables.list()

# Generate a new DataTable based on Chat context
chat.datatables.generate()

# Run prompt to update/query a datatable
dt_id = datatable.id
chat.datatables.prompt(dt_id, prompt)

# Retrieve a datatable
chat.datatables.get(dt_id)

# View datatable as a pandas Dataframe
df = datatable.dataframe

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

mara_client-0.20.6.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

mara_client-0.20.6-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file mara_client-0.20.6.tar.gz.

File metadata

  • Download URL: mara_client-0.20.6.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mara_client-0.20.6.tar.gz
Algorithm Hash digest
SHA256 d27fe14da28b173adb6296cdd6981765168b5a2ad504146fa8ab9b80d86e1619
MD5 77a4cdd754700feb157ed99843be3e76
BLAKE2b-256 28de403f6cc254fb4a02241febbb9017c031214f1991e8424cb8b50fa8e37e32

See more details on using hashes here.

File details

Details for the file mara_client-0.20.6-py3-none-any.whl.

File metadata

  • Download URL: mara_client-0.20.6-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mara_client-0.20.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7c0814a56bab4d4e72445bee27bbfd80174ba68c7177cde2a991f05ef202edee
MD5 18bb21869d664d26410de42608c25a60
BLAKE2b-256 6525aff09220081c7bc24201aeb1d9be276ed55c09fe75fce2fe6a7e4fe71e0d

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