aryn-ai / sycamore

🍁 Sycamore is an LLM-powered search and analytics platform for unstructured data.
https://sycamore.readthedocs.io
Apache License 2.0
352 stars 39 forks source link

Can avoid the filesystem when posting files. #562

Closed alexaryn closed 2 months ago

alexaryn commented 2 months ago

Added a new cache argument to post(). The code will look in the cache using the path (without @) as the key before trying to read from the filesystem. Example usage:

with open(path, "rb") as fp
    buf = fp.read()
hdr = {"Authorization": f"Bearer {tok}"}
form = {
    "options": '{"use_foo": true}',
    "input": f"@{path}",
}
cache = {path: buf}
c = OneShotKaClient(url)
res = c.post(headers=hdr, form=form, cache=cache)