mara-client 0.15.2__tar.gz → 0.15.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mara_client-0.15.2 → mara_client-0.15.4}/PKG-INFO +25 -3
- {mara_client-0.15.2 → mara_client-0.15.4}/README.md +25 -3
- {mara_client-0.15.2 → mara_client-0.15.4}/mara_client/clients.py +16 -12
- {mara_client-0.15.2 → mara_client-0.15.4}/mara_client.egg-info/PKG-INFO +25 -3
- {mara_client-0.15.2 → mara_client-0.15.4}/MANIFEST.in +0 -0
- {mara_client-0.15.2 → mara_client-0.15.4}/mara_client/__init__.py +0 -0
- {mara_client-0.15.2 → mara_client-0.15.4}/mara_client/models.py +0 -0
- {mara_client-0.15.2 → mara_client-0.15.4}/mara_client/utils.py +0 -0
- {mara_client-0.15.2 → mara_client-0.15.4}/mara_client.egg-info/SOURCES.txt +0 -0
- {mara_client-0.15.2 → mara_client-0.15.4}/mara_client.egg-info/dependency_links.txt +0 -0
- {mara_client-0.15.2 → mara_client-0.15.4}/mara_client.egg-info/requires.txt +0 -0
- {mara_client-0.15.2 → mara_client-0.15.4}/mara_client.egg-info/top_level.txt +0 -0
- {mara_client-0.15.2 → mara_client-0.15.4}/pyproject.toml +0 -0
- {mara_client-0.15.2 → mara_client-0.15.4}/setup.cfg +0 -0
- {mara_client-0.15.2 → mara_client-0.15.4}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: mara_client
|
|
3
|
-
Version: 0.15.
|
|
3
|
+
Version: 0.15.4
|
|
4
4
|
Summary: A client for the MARA conversational agent for cheminformatics.
|
|
5
5
|
Home-page: https://nanome.ai/mara
|
|
6
6
|
Author: Sam Hessenauer, Alex McNerney, Mike Rosengrant
|
|
@@ -37,11 +37,11 @@ To use the MARA client, you need to have an API key. You can create one at https
|
|
|
37
37
|
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.
|
|
38
38
|
|
|
39
39
|
```python
|
|
40
|
-
import
|
|
40
|
+
from mara_client import MARAClient
|
|
41
41
|
|
|
42
42
|
API_KEY = "..."
|
|
43
43
|
URL = "https://mara.example.com" # optional
|
|
44
|
-
client =
|
|
44
|
+
client = MARAClient(API_KEY, URL)
|
|
45
45
|
|
|
46
46
|
chat = client.new_chat()
|
|
47
47
|
# or, chat = client.get_chat("chat_id")
|
|
@@ -72,6 +72,28 @@ chat.delete()
|
|
|
72
72
|
# remove chat from history, delete associated files and data
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
### Files
|
|
76
|
+
|
|
77
|
+
The chat object contains a `files` attribute for working with files.
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
# Upload a file as part of a prompt
|
|
81
|
+
file_path = './example.sdf'
|
|
82
|
+
result = chat.prompt('Convert this to SMILES', files=[file_path])
|
|
83
|
+
|
|
84
|
+
# List all files
|
|
85
|
+
file_list = chat.files.list()
|
|
86
|
+
|
|
87
|
+
# Download a file
|
|
88
|
+
file_name = file_list[0].name
|
|
89
|
+
chat.files.download(file_name, 'output.sdf')
|
|
90
|
+
|
|
91
|
+
# Upload a file directly
|
|
92
|
+
file_path = './example.sdf'
|
|
93
|
+
file = chat.files.upload(file_path)
|
|
94
|
+
print(file.id)
|
|
95
|
+
```
|
|
96
|
+
|
|
75
97
|
### Data Tables
|
|
76
98
|
|
|
77
99
|
The chat object contains a `datatables` attribute for working with DataTables.
|
|
@@ -15,11 +15,11 @@ To use the MARA client, you need to have an API key. You can create one at https
|
|
|
15
15
|
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.
|
|
16
16
|
|
|
17
17
|
```python
|
|
18
|
-
import
|
|
18
|
+
from mara_client import MARAClient
|
|
19
19
|
|
|
20
20
|
API_KEY = "..."
|
|
21
21
|
URL = "https://mara.example.com" # optional
|
|
22
|
-
client =
|
|
22
|
+
client = MARAClient(API_KEY, URL)
|
|
23
23
|
|
|
24
24
|
chat = client.new_chat()
|
|
25
25
|
# or, chat = client.get_chat("chat_id")
|
|
@@ -50,6 +50,28 @@ chat.delete()
|
|
|
50
50
|
# remove chat from history, delete associated files and data
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
### Files
|
|
54
|
+
|
|
55
|
+
The chat object contains a `files` attribute for working with files.
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
# Upload a file as part of a prompt
|
|
59
|
+
file_path = './example.sdf'
|
|
60
|
+
result = chat.prompt('Convert this to SMILES', files=[file_path])
|
|
61
|
+
|
|
62
|
+
# List all files
|
|
63
|
+
file_list = chat.files.list()
|
|
64
|
+
|
|
65
|
+
# Download a file
|
|
66
|
+
file_name = file_list[0].name
|
|
67
|
+
chat.files.download(file_name, 'output.sdf')
|
|
68
|
+
|
|
69
|
+
# Upload a file directly
|
|
70
|
+
file_path = './example.sdf'
|
|
71
|
+
file = chat.files.upload(file_path)
|
|
72
|
+
print(file.id)
|
|
73
|
+
```
|
|
74
|
+
|
|
53
75
|
### Data Tables
|
|
54
76
|
|
|
55
77
|
The chat object contains a `datatables` attribute for working with DataTables.
|
|
@@ -74,4 +96,4 @@ chat.datatables.get(dt_id)
|
|
|
74
96
|
|
|
75
97
|
# View datatable as a pandas Dataframe
|
|
76
98
|
df = datatable.dataframe
|
|
77
|
-
```
|
|
99
|
+
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import requests
|
|
2
|
-
from typing import List, Optional
|
|
2
|
+
from typing import List, Optional, Union
|
|
3
3
|
from .models import ChatFile, ChatResult, DataTable
|
|
4
4
|
from . import utils
|
|
5
5
|
|
|
@@ -122,12 +122,12 @@ class FileManager:
|
|
|
122
122
|
|
|
123
123
|
def upload(self, filepath: str) -> ChatFile:
|
|
124
124
|
path = f'chats/{self.chat_id}/files'
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
resp = self.client._request(
|
|
126
|
+
method='POST',
|
|
127
|
+
path=path,
|
|
128
|
+
json=None,
|
|
129
|
+
files={'file': open(filepath, 'rb')}
|
|
130
|
+
)
|
|
131
131
|
return ChatFile(**resp.json())
|
|
132
132
|
|
|
133
133
|
def list(self) -> List[dict]:
|
|
@@ -166,16 +166,20 @@ class Chat:
|
|
|
166
166
|
"""Delete the chat and all of its data and files."""
|
|
167
167
|
self.client._request(method='DELETE', path=f'chats/{self.chat_id}')
|
|
168
168
|
|
|
169
|
-
def prompt(self, content: str, files: List[str] = None) -> ChatResult:
|
|
169
|
+
def prompt(self, content: str, files: List[Union[str, ChatFile]] = None) -> ChatResult:
|
|
170
170
|
"""Prompt the chat with a message and optional files. Return the result."""
|
|
171
171
|
files = files or []
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
file_ids = []
|
|
174
174
|
for fi in files:
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
if isinstance(fi, str):
|
|
176
|
+
fi = self.files.upload(fi)
|
|
177
|
+
elif not isinstance(fi, ChatFile):
|
|
178
|
+
raise ValueError('Files must be either string file paths or ChatFile objects')
|
|
179
|
+
file_ids.append(fi.id)
|
|
180
|
+
data = {'content': content, 'files': file_ids}
|
|
177
181
|
path = f'chats/{self.chat_id}'
|
|
178
|
-
r = self.client._request(path=path, json=data
|
|
182
|
+
r = self.client._request(path=path, json=data)
|
|
179
183
|
return ChatResult.from_response(r.text)
|
|
180
184
|
|
|
181
185
|
def get_context(self) -> str:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: mara_client
|
|
3
|
-
Version: 0.15.
|
|
3
|
+
Version: 0.15.4
|
|
4
4
|
Summary: A client for the MARA conversational agent for cheminformatics.
|
|
5
5
|
Home-page: https://nanome.ai/mara
|
|
6
6
|
Author: Sam Hessenauer, Alex McNerney, Mike Rosengrant
|
|
@@ -37,11 +37,11 @@ To use the MARA client, you need to have an API key. You can create one at https
|
|
|
37
37
|
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.
|
|
38
38
|
|
|
39
39
|
```python
|
|
40
|
-
import
|
|
40
|
+
from mara_client import MARAClient
|
|
41
41
|
|
|
42
42
|
API_KEY = "..."
|
|
43
43
|
URL = "https://mara.example.com" # optional
|
|
44
|
-
client =
|
|
44
|
+
client = MARAClient(API_KEY, URL)
|
|
45
45
|
|
|
46
46
|
chat = client.new_chat()
|
|
47
47
|
# or, chat = client.get_chat("chat_id")
|
|
@@ -72,6 +72,28 @@ chat.delete()
|
|
|
72
72
|
# remove chat from history, delete associated files and data
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
### Files
|
|
76
|
+
|
|
77
|
+
The chat object contains a `files` attribute for working with files.
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
# Upload a file as part of a prompt
|
|
81
|
+
file_path = './example.sdf'
|
|
82
|
+
result = chat.prompt('Convert this to SMILES', files=[file_path])
|
|
83
|
+
|
|
84
|
+
# List all files
|
|
85
|
+
file_list = chat.files.list()
|
|
86
|
+
|
|
87
|
+
# Download a file
|
|
88
|
+
file_name = file_list[0].name
|
|
89
|
+
chat.files.download(file_name, 'output.sdf')
|
|
90
|
+
|
|
91
|
+
# Upload a file directly
|
|
92
|
+
file_path = './example.sdf'
|
|
93
|
+
file = chat.files.upload(file_path)
|
|
94
|
+
print(file.id)
|
|
95
|
+
```
|
|
96
|
+
|
|
75
97
|
### Data Tables
|
|
76
98
|
|
|
77
99
|
The chat object contains a `datatables` attribute for working with DataTables.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|