Skip to content

Commit d18ec43

Browse files
authored
Merge pull request #137 from mindsdb/staging
Release 3.0.1
2 parents d12f1a7 + fbcd470 commit d18ec43

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

mindsdb_sdk/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__title__ = 'mindsdb_sdk'
22
__package_name__ = 'mindsdb_sdk'
3-
__version__ = '3.0.0'
3+
__version__ = '3.0.1'
44
__description__ = "MindsDB Python SDK, provides an SDK to use a remote mindsdb instance"
55
__email__ = "[email protected]"
66
__author__ = 'MindsDB Inc'

mindsdb_sdk/agents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def add_files(self, name: str, file_paths: List[str], description: str, knowledg
245245
Add a list of files to the agent for retrieval.
246246
247247
:param name: Name of the agent
248-
:param file_paths: List of paths to the files to be added.
248+
:param file_paths: List of paths or URLs to the files to be added.
249249
:param description: Description of the file. Used by agent to know when to do retrieval
250250
:param knowledge_base: Name of an existing knowledge base to be used. Will create a default knowledge base if not given.
251251
"""

mindsdb_sdk/connectors/rest_api.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import requests
77
import pandas as pd
8+
import validators
89

910
from mindsdb_sdk import __about__
1011
from sseclient import SSEClient
@@ -149,6 +150,7 @@ def read_file_as_bytes(file_path: str):
149150
raise Exception(f'Permission denied when reading file {file_path}.')
150151
except Exception as e:
151152
raise Exception(f'Unknown error occurred when reading file {file_path} - {str(e)}')
153+
152154
@staticmethod
153155
def read_dataframe_as_csv(data: pd.DataFrame):
154156
"""
@@ -161,6 +163,16 @@ def read_dataframe_as_csv(data: pd.DataFrame):
161163
fd.seek(0)
162164
return fd.read()
163165

166+
@staticmethod
167+
def read_file_as_webpage(url: str):
168+
"""
169+
Read and return content of a file in bytes, given its URL.
170+
:param file_path: URL of the file to read.
171+
:return: File content in bytes.
172+
"""
173+
data = requests.get(url)
174+
return data.content
175+
164176
def upload_data(self, file_name: str, data: bytes):
165177
"""
166178
Upload binary data to MindsDB.
@@ -194,6 +206,8 @@ def upload_file(self, name: str, data: Union[pd.DataFrame, str]):
194206
"""
195207
if isinstance(data, pd.DataFrame):
196208
data_in_bytes = self.read_dataframe_as_csv(data)
209+
elif validators.url(data):
210+
data_in_bytes = self.read_file_as_webpage(data)
197211
else:
198212
data_in_bytes = self.read_file_as_bytes(data)
199213

mindsdb_sdk/utils/mind.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ class DatabaseConfig(DataSourceConfig):
4343
tables: List[str] = []
4444

4545

46+
class FileConfig(DataSourceConfig):
47+
"""
48+
Represents a colection of files that can be made available to a Mind.
49+
"""
50+
51+
# Local file paths and/or URLs.
52+
paths: List[str] = []
53+
54+
# TODO: Configure Vector storage. Use defaults for now.
55+
56+
4657
# Create mind entity util function
4758
def create_mind(
4859
base_url: str,

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ docstring-parser >= 0.7.3
55
tenacity >= 8.0.1
66
openai >= 1.15.0
77
sseclient-py >= 1.8.0
8+
validators == 0.20.0

0 commit comments

Comments
 (0)