chenpei d0dc94e36d feat: 将弹幕功能替换为AI聊天助手
新功能:
- 创建AI聊天助手组件(AIChatWidget)
- 支持文字+图片多模态对话
- 集成Gemini AI API
- 支持图片编辑和内容生成
- 实时对话历史管理
- 优雅的UI设计,支持黑夜模式

技术实现:
- 后端API代理Gemini API(/api/ai-chat)
- 支持最多5张图片上传
- 流式响应处理
- 对话历史管理
- Base64图片处理

配置:
- 在.env中添加Gemini API配置
- GEMINI_API_KEY
- GEMINI_API_BASE_URL
- GEMINI_MODEL

替换原弹幕功能,提供更强大的AI助手体验!
2025-10-27 17:45:37 +08:00

86 lines
2.9 KiB
Python
Executable File

# coding:utf-8
from __future__ import print_function
from volcengine.rdspostgresql.rdspostgresql import RdsPostgreSQL
# test unit : "create_instance" "create_account" "create_white_list" "create_database" "modify_database_owner"
test_unit = "create_instance"
instanceID = "postgres-xxx"
def test_create_instance(cls):
params = {
"Region": "cn-north-x",
"Zone": "cn-north-x-a",
"DBEngine": "PostgreSQL",
"DBEngineVersion": "PostgreSQL_12", # PostgreSQL Version "PostgreSQL_12" "PostgreSQL_11"
"InstanceType": "HA", # Primary isntance should be "HA" Readonly instance should be "Basic"
"InstanceSpecName": "rds.postgres.1c2g", # 1c2g mean 1CPU and 2G Memory
"StorageSpaceGB": 100, # storage(GB)
"Number": 1, # instance number
"StorageType": "LocalSSD", # storage type should be "LocalSSD"
"VpcID": "vpc-xxx",
"ChargeType": "PostPaid", # ChargeType currently should be "PostPaid"
"InstanceCategory": "Primary", # Primary instance type should be "Primary", readonly instance should be "ReadOnly"
"RequestSource": "OpenAPI"
}
print(cls.create_instance(params))
def test_create_account(cls):
params = {
"InstanceId": instanceID,
"AccountName": "user004",
"AccountPassword": "xxx",
"AccountDesc": "",
"AccountType": "Normal", # account type "Super" or "Normal"
}
print(cls.create_account(params))
def test_create_white_list(cls):
params = {
"InstanceId": instanceID,
"GroupName": "hahaha",
"IPList": ["1.1.1.2"],
}
print(cls.create_instance_white_list(params))
def test_create_database(cls):
params = {
"InstanceId": instanceID,
"DBName": "db001",
"CharacterSetName": "utf8", # CharacterSet "utf8" "latin1" or "ascii"
"Collate": "CUTF8", # Collate "C" "CUTF8" or "EnUsUtf8"
"Ctype": "CUTF8", # Ctype "C" "CUTF8" or "EnUsUtf8"
"Owner": "user001",
}
print(cls.create_database(params))
def test_modify_database_owner(cls):
params = {
"InstanceId": instanceID,
"DBName": "db001",
"Owner": "user001",
}
print(cls.modify_database_owner(params))
if __name__ == '__main__':
service = RdsPostgreSQL("cn-north-1")
service.set_ak("Your AK")
service.set_sk("Your SK")
if test_unit == "create_instance":
test_create_instance(service)
elif test_unit == "create_account":
test_create_account(service)
elif test_unit == "create_white_list":
test_create_white_list(service)
elif test_unit == "create_database":
test_create_database(service)
elif test_unit == "modify_database_owner":
test_modify_database_owner(service)