Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions agentrun/memory_collection/__memory_collection_async_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,27 @@ async def to_mem0_memory_async(

@staticmethod
def _convert_vpc_endpoint_to_public(endpoint: str) -> str:
"""将 VPC 内网地址转换为公网地址
"""根据运行环境决定是否将 VPC 内网地址转换为公网地址

在云上(FC_REGION 环境变量存在)保持 VPC 地址不变,
在本地(FC_REGION 不存在)将 VPC 地址转换为公网地址。

Args:
endpoint: 原始 endpoint,可能是 VPC 内网地址

Returns:
str: 公网地址
str: 根据环境返回 VPC 地址或公网地址

Example:
>>> _convert_vpc_endpoint_to_public("https://jiuqing.cn-hangzhou.vpc.tablestore.aliyuncs.com")
"https://jiuqing.cn-hangzhou.ots.aliyuncs.com"
"https://jiuqing.cn-hangzhou.ots.aliyuncs.com" # 本地环境
"""
import os

is_running_on_fc = os.getenv("FC_REGION") is not None
if is_running_on_fc:
return endpoint
if ".vpc.tablestore.aliyuncs.com" in endpoint:
# 将 .vpc.tablestore.aliyuncs.com 替换为 .ots.aliyuncs.com
return endpoint.replace(
".vpc.tablestore.aliyuncs.com", ".ots.aliyuncs.com"
)
Expand Down
15 changes: 11 additions & 4 deletions agentrun/memory_collection/memory_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,20 +521,27 @@ def to_mem0_memory(

@staticmethod
def _convert_vpc_endpoint_to_public(endpoint: str) -> str:
"""将 VPC 内网地址转换为公网地址
"""根据运行环境决定是否将 VPC 内网地址转换为公网地址

在云上(FC_REGION 环境变量存在)保持 VPC 地址不变,
在本地(FC_REGION 不存在)将 VPC 地址转换为公网地址。

Args:
endpoint: 原始 endpoint,可能是 VPC 内网地址

Returns:
str: 公网地址
str: 根据环境返回 VPC 地址或公网地址

Example:
>>> _convert_vpc_endpoint_to_public("https://jiuqing.cn-hangzhou.vpc.tablestore.aliyuncs.com")
"https://jiuqing.cn-hangzhou.ots.aliyuncs.com"
"https://jiuqing.cn-hangzhou.ots.aliyuncs.com" # 本地环境
"""
import os

is_running_on_fc = os.getenv("FC_REGION") is not None
if is_running_on_fc:
return endpoint
if ".vpc.tablestore.aliyuncs.com" in endpoint:
# 将 .vpc.tablestore.aliyuncs.com 替换为 .ots.aliyuncs.com
return endpoint.replace(
".vpc.tablestore.aliyuncs.com", ".ots.aliyuncs.com"
)
Expand Down
Loading