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.

import mara_client

API_KEY = "..."
URL = "https://mara.example.com" # optional
client = mara.Client(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

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


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.14.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

mara_client-0.14.3-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mara_client-0.14.3.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mara_client-0.14.3.tar.gz
Algorithm Hash digest
SHA256 26e1a48e5371f22fb7c4b85241015a4a91f5c1c88fc975509ed633748cbb093e
MD5 b048ffa86a5fe4e3d59eb2bf3879b225
BLAKE2b-256 8144dc01305fed78b0bce908adc33c19ae684c28c6eb46137e75921f000452b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mara_client-0.14.3-py3-none-any.whl
Algorithm Hash digest
SHA256 06c46271194a307610e7825877ae6a83a88a475d108f7ce8b9e5552187c79ac9
MD5 47145a75a829dd7e0b8fc187989ec539
BLAKE2b-256 3985d974ba6c94ffb5a78aef2c3a63f453a4868b53b5a717ce2ff5e279ac3de4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page