Skip to content

Commit a9a3642

Browse files
committed
first commit
0 parents  commit a9a3642

11 files changed

+323
-0
lines changed

README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# default_async_llm_tool_extension_python
2+
3+
<!-- brief introduction for the extension -->
4+
5+
## Features
6+
7+
<!-- main features introduction -->
8+
9+
- xxx feature
10+
11+
## API
12+
13+
Refer to `api` definition in [manifest.json] and default values in [property.json](property.json).
14+
15+
<!-- Additional API.md can be referred to if extra introduction needed -->
16+
17+
## Development
18+
19+
### Build
20+
21+
<!-- build dependencies and steps -->
22+
23+
### Unit test
24+
25+
<!-- how to do unit test for the extension -->
26+
27+
## Misc
28+
29+
<!-- others if applicable -->

README.md.tent

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# {{package_name}}
2+
3+
<!-- brief introduction for the extension -->
4+
5+
## Features
6+
7+
<!-- main features introduction -->
8+
9+
- xxx feature
10+
11+
## API
12+
13+
Refer to `api` definition in [manifest.json] and default values in [property.json](property.json).
14+
15+
<!-- Additional API.md can be referred to if extra introduction needed -->
16+
17+
## Development
18+
19+
### Build
20+
21+
<!-- build dependencies and steps -->
22+
23+
### Unit test
24+
25+
<!-- how to do unit test for the extension -->
26+
27+
## Misc
28+
29+
<!-- others if applicable -->

__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# This file is part of TEN Framework, an open source project.
3+
# Licensed under the Apache License, Version 2.0.
4+
# See the LICENSE file for more information.
5+
#
6+
from . import addon

addon.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# This file is part of TEN Framework, an open source project.
3+
# Licensed under the Apache License, Version 2.0.
4+
# See the LICENSE file for more information.
5+
#
6+
from ten import (
7+
Addon,
8+
register_addon_as_extension,
9+
TenEnv,
10+
)
11+
from .extension import DefaultAsyncLLMToolExtension
12+
13+
14+
@register_addon_as_extension("default_async_llm_tool_extension_python")
15+
class DefaultAsyncLLMToolExtensionAddon(Addon):
16+
17+
def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None:
18+
ten_env.log_info("on_create_instance")
19+
ten_env.on_create_instance_done(
20+
DefaultAsyncLLMToolExtension(name), context)

addon.py.tent

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# This file is part of TEN Framework, an open source project.
3+
# Licensed under the Apache License, Version 2.0.
4+
# See the LICENSE file for more information.
5+
#
6+
from ten import (
7+
Addon,
8+
register_addon_as_extension,
9+
TenEnv,
10+
)
11+
from .extension import {{class_name_prefix}}Extension
12+
13+
14+
@register_addon_as_extension("{{package_name}}")
15+
class {{class_name_prefix}}ExtensionAddon(Addon):
16+
17+
def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None:
18+
ten_env.log_info("on_create_instance")
19+
ten_env.on_create_instance_done(
20+
{{class_name_prefix}}Extension(name), context)

extension.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#
2+
# This file is part of TEN Framework, an open source project.
3+
# Licensed under the Apache License, Version 2.0.
4+
# See the LICENSE file for more information.
5+
#
6+
from ten import (
7+
TenEnv,
8+
AsyncTenEnv,
9+
)
10+
from ten_ai_base import (
11+
AsyncLLMToolBaseExtension, LLMToolMetadata, LLMToolResult, BaseConfig
12+
)
13+
from dataclasses import dataclass
14+
15+
16+
@dataclass
17+
class DefaultAsyncLLMToolConfig(BaseConfig):
18+
# TODO: add extra config fields here
19+
pass
20+
21+
22+
class DefaultAsyncLLMToolExtension(AsyncLLMToolBaseExtension):
23+
async def on_start(self, ten_env: AsyncTenEnv) -> None:
24+
await super().on_start(ten_env)
25+
26+
# initialize configuration
27+
self.config = DefaultAsyncLLMToolConfig.create(ten_env=ten_env)
28+
ten_env.log_info(f"config: {self.config}")
29+
30+
"""Implement this method to construct and start your resources."""
31+
ten_env.log_debug("TODO: on_start")
32+
33+
async def on_stop(self, ten_env: AsyncTenEnv) -> None:
34+
await super().on_stop(ten_env)
35+
36+
"""Implement this method to stop and destruct your resources."""
37+
ten_env.log_debug("TODO: on_stop")
38+
39+
def get_tool_metadata(self, ten_env: TenEnv) -> list[LLMToolMetadata]:
40+
ten_env.log_debug("TODO: get_tool_metadata")
41+
return []
42+
43+
async def run_tool(self, ten_env: AsyncTenEnv, name: str, args: dict) -> LLMToolResult:
44+
ten_env.log_debug(f"TODO: run_tool {name} {args}")

extension.py.tent

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#
2+
# This file is part of TEN Framework, an open source project.
3+
# Licensed under the Apache License, Version 2.0.
4+
# See the LICENSE file for more information.
5+
#
6+
from ten import (
7+
TenEnv,
8+
AsyncTenEnv,
9+
)
10+
from ten_ai_base import (
11+
AsyncLLMToolBaseExtension, LLMToolMetadata, LLMToolResult, BaseConfig
12+
)
13+
from dataclasses import dataclass
14+
15+
16+
@dataclass
17+
class {{class_name_prefix}}Config(BaseConfig):
18+
# TODO: add extra config fields here
19+
pass
20+
21+
22+
class {{class_name_prefix}}Extension(AsyncLLMToolBaseExtension):
23+
async def on_start(self, ten_env: AsyncTenEnv) -> None:
24+
await super().on_start(ten_env)
25+
26+
# initialize configuration
27+
self.config = {{class_name_prefix}}Config.create(ten_env=ten_env)
28+
ten_env.log_info(f"config: {self.config}")
29+
30+
"""Implement this method to construct and start your resources."""
31+
ten_env.log_debug("TODO: on_start")
32+
33+
async def on_stop(self, ten_env: AsyncTenEnv) -> None:
34+
await super().on_stop(ten_env)
35+
36+
"""Implement this method to stop and destruct your resources."""
37+
ten_env.log_debug("TODO: on_stop")
38+
39+
def get_tool_metadata(self, ten_env: TenEnv) -> list[LLMToolMetadata]:
40+
ten_env.log_debug("TODO: get_tool_metadata")
41+
return []
42+
43+
async def run_tool(self, ten_env: AsyncTenEnv, name: str, args: dict) -> LLMToolResult:
44+
ten_env.log_debug(f"TODO: run_tool {name} {args}")

manifest.json

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"type": "extension",
3+
"name": "default_async_llm_tool_extension_python",
4+
"version": "0.1.0",
5+
"dependencies": [
6+
{
7+
"type": "system",
8+
"name": "ten_ai_base",
9+
"version": "0.1.0"
10+
}
11+
],
12+
"package": {
13+
"include": [
14+
"manifest.json",
15+
"property.json",
16+
"requirements.txt",
17+
"**.tent",
18+
"**.py",
19+
"README.md"
20+
]
21+
},
22+
"api": {
23+
"property": {},
24+
"cmd_in": [
25+
{
26+
"name": "tool_call",
27+
"property": {
28+
"name": {
29+
"type": "string"
30+
},
31+
"arguments": {
32+
"type": "string"
33+
}
34+
},
35+
"required": [
36+
"name",
37+
"arguments"
38+
],
39+
"result": {
40+
"property": {
41+
"tool_result": {
42+
"type": "string"
43+
}
44+
},
45+
"required": [
46+
"tool_result"
47+
]
48+
}
49+
}
50+
],
51+
"cmd_out": [
52+
{
53+
"name": "tool_register",
54+
"property": {
55+
"tool": {
56+
"type": "string"
57+
}
58+
},
59+
"required": [
60+
"tool"
61+
]
62+
}
63+
]
64+
}
65+
}

manifest.json.tent

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"type": "extension",
3+
"name": "{{package_name}}",
4+
"version": "0.1.0",
5+
"dependencies": [
6+
{
7+
"type": "system",
8+
"name": "ten_ai_base",
9+
"version": "0.1.0"
10+
}
11+
],
12+
"package": {
13+
"include": [
14+
"manifest.json",
15+
"property.json",
16+
"requirements.txt",
17+
"**.tent",
18+
"**.py",
19+
"README.md"
20+
]
21+
},
22+
"api": {
23+
"property": {},
24+
"cmd_in": [
25+
{
26+
"name": "tool_call",
27+
"property": {
28+
"name": {
29+
"type": "string"
30+
},
31+
"arguments": {
32+
"type": "string"
33+
}
34+
},
35+
"required": [
36+
"name",
37+
"arguments"
38+
],
39+
"result": {
40+
"property": {
41+
"tool_result": {
42+
"type": "string"
43+
}
44+
},
45+
"required": [
46+
"tool_result"
47+
]
48+
}
49+
}
50+
],
51+
"cmd_out": [
52+
{
53+
"name": "tool_register",
54+
"property": {
55+
"tool": {
56+
"type": "string"
57+
}
58+
},
59+
"required": [
60+
"tool"
61+
]
62+
}
63+
]
64+
}
65+
}

property.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

requirements.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)