Skip to content

Commit

Permalink
fix(docs): fix ai engine sdk guide issue (#951)
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamgambhir97 authored Sep 17, 2024
1 parent 80403c7 commit 7eac1a5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
10 changes: 5 additions & 5 deletions pages/examples/advanced/chat_api_example.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand Down
40 changes: 29 additions & 11 deletions pages/guides/ai-engine-sdk/python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7eac1a5

Please sign in to comment.