Skip to content

Commit

Permalink
Allow recursive blobs (#186)
Browse files Browse the repository at this point in the history
* Allow recursive blobs in file utils.

* Make recursive blobs default behavior.
  • Loading branch information
wrmedford authored Oct 30, 2023
1 parent 5e682c2 commit 4372fc7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions memgpt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ def read_in_rows_csv(file_object, chunk_size):

def prepare_archival_index_from_files(glob_pattern, tkns_per_chunk=300, model="gpt-4"):
encoding = tiktoken.encoding_for_model(model)
files = glob.glob(glob_pattern)
files = glob.glob(glob_pattern, recursive=True)
return chunk_files(files, tkns_per_chunk, model)


def total_bytes(pattern):
total = 0
for filename in glob.glob(pattern):
for filename in glob.glob(pattern, recursive=True):
if os.path.isfile(filename): # ensure it's a file and not a directory
total += os.path.getsize(filename)
return total
Expand Down Expand Up @@ -260,7 +260,7 @@ async def prepare_archival_index_from_files_compute_embeddings(
model="gpt-4",
embeddings_model="text-embedding-ada-002",
):
files = sorted(glob.glob(glob_pattern))
files = sorted(glob.glob(glob_pattern, recursive=True))
save_dir = os.path.join(
MEMGPT_DIR,
"archival_index_from_files_" + get_local_time().replace(" ", "_").replace(":", "_"),
Expand Down

0 comments on commit 4372fc7

Please # to comment.