Simple file management and serving for agents
Installation
pip install agentfs
Quickstart
- Start the server:
You can start the server by using the
start_server()function:
from agentfs import start_server
start_server()
This will start the server at http://localhost:8000.
You can start the server with uvicorn like this:
import os
if __name__ == "__main__":
import uvicorn
uvicorn.run("agentfs:start_server", host="0.0.0.0", port=int(os.getenv("PORT", 8000)))
- Get a file:
Once the server is up and running, you can retrieve file content by sending a GET request to
/file/{path}endpoint, where{path}is the path to the file relative to the server's current storage directory.
from agentfs import get_file
# Fetches the content of the file located at "./files/test.txt"
file_content = get_file("test.txt")
print(file_content)
- Save a file:
Similarly, you can save content to a file by sending a POST request to
/file/endpoint, with JSON data containing thepathandcontentparameters.
from agentfs import add_file
# Creates a file named "test.txt" in the current storage directory
# and writes "Hello, world!" to it.
add_file("test.txt", "Hello, world!")
API Documentation
AgentFS provides the following public functions:
start_server(storage_path=None)
Starts the FastAPI server. If a storage_path is provided, it sets the storage directory to the given path.
Arguments:
storage_path(str, optional): The path to the storage directory.
Returns:
- None
Example:
from agentfs import start_server
start_server("/my/storage/directory")
get_server()
Returns the FastAPI application instance.
Arguments:
- None
Returns:
- FastAPI application instance.
Example:
from agentfs import get_server
app = get_server()
set_storage_path(new_path)
Sets the storage directory to the provided path.
Arguments:
new_path(str): The path to the new storage directory.
Returns:
Trueif the path was successfully set,Falseotherwise.
Example:
from agentfs import set_storage_path
set_storage_path("/my/storage/directory")
add_file(path, content)
Creates a file at the specified path and writes the provided content to it.
Arguments:
path(str): The path to the new file.content(str): The content to be written to the file.
Returns:
Trueif the file was successfully created.
Example:
from agentfs import add_file
add_file("test.txt", "Hello, world!")
remove_file(path)
Removes the file at the specified path.
Arguments:
path(str): The path to the file to be removed.
Returns:
Trueif the file was successfully removed.
Example:
from agentfs import remove_file
remove_file("test.txt")
update_file(path, content)
Appends the provided content to the file at the specified path.
Arguments:
path(str): The path to the file to be updated.content(str): The content to be appended to the file.
Returns:
Trueif the file was successfully updated.
Example:
from agentfs import update_file
update_file("test.txt", "New content")
list_files(path='.')
Lists all files in the specified directory.
Arguments:
path(str, optional): The path to the directory. Defaults to'.'(current directory).
Returns:
- A list of file names in the specified directory.
Example:
from agentfs import list_files
files = list_files()
get_file(path)
Returns the content of the file at the specified path.
Arguments:
path(str): The path to the file.
Returns:
- A string containing the content of the file.
Example:
from agentfs import get_file
content = get_file("test.txt")
Contributions Welcome
If you like this library and want to contribute in any way, please feel free to submit a PR and I will review it. Please note that the goal here is simplicity and accesibility, using common language and few dependencies.
Metadata
Release files for agentfs 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentfs-0.1.0.tar.gz | 4.8 kB | Without provenance | Details for agentfs-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentfs-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for agentfs-0.1.0-py3-none-any.whl |
Total release size: 10.0 kB
Release files / agentfs-0.1.0.tar.gz
| Download URL | agentfs-0.1.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1168d1fcef540c7798d89ba35a446e37e9e677eadc87d4bd1ae9b3f91fe8527
|
|
BLAKE2b-256 checksum How to use checksums |
b0aa1dc25407f3e91298935675390ec6cfb9bf22c29a1cd9bc2246ad10aa424b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|
Release files / agentfs-0.1.0-py3-none-any.whl
| Download URL | agentfs-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f55a11c258c5e75c42d4c19551835b426304aee95375cc7fccfadbdcb32fd2f
|
|
BLAKE2b-256 checksum How to use checksums |
4cd9c81b47fd4ffbe80787d49f7f4f56eb6da5d4f00c24df04faf6295d81d2bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|
Security for agentfs 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.