Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/refactor exts #276

Merged
merged 13 commits into from
Sep 17, 2024
3 changes: 1 addition & 2 deletions agents/manifest-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@
"type": "system",
"name": "nlohmann_json",
"version": "3.11.2",
"hash": "72b15822c7ea9deef5e7ad96216ac55e93f11b00466dd1943afd5ee276e99d19",
"supports": []
"hash": "72b15822c7ea9deef5e7ad96216ac55e93f11b00466dd1943afd5ee276e99d19"
},
{
"type": "system",
Expand Down
4 changes: 4 additions & 0 deletions agents/ten_packages/bak/openai_chatgpt_python/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import openai_chatgpt_addon
from .log import logger

logger.info("openai_chatgpt_python extension loaded")
13 changes: 13 additions & 0 deletions agents/ten_packages/bak/openai_chatgpt_python/log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import logging

logger = logging.getLogger("openai_chatgpt_python")
logger.setLevel(logging.INFO)

formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(process)d - [%(filename)s:%(lineno)d] - %(message)s"
)

console_handler = logging.StreamHandler()
console_handler.setFormatter(formatter)

logger.addHandler(console_handler)
93 changes: 93 additions & 0 deletions agents/ten_packages/bak/openai_chatgpt_python/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"type": "extension",
"name": "openai_chatgpt_python",
"version": "0.4.0",
"dependencies": [
{
"type": "system",
"name": "ten_runtime_python",
"version": "0.2"
}
],
"api": {
"property": {
"api_key": {
"type": "string"
},
"frequency_penalty": {
"type": "float64"
},
"presence_penalty": {
"type": "float64"
},
"temperature": {
"type": "float64"
},
"top_p": {
"type": "float64"
},
"model": {
"type": "string"
},
"max_tokens": {
"type": "int64"
},
"base_url": {
"type": "string"
},
"prompt": {
"type": "string"
},
"greeting": {
"type": "string"
},
"checking_vision_text_items": {
"type": "string"
},
"proxy_url": {
"type": "string"
},
"max_memory_length": {
"type": "int64"
},
"enable_tools": {
"type": "bool"
}
},
"data_in": [
{
"name": "text_data",
"property": {
"text": {
"type": "string"
}
}
}
],
"data_out": [
{
"name": "text_data",
"property": {
"text": {
"type": "string"
}
}
}
],
"cmd_in": [
{
"name": "flush"
}
],
"cmd_out": [
{
"name": "flush"
}
],
"video_frame_in": [
{
"name": "video_frame"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
openai
numpy
requests
pillow
asyncio
21 changes: 21 additions & 0 deletions agents/ten_packages/extension/openai_chatgpt_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("openai_chatgpt_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/openai_chatgpt_python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# openai_chatgpt_python

<!-- brief introduction for the extension -->
plutoless marked this conversation as resolved.
Show resolved Hide resolved

## 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 -->
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
from . import openai_chatgpt_addon
#
#
# 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("openai_chatgpt_python extension loaded")
22 changes: 22 additions & 0 deletions agents/ten_packages/extension/openai_chatgpt_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 OpenAIChatGPTExtension
from .log import logger


@register_addon_as_extension("openai_chatgpt_python")
class OpenAIChatGPTExtensionAddon(Addon):

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