This tutorial will guide you through using the HiveAgentClient, a Python class designed to interact with the Hive Agent's API. The client facilitates various operations such as sending chat messages and sending data to a Hive Agent.
Setup
Ensure you have httpx installed in your environment:
pip install httpx
Import the HiveAgentClient in your Python script:
from hive_agent_client import HiveAgentClient
Instantiate the client with the base URL of your Hive Agent API:
base_url ="https://localhost:8000/api/"# replace with your actual API URLversion ="v1"# optional paramclient =HiveAgentClient(base_url, version)
asyncdeflist_all_files():try: files =await client.list_files()print("Files on server:", files)exceptExceptionas e:print("Error:", e)
Renaming a File
To rename a specified file on the server:
asyncdefrename_file_on_server(old_filename,new_filename):try: result =await client.rename_file(old_filename, new_filename)print("Rename result:", result)exceptExceptionas e:print("Error:", e)
Deleting a File
To delete a specified file from the server:
asyncdefdelete_file_on_server(filename):try: result =await client.delete_file(filename)print("Delete result:", result)exceptExceptionas e:print("Error:", e)
So far, we have demonstrated the HiveAgentClient and the methods to interact with the HiveAgent API. We performed various operations such as sending chat messages and sending data to a Hive Agent.
Example usage of the HiveAgentClient.
This tutorial demonstrates how to use the HiveAgentClient class in an asynchronous context.
Now, let's combine all the operations and form a single asynchronous function.
Replace "my_table", {"id": "Integer", "name": "String"}, and other placeholders with your actual data. Replace "path/to/your/file1.txt", "path/to/your/file2.txt", and other placeholders with your actual file paths.
This tutorial provides a basic overview of how to interact with the Hive Agent API using the HiveAgentClient class.