Simple chat, debug and file management panel for agents
Project description
Simple file management and serving for agents
Installation
pip install agentcomlink
Quickstart
- Start the server: You can start the server with uvicorn like this:
import os
if __name__ == "__main__":
import uvicorn
uvicorn.run("agentcomlink:start_server", host="0.0.0.0", port=int(os.getenv("PORT", 8000)))
This will start the server at http://localhost: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 agentcomlink 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 thepath
andcontent
parameters.
from agentcomlink 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 agentcomlink import start_server
start_server("/my/storage/directory")
get_server()
Returns the FastAPI application instance.
Arguments:
- None
Returns:
- FastAPI application instance.
Example:
from agentcomlink 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:
True
if the path was successfully set,False
otherwise.
Example:
from agentcomlink 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:
True
if the file was successfully created.
Example:
from agentcomlink 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:
True
if the file was successfully removed.
Example:
from agentcomlink 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:
True
if the file was successfully updated.
Example:
from agentcomlink 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 agentcomlink import list_files
files = list_files()
list_files_formatted(path='.')
Lists all files in the specified directory as a formatted string. Convenient!
Arguments:
path
(str, optional): The path to the directory. Defaults to'.'
(current directory).
Returns:
- A string containing a list of file names in the specified directory.
Example:
from agentcomlink 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 agentcomlink 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file agentcomlink-0.1.11.tar.gz
.
File metadata
- Download URL: agentcomlink-0.1.11.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7eb26e71d32afb675b6b7c48ddae679146b32812f6460d8f946316facbc213f7 |
|
MD5 | a364e190b6fa6eb5f641dbaf447e9aba |
|
BLAKE2b-256 | fd67c050723e8267fd1c45e8569fd5132e3a62c7b8f987273da3cc979de16c55 |
File details
Details for the file agentcomlink-0.1.11-py3-none-any.whl
.
File metadata
- Download URL: agentcomlink-0.1.11-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78e65576000dad260b106c70423b15eb0c51ec0a4f38b65baf77705ba50ab84d |
|
MD5 | 2c48e3d4fdbf90034c38bcbbaaa57d17 |
|
BLAKE2b-256 | 0a164501e037272c75a26057c09b2ae88bd1602b1de1054b8e76bffb850da971 |