From 7eac1a562f33c45aa6e9c2b338079afa2cec1865 Mon Sep 17 00:00:00 2001 From: gautamgambhir97 <140384949+gautamgambhir97@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:42:39 +0530 Subject: [PATCH] fix(docs): fix ai engine sdk guide issue (#951) --- pages/examples/advanced/chat_api_example.mdx | 10 ++--- pages/guides/ai-engine-sdk/python.mdx | 40 ++++++++++++++------ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/pages/examples/advanced/chat_api_example.mdx b/pages/examples/advanced/chat_api_example.mdx index 6d3b67454..603a293da 100644 --- a/pages/examples/advanced/chat_api_example.mdx +++ b/pages/examples/advanced/chat_api_example.mdx @@ -319,13 +319,13 @@ The main script flow includes: last_response = "" while True: - time.sleep(5) # Wait before fetching responses to avoid overwhelming the server - response = get_request(f"https://agentverse.ai/v1beta1/engine/chat/sessions/{session_id}/responses", {"Authorization": token}) + time.sleep(5) # Wait before fetching responses to avoid overwhelming the server + response = get_request(f"https://agentverse.ai/v1beta1/engine/chat/sessions/{session_id}/responses", {"Authorization": token}) - if response.status_code != 200: - raise Exception(f"Error in fetching responses: Status code {response.status_code}") + if response.status_code != 200: + raise Exception(f"Error in fetching responses: Status code {response.status_code}") - response = response.json() + response = response.json() # Handling unresponsive deltaV if not response['agent_response']: diff --git a/pages/guides/ai-engine-sdk/python.mdx b/pages/guides/ai-engine-sdk/python.mdx index 5fb41aab8..f3719d2df 100644 --- a/pages/guides/ai-engine-sdk/python.mdx +++ b/pages/guides/ai-engine-sdk/python.mdx @@ -46,26 +46,44 @@ from ai_engine_sdk import AiEngine ai_engine: AiEngine = AiEngine(api_key) ``` -### Querying Function Groups in AI Engine SDK +## Querying Function Groups -```py copy -function_groups: list[FunctionGroup] = await ai_engine.get_function_groups() +The AI Engine SDK allows you to query different groups of functions, such as `private functions`, `public functions`, or `Fetch.ai-verified functions`. You can filter function groups using the respective methods provided by the SDK based on your needs. + +### Querying Private Functions + +Private functions are those that you have created and are not accessible to the public or other users. To access your private functions, use the `get_private_function_groups()` method. This will return all functions under your account, giving you access to personal or proprietary models and algorithms. + +#### Example + +```python +private = await ai_engine.get_private_function_groups() -public_group = next( - (g for g in function_groups if g.name == "Fetch Verified"), - None +private_functions = next( + (g for g in private if g.name == "My Functions"), + None ) ``` -If you would like to use the functions in your own My Functions function group instead then you can use this filter instead: +#### Querying Public Functions + +Public functions are accessible by anyone on the platform. These functions include your publicly available functions and functions verified by Fetch.ai. To access public function groups, use the `get_public_function_groups()` method. You can further filter by two important groups: `Public` and `Fetch Verified`. ```py copy -my_group = next( - (g for g in function_groups if g.name == "My Functions"), - None +public = await ai_engine.get_public_function_groups() + +# Access your public functions +public_functions = next( + (g for g in public if g.name == "Public"), + None ) -``` +# Access Fetch.ai-verified functions +fetch_verified_group = next( + (g for g in public if g.name == "Fetch Verified"), + None +) +``` ### Sharing function groups