-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
246 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
agents/ten_packages/extension/image_generate_tool/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# image_generate_tool | ||
|
||
<!-- brief introduction for the extension --> | ||
|
||
## Features | ||
|
||
<!-- main features introduction --> | ||
|
||
- xxx feature | ||
|
||
## API | ||
|
||
Refer to `api` definition in [manifest.json] and default values in [property.json](property.json). | ||
|
||
<!-- Additional API.md can be referred to if extra introduction needed --> | ||
|
||
## Development | ||
|
||
### Build | ||
|
||
<!-- build dependencies and steps --> | ||
|
||
### Unit test | ||
|
||
<!-- how to do unit test for the extension --> | ||
|
||
## Misc | ||
|
||
<!-- others if applicable --> |
6 changes: 6 additions & 0 deletions
6
agents/ten_packages/extension/image_generate_tool/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# | ||
# This file is part of TEN Framework, an open source project. | ||
# Licensed under the Apache License, Version 2.0. | ||
# See the LICENSE file for more information. | ||
# | ||
from . import addon |
20 changes: 20 additions & 0 deletions
20
agents/ten_packages/extension/image_generate_tool/addon.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# | ||
# This file is part of TEN Framework, an open source project. | ||
# Licensed under the Apache License, Version 2.0. | ||
# See the LICENSE file for more information. | ||
# | ||
from ten import ( | ||
Addon, | ||
register_addon_as_extension, | ||
TenEnv, | ||
) | ||
from .extension import ImageGenerateToolExtension | ||
|
||
|
||
@register_addon_as_extension("image_generate_tool") | ||
class ImageGenerateToolExtensionAddon(Addon): | ||
|
||
def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None: | ||
ten_env.log_info("on_create_instance") | ||
ten_env.on_create_instance_done( | ||
ImageGenerateToolExtension(name), context) |
48 changes: 48 additions & 0 deletions
48
agents/ten_packages/extension/image_generate_tool/extension.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# | ||
# This file is part of TEN Framework, an open source project. | ||
# Licensed under the Apache License, Version 2.0. | ||
# See the LICENSE file for more information. | ||
# | ||
from ten import ( | ||
TenEnv, | ||
AsyncTenEnv, | ||
) | ||
from ten_ai_base import ( | ||
AsyncLLMToolBaseExtension, LLMToolMetadata, LLMToolResult, BaseConfig | ||
) | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class ImageGenerateToolConfig(BaseConfig): | ||
# TODO: add extra config fields here | ||
pass | ||
|
||
|
||
class ImageGenerateToolExtension(AsyncLLMToolBaseExtension): | ||
def __init__(self, name: str): | ||
super().__init__(name) | ||
self.config = None | ||
|
||
async def on_start(self, ten_env: AsyncTenEnv) -> None: | ||
await super().on_start(ten_env) | ||
|
||
# initialize configuration | ||
self.config = await ImageGenerateToolConfig.create_async(ten_env=ten_env) | ||
ten_env.log_info(f"config: {self.config}") | ||
|
||
# Implement this method to construct and start your resources. | ||
ten_env.log_debug("TODO: on_start") | ||
|
||
async def on_stop(self, ten_env: AsyncTenEnv) -> None: | ||
await super().on_stop(ten_env) | ||
|
||
#Implement this method to stop and destruct your resources. | ||
ten_env.log_debug("TODO: on_stop") | ||
|
||
def get_tool_metadata(self, ten_env: TenEnv) -> list[LLMToolMetadata]: | ||
ten_env.log_debug("TODO: get_tool_metadata") | ||
return [] | ||
|
||
async def run_tool(self, ten_env: AsyncTenEnv, name: str, args: dict) -> LLMToolResult | None: | ||
ten_env.log_debug(f"TODO: run_tool {name} {args}") |
88 changes: 88 additions & 0 deletions
88
agents/ten_packages/extension/image_generate_tool/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"type": "extension", | ||
"name": "image_generate_tool", | ||
"version": "0.1.0", | ||
"dependencies": [ | ||
{ | ||
"type": "system", | ||
"name": "ten_runtime_python", | ||
"version": "0.6" | ||
} | ||
], | ||
"package": { | ||
"include": [ | ||
"manifest.json", | ||
"property.json", | ||
"requirements.txt", | ||
"**.tent", | ||
"**.py", | ||
"README.md" | ||
] | ||
}, | ||
"api": { | ||
"property": {}, | ||
"cmd_in": [ | ||
{ | ||
"name": "tool_call", | ||
"property": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"arguments": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"name" | ||
], | ||
"result": { | ||
"property": { | ||
"tool_result": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"tool_result" | ||
] | ||
} | ||
} | ||
], | ||
"cmd_out": [ | ||
{ | ||
"name": "tool_register", | ||
"property": { | ||
"tool": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"description": { | ||
"type": "string" | ||
}, | ||
"parameters": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": {} | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"name", | ||
"description", | ||
"parameters" | ||
] | ||
} | ||
}, | ||
"result": { | ||
"property": { | ||
"response": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
agents/ten_packages/extension/image_generate_tool/property.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters