浏览代码

get config default for sandbox (#3508)

Co-authored-by: miendinh <miendinh@users.noreply.github.com>
miendinh 1 年之前
父节点
当前提交
b9fbc39754
共有 2 个文件被更改,包括 6 次插入5 次删除
  1. 2 2
      api/config.py
  2. 4 3
      api/core/helper/code_executor/code_executor.py

+ 2 - 2
api/config.py

@@ -64,8 +64,8 @@ DEFAULTS = {
     'ETL_TYPE': 'dify',
     'ETL_TYPE': 'dify',
     'KEYWORD_STORE': 'jieba',
     'KEYWORD_STORE': 'jieba',
     'BATCH_UPLOAD_LIMIT': 20,
     'BATCH_UPLOAD_LIMIT': 20,
-    'CODE_EXECUTION_ENDPOINT': '',
-    'CODE_EXECUTION_API_KEY': '',
+    'CODE_EXECUTION_ENDPOINT': 'http://sandbox:8194',
+    'CODE_EXECUTION_API_KEY': 'dify-sandbox',
     'TOOL_ICON_CACHE_MAX_AGE': 3600,
     'TOOL_ICON_CACHE_MAX_AGE': 3600,
     'MILVUS_DATABASE': 'default',
     'MILVUS_DATABASE': 'default',
     'KEYWORD_DATA_SOURCE_TYPE': 'database',
     'KEYWORD_DATA_SOURCE_TYPE': 'database',

+ 4 - 3
api/core/helper/code_executor/code_executor.py

@@ -1,17 +1,17 @@
-from os import environ
 from typing import Literal, Optional
 from typing import Literal, Optional
 
 
 from httpx import post
 from httpx import post
 from pydantic import BaseModel
 from pydantic import BaseModel
 from yarl import URL
 from yarl import URL
 
 
+from config import get_env
 from core.helper.code_executor.javascript_transformer import NodeJsTemplateTransformer
 from core.helper.code_executor.javascript_transformer import NodeJsTemplateTransformer
 from core.helper.code_executor.jina2_transformer import Jinja2TemplateTransformer
 from core.helper.code_executor.jina2_transformer import Jinja2TemplateTransformer
 from core.helper.code_executor.python_transformer import PythonTemplateTransformer
 from core.helper.code_executor.python_transformer import PythonTemplateTransformer
 
 
 # Code Executor
 # Code Executor
-CODE_EXECUTION_ENDPOINT = environ.get('CODE_EXECUTION_ENDPOINT', '')
-CODE_EXECUTION_API_KEY = environ.get('CODE_EXECUTION_API_KEY', '')
+CODE_EXECUTION_ENDPOINT = get_env('CODE_EXECUTION_ENDPOINT')
+CODE_EXECUTION_API_KEY = get_env('CODE_EXECUTION_API_KEY')
 
 
 CODE_EXECUTION_TIMEOUT= (10, 60)
 CODE_EXECUTION_TIMEOUT= (10, 60)
 
 
@@ -27,6 +27,7 @@ class CodeExecutionResponse(BaseModel):
     message: str
     message: str
     data: Data
     data: Data
 
 
+
 class CodeExecutor:
 class CodeExecutor:
     @classmethod
     @classmethod
     def execute_code(cls, language: Literal['python3', 'javascript', 'jinja2'], code: str, inputs: dict) -> dict:
     def execute_code(cls, language: Literal['python3', 'javascript', 'jinja2'], code: str, inputs: dict) -> dict: