Official SDK for developing extensions for the Agently framework
Project description
Agently SDK
The official SDK for developing extensions for the Agently framework. Currently focused on plugin development, with more capabilities planned for future releases.
Installation
pip install agently-sdk
Quick Start
Create a simple plugin:
from agently_sdk.plugins import Plugin, PluginVariable, kernel_function
class HelloPlugin(Plugin):
name = "hello"
description = "A simple hello world plugin"
default_name = PluginVariable(
name="default_name",
description="Default name to use in greetings",
default="World"
)
@kernel_function
def greet(self, name=None) -> str:
"""Greet the user."""
return f"Hello, {name or self.default_name}!"
Plugin Development
Plugin Class
The Plugin class is the base class for all Agently plugins. It provides the structure and interface for creating plugins that can be used by Agently agents.
| Attribute | Type | Required | Description |
|---|---|---|---|
name |
str |
Yes | The name of the plugin, used for identification |
description |
str |
Yes | A brief description of what the plugin does |
Methods
| Method | Description |
|---|---|
get_kernel_functions() |
Returns a dictionary of all methods decorated with @kernel_function |
get_plugin_variables() |
Returns a dictionary of all PluginVariable instances defined in the class |
PluginVariable
The PluginVariable class represents a configurable variable for a plugin. It allows plugins to be configured with different values when they are loaded by Agently.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name |
str |
Yes | - | The name of the variable |
description |
str |
Yes | - | A description of what the variable is used for |
default |
Any |
No | None |
The default value if none is provided |
required |
bool |
No | False |
Whether this variable must be provided |
validator |
Callable[[Any], bool] |
No | None |
Optional function that validates the value |
choices |
List[Any] |
No | None |
Optional list of valid choices for the value |
type |
Type |
No | None |
Optional type constraint for the value |
Methods
| Method | Description |
|---|---|
validate(value) |
Validates a value against this variable's constraints |
to_dict() |
Converts this variable to a dictionary representation |
Kernel Function Decorator
Agently SDK provides two decorators for marking methods as callable by agents:
@agently_function- The recommended decorator for Agently plugins@kernel_function- An alias for@agently_functionprovided for backward compatibility
Both decorators wrap the kernel_function decorator from semantic_kernel.functions while maintaining compatibility with our existing code. If the Semantic Kernel package is not available, they fall back to a compatible implementation.
from agently_sdk.plugins import Plugin, PluginVariable, agently_function
class MyPlugin(Plugin):
name = "my_plugin"
description = "A sample plugin"
@agently_function(action="Performing calculation")
def my_function(self, param1: str, param2: int = 0) -> str:
"""
Function docstring that describes what this function does.
Args:
param1: Description of param1
param2: Description of param2
Returns:
Description of the return value
"""
# Implementation
return result
The action parameter provides a human-readable description of what the function does, which is useful for tracking and reporting.
Function Tracking and Execution Results
Agently SDK provides functionality to track function execution and get detailed information about each function call.
ExecutionResult
When function tracking is enabled, decorated functions return ExecutionResult objects that include:
- The actual return value of the function (
value) - The human-readable action description (
action) - Metadata about the execution (
metadata), such as:- Duration of the function call
- Function name
- Arguments passed to the function
from agently_sdk.plugins import track_function_calls
# Enable function tracking
track_function_calls(True)
# Call a plugin function
result = my_plugin.some_function("arg1", "arg2")
# Access the execution information
print(f"Action: {result.action}")
print(f"Duration: {result.metadata['duration']} seconds")
print(f"Actual value: {result.value}")
Getting Raw Results
For backward compatibility, you can use the get_result helper function to extract the raw return value from either an ExecutionResult or a direct value:
from agently_sdk.plugins import get_result
# Works with both ExecutionResult objects and direct values
raw_value = get_result(result)
Enabling and Disabling Function Tracking
Function tracking is disabled by default for backward compatibility. You can enable it globally:
from agently_sdk.plugins import track_function_calls
# Enable function tracking
track_function_calls(True)
# Disable function tracking
track_function_calls(False)
Best Practices
Plugin Design
- Clear Purpose: Each plugin should have a clear, focused purpose
- Descriptive Names: Use descriptive names for plugins, variables, and functions
- Comprehensive Documentation: Include detailed docstrings for all functions
- Input Validation: Validate all inputs to ensure robust behavior
- Error Handling: Handle errors gracefully and provide informative error messages
Variable Configuration
- Default Values: Provide sensible default values for variables when possible
- Validation: Use validators to ensure variables meet requirements
- Type Constraints: Specify value types to catch type errors early
- Descriptive Names: Use clear, descriptive names for variables
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agently_sdk-0.5.1.tar.gz.
File metadata
- Download URL: agently_sdk-0.5.1.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e16eb267f5df41eaed677179acdc00c6871a3653e7d50ce0c17f966a4be4adf
|
|
| MD5 |
8f3432c9d7808ae421460d1bb2299875
|
|
| BLAKE2b-256 |
3ba9fea357afe1d98bfabb1fe12b3809d1e5152c858b51a48df120676ed16d1f
|
File details
Details for the file agently_sdk-0.5.1-py3-none-any.whl.
File metadata
- Download URL: agently_sdk-0.5.1-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6476f4687e5a468b92498bd809687447443016c6bce3d910ab5522a8cec40a2
|
|
| MD5 |
24a05d9ac70b741b73f0a1374227ca06
|
|
| BLAKE2b-256 |
260742f7035557d19b629cd5713f94bec7515021657ee1fe355f2cc04ad5174f
|