Skip to content

Commit

Permalink
feat: support glm extension
Browse files Browse the repository at this point in the history
  • Loading branch information
plutoless committed Jan 24, 2025
1 parent 5f6657d commit 3a0f1e8
Show file tree
Hide file tree
Showing 13 changed files with 2,030 additions and 38 deletions.
48 changes: 10 additions & 38 deletions agents/examples/default/property.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,18 +512,20 @@
{
"type": "extension",
"name": "v2v",
"addon": "openai_v2v_python",
"addon": "glm_v2v_python",
"extension_group": "llm",
"property": {
"api_key": "${env:OPENAI_REALTIME_API_KEY}",
"temperature": 0.9,
"model": "gpt-4o-realtime-preview-2024-12-17",
"max_tokens": 2048,
"voice": "alloy",
"api_key": "${env:GLM_API_KEY}",
"base_uri": "wss://open.bigmodel.cn",
"dump": true,
"enable_storage": false,
"history": 10,
"language": "en-US",
"max_tokens": 2048,
"model": "gpt-4o-realtime-preview",
"server_vad": true,
"dump": true,
"max_history": 10
"temperature": 0.9,
"voice": "alloy"
}
},
{
Expand All @@ -532,15 +534,6 @@
"addon": "message_collector",
"extension_group": "transcriber",
"property": {}
},
{
"type": "extension",
"name": "weatherapi_tool_python",
"addon": "weatherapi_tool_python",
"extension_group": "default",
"property": {
"api_key": "${env:WEATHERAPI_API_KEY|}"
}
}
],
"connections": [
Expand Down Expand Up @@ -593,14 +586,6 @@
"extension": "agora_rtc"
}
]
},
{
"name": "tool_call",
"dest": [
{
"extension": "weatherapi_tool_python"
}
]
}
],
"data": [
Expand Down Expand Up @@ -636,19 +621,6 @@
]
}
]
},
{
"extension": "weatherapi_tool_python",
"cmd": [
{
"name": "tool_register",
"dest": [
{
"extension": "v2v"
}
]
}
]
}
]
},
Expand Down
20 changes: 20 additions & 0 deletions agents/ten_packages/extension/glm_v2v_python/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
#
# 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_v2v_python") {
package_kind = "extension"

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

An extension for integrating OpenAI's Next Generation of **Multimodal** AI into your application, providing configurable AI-driven features such as conversational agents, task automation, and tool integration.

## Features

<!-- main features introduction -->

- OpenAI **Multimodal** Integration: Leverage GPT **Multimodal** models for voice to voice as well as text processing.
- Configurable: Easily customize API keys, model settings, prompts, temperature, etc.
- Async Queue Processing: Supports real-time message processing with task cancellation and prioritization.
<!-- - Tool Support: Integrate external tools like image recognition via OpenAI's API. -->

## 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 -->

| **Property** | **Type** | **Description** |
|----------------------------|------------|-------------------------------------------|
| `api_key` | `string` | API key for authenticating with OpenAI |
| `temperature` | `float64` | Sampling temperature, higher values mean more randomness |
| `model` | `string` | Model identifier (e.g., GPT-3.5, GPT-4) |
| `max_tokens` | `int64` | Maximum number of tokens to generate |
| `system_message` | `string` | Default system message to send to the model |
| `voice` | `string` | Voice that OpenAI model speeches, such as `alloy`, `echo`, `shimmer`, etc |
| `server_vad` | `bool` | Flag to enable or disable server vad of OpenAI |
| `language` | `string` | Language that OpenAO model reponds, such as `en-US`, `zh-CN`, etc |
| `dump` | `bool` | Flag to enable or disable audio dump for debugging purpose |

### Data Out:
| **Name** | **Property** | **Type** | **Description** |
|----------------|--------------|------------|-------------------------------|
| `text_data` | `text` | `string` | Outgoing text data |

### Command Out:
| **Name** | **Description** |
|----------------|---------------------------------------------|
| `flush` | Response after flushing the current state |

### Audio Frame In:
| **Name** | **Description** |
|------------------|-------------------------------------------|
| `pcm_frame` | Audio frame input for voice processing |

### Audio Frame Out:
| **Name** | **Description** |
|------------------|-------------------------------------------|
| `pcm_frame` | Audio frame output after voice processing |


### Azure Support

This extension also support Azure OpenAI Service, the propoerty settings are as follow:

``` json
{
"base_uri": "wss://xxx.openai.azure.com",
"path": "/openai/realtime?api-version=xxx&deployment=xxx",
"api_key": "xxx",
"model": "gpt-4o-realtime-preview",
"vendor": "azure"
}
```
8 changes: 8 additions & 0 deletions agents/ten_packages/extension/glm_v2v_python/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
#
# Agora Real Time Engagement
# Created by Wei Hu in 2024-08.
# Copyright (c) 2024 Agora IO. All rights reserved.
#
#
from . import addon
22 changes: 22 additions & 0 deletions agents/ten_packages/extension/glm_v2v_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,
)


@register_addon_as_extension("glm_v2v_python")
class GLMRealtimeExtensionAddon(Addon):

def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None:
from .extension import GLMRealtimeExtension

ten_env.log_info("GLMRealtimeExtensionAddon on_create_instance")
ten_env.on_create_instance_done(GLMRealtimeExtension(name), context)
Loading

0 comments on commit 3a0f1e8

Please sign in to comment.