Skip to content

Commit

Permalink
Fix langstudio pre env
Browse files Browse the repository at this point in the history
  • Loading branch information
wwxxzz committed Jan 17, 2025
1 parent 8696675 commit 74c2dbf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/pai_rag/integrations/embeddings/pai/langstudio_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def get_connection_info(region_id: str, connection_name: str, workspace_id: str)


def convert_langstudio_embed_config(embed_config):
load_and_setup_env()
region_id = embed_config.region_id or get_region_id()
conn_info, config, secrets = get_connection_info(
region_id, embed_config.connection_name, embed_config.workspace_id
Expand All @@ -98,3 +99,19 @@ def convert_langstudio_embed_config(embed_config):
)
else:
raise ValueError(f"Unknown connection type: {conn_info.custom_type}")


def load_and_setup_env():
# hack: setup pre env service hosts
# TODO: remove this hack after production service is ready
if not os.getenv("PAI_ENVIRONMENT", "").lower() == "pre":
return
logger.warning("Try to setup environment for pre env...")
with open("/etc/hosts", "a") as f:
f.write("\n")
f.write(
"100.103.108.19 pailangstudio.cn-hangzhou.aliyuncs.com pailangstudio-vpc.cn-hangzhou.aliyuncs.com\n"
)
f.write(
"100.103.108.19 aiworkspace.cn-hangzhou.aliyuncs.com aiworkspace-vpc.cn-hangzhou.aliyuncs.com\n"
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from loguru import logger

RAG_PARSER_CPU_REQUIRED = 6
RAG_PARSER_CPU_REQUIRED = 4
RAG_PARSER_MEM_REQUIRED = 8 # GB

RAG_SPLITTER_CPU_REQUIRED = 2
Expand Down

0 comments on commit 74c2dbf

Please sign in to comment.