Skip to content

Commit

Permalink
Merge pull request #325 from tomasliu-agora/dev/bing_search
Browse files Browse the repository at this point in the history
use conversion for tool_call and add bing search
  • Loading branch information
tomasliu-agora authored Oct 12, 2024
2 parents 4df66b8 + 1169ece commit c393a87
Show file tree
Hide file tree
Showing 10 changed files with 420 additions and 3 deletions.
99 changes: 97 additions & 2 deletions agents/property.json
Original file line number Diff line number Diff line change
Expand Up @@ -2251,6 +2251,15 @@
"property": {
"api_key": "${env:WEATHERAPI_API_KEY}"
}
},
{
"type": "extension",
"extension_group": "tools",
"addon": "bingsearch_tool_python",
"name": "bingsearch_tool_python",
"property": {
"api_key": "${env:BING_API_KEY}"
}
}
],
"connections": [
Expand Down Expand Up @@ -2284,6 +2293,21 @@
}
]
},
{
"extension_group": "tools",
"extension": "bingsearch_tool_python",
"cmd": [
{
"name": "tool_register",
"dest": [
{
"extension_group": "llm",
"extension": "openai_v2v_python"
}
]
}
]
},
{
"extension_group": "llm",
"extension": "openai_v2v_python",
Expand Down Expand Up @@ -2320,11 +2344,82 @@
]
},
{
"name": "tool_call",
"name": "tool_call_get_current_weather",
"dest": [
{
"extension_group": "tools",
"extension": "weatherapi_tool_python",
"msg_conversion": {
"type": "per_property",
"keep_original": true,
"rules": [
{
"path": "_ten.name",
"conversion_mode": "fixed_value",
"value": "tool_call"
}
]
}
}
]
},
{
"name": "tool_call_get_past_weather",
"dest": [
{
"extension_group": "tools",
"extension": "weatherapi_tool_python",
"msg_conversion": {
"type": "per_property",
"keep_original": true,
"rules": [
{
"path": "_ten.name",
"conversion_mode": "fixed_value",
"value": "tool_call"
}
]
}
}
]
},
{
"name": "tool_call_get_future_weather",
"dest": [
{
"extension_group": "tools",
"extension": "weatherapi_tool_python",
"msg_conversion": {
"type": "per_property",
"keep_original": true,
"rules": [
{
"path": "_ten.name",
"conversion_mode": "fixed_value",
"value": "tool_call"
}
]
}
}
]
},
{
"name": "tool_call_bing_search",
"dest": [
{
"extension_group": "tools",
"extension": "weatherapi_tool_python"
"extension": "bingsearch_tool_python",
"msg_conversion": {
"type": "per_property",
"keep_original": true,
"rules": [
{
"path": "_ten.name",
"conversion_mode": "fixed_value",
"value": "tool_call"
}
]
}
}
]
}
Expand Down
21 changes: 21 additions & 0 deletions agents/ten_packages/extension/bingsearch_tool_python/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
#
# Agora Real Time Engagement
# Created by Wei Hu in 2022-11.
# Copyright (c) 2024 Agora IO. All rights reserved.
#
#
import("//build/feature/ten_package.gni")

ten_package("bingsearch_tool_python") {
package_kind = "extension"

resources = [
"__init__.py",
"addon.py",
"extension.py",
"log.py",
"manifest.json",
"property.json",
]
}
29 changes: 29 additions & 0 deletions agents/ten_packages/extension/bingsearch_tool_python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# bingsearch_tool_python

<!-- 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 -->
11 changes: 11 additions & 0 deletions agents/ten_packages/extension/bingsearch_tool_python/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
#
# Agora Real Time Engagement
# Created by Wei Hu in 2024-08.
# Copyright (c) 2024 Agora IO. All rights reserved.
#
#
from . import addon
from .log import logger

logger.info("bingsearch_tool_python extension loaded")
22 changes: 22 additions & 0 deletions agents/ten_packages/extension/bingsearch_tool_python/addon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
#
# Agora Real Time Engagement
# Created by Wei Hu in 2024-08.
# Copyright (c) 2024 Agora IO. All rights reserved.
#
#
from ten import (
Addon,
register_addon_as_extension,
TenEnv,
)
from .extension import BingSearchToolExtension
from .log import logger


@register_addon_as_extension("bingsearch_tool_python")
class BingSearchToolExtensionAddon(Addon):

def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None:
logger.info("BingSearchToolExtensionAddon on_create_instance")
ten_env.on_create_instance_done(BingSearchToolExtension(name), context)
Loading

0 comments on commit c393a87

Please sign in to comment.