We have a new enhancement in AI Engine API and Python SDK that allows you to grant access to your
function groups
With it, you will be able to provide access but keep everybody away from altering the core functionalities of your app.
Collaboration is at the heart of innovation. Whether you're working on a complex project, sharing agents with colleagues, or simply need to grant access to specific functionalities, our new function group-sharing feature makes it effortless.
There are not a few occasions when we need to make our resources, in this case, our
agents
functions
This is what you get with the Function Group Sharing feature.
The use cases are infinite and they will depend entirely on your requirements - from sharing a bunch of agents used only by your brand new company project with the QA team to sharing your personal agents that replicate Nancy Pelosi's trades in the stock market within your colleagues (and not allowing them to alter it - but get the latest updates).
With this new feature, you can share a function group with another user by making a single API request. Here’s how you can do it:
import asyncio import json import aiohttp async def share_function_group( fg_id: str, target_user_email: str, api_key: str ): ### # THE RELEVANT PART ### """ I will explain the action part a bit more after this snippet :) Just keep in mind that "SHARE" means giving access, so the only allowed action by user you are sharing it with should be "RETRIEVE" (or, in other words, action that cannot alter any of your share resources). """ payload = { "user_email_to_add_permission": target_user_email, "action": "RETRIEVE" } headers = { "Content-Type": "application/json", "Authorization": f"Bearer {api_key}" } method = "PUT" async with aiohttp.ClientSession() as session: async with session.request( method, f"{api_base_url}{endpoint}", headers=headers, data=json.dumps(payload) ) as response: # If everything went ok: -> status=201 & empty body return response.status ### # DISPENSABLE PART, IT IS HERE JUST FOR THE SAKE OF THE EXAMPLE. ### if __name__ == "__main__": asyncio.run( share_function_group( fg_id="your_function_group_id", target_user_email="[email protected]", api_key="an agentverse api key" ) )
The "actions" key refers to what kind of operations will be able to commit the user granted with.
For example, in a general sense - when we "share" we intend to allow somebody to enjoy our resources but do not alter them at all (destroy, change, or share with other people with our permission).
The owner of
function group
RETRIEVE
function group
If you're already using our Python SDK, sharing a function group is a breeze.
🧠 If you are any curious or want to delve into our SDK, please, visit https://fetch.ai/docs/guides/ai-engine-sdk/python to know more.
In case this will be the first time you use the SDK be sure to follow the README before you start to experiment with the following snippets and tools in order to have a working and sounding setup.
📢 We also have JS SDK 🛠️
If you are not interested in adding this programmatically or adding it to a bigger project you can just use a script meant for this purpose, so the only thing you will have to do to get your function-group shared is to execute it.
You will find it in
examples/share_function_group.py
Once the SDK setup is ready - using that tool is as easy as running it with our Python interpreter. Let’s see the parameters accepted by the script:
--function_group_id_to_share (or -fg_id_to_share): It's self-explanatory, it will be the identifier of the
function group
You could retrieve that identifier by using the SDK lib or just another useful tool we have provided for cases like that:
examples/list_function_groups_by_user_sdk.py
--target_environment (or -e): That parameter is meant to define which environment (agentverse's cluster we could say) we want to affect; production, staging, development...
This is unlikely to be used or has much relevance for the general audience and use cases, so you can omit that argument and it will automatically point to production.
--target_user_email: As self-explanatory as the previous ones, this is the email of the user with whom we want to share the
function group
Resulting in something like the following:
# Located in the "ai-engine-sdk-py" root python examples/share_function_group.py -fg_id_to_share "bcd181fa-14dd-4d94-8094-c9b4c085e8aa" -target_user_email "[email protected]"
The SDK handles all the underlying API interactions for you, allowing you to focus on what matters most: your project, your logic.
Here is a dummy, but functional, example.
import argparse import asyncio from ai_engine_sdk import AiEngine async def main(fg_id: str, api_key: str, target_user_email: str): ### # THE RELEVANT PART ### client = AiEngine(api_key=api_key) result = await client.share_function_group( function_group_id=fg_id, target_user_email=target_user_email ) ### # SECONDARY ELEMENTS FOR THE SAKE OF THE EXAMPLE AND TOTALLY DISPENSABLE ### print(result) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--fg_id", required=True, help="Function group ID to share" ) parser.add_argument( "--email", required=True, help="Target user's email; with whom I want to share." ) parser.add_argument( "--api_key", required=True, help="Your AgentVerse API key" ) args = parser.parse_args() asyncio.run( main( fg_id=args.fg_id, api_key=args.api_key, target_user_email=args.email ) )
As you can see, is as simple as using a single method of the client and providing the
function group
Imagine you're part of a team working on an agent (or a bunch of them with a common goal). You’ve created a function group that encapsulates several critical functions. With this new feature, you can quickly share the function group with your teammates, allowing them to contribute without needing to duplicate your work.
In a large enterprise environment, managing permissions across different teams can be complex. This feature allows you to efficiently grant access to specific function groups, ensuring that each team member has the necessary permissions to perform their tasks without compromising security.
Educators can now easily share function groups with students. This is particularly useful for coding boot camps, data science courses, or any learning environment where instructors need to provide specific resources to students.
Whether you’re sharing resources with a teammate or managing access for an entire department, this enhancement is designed to make your life easier.
For any questions or feedback, feel free to reach out to our support team or join the conversation on our community forum. Happy coding! 🎉
Stay tuned for more updates as we continue to improve our platform with new and exciting features.