Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix the error of unable to retrieve url from file (#10498)

Xiao Ley5eb27afd63f2
diff --git a/api/core/file/file_manager.py b/api/core/file/file_manager.py
index eb260a8f84f..389659c292f 100644
--- a/api/core/file/file_manager.py
+++ b/api/core/file/file_manager.py
@@ -26,7 +26,7 @@ def get_attr(*, file: File, attr: FileAttribute):
case FileAttribute.TRANSFER_METHOD:
return file.transfer_method.value
case FileAttribute.URL:
- return file.remote_url
+ return _to_url(file)
case FileAttribute.EXTENSION:
return file.extension
case _:
diff --git a/api/core/tools/provider/builtin/podcast_generator/podcast_generator.yaml b/api/core/tools/provider/builtin/podcast_generator/podcast_generator.yaml
index bd02b32020a..bbae1f81b61 100644
--- a/api/core/tools/provider/builtin/podcast_generator/podcast_generator.yaml
+++ b/api/core/tools/provider/builtin/podcast_generator/podcast_generator.yaml
@@ -32,3 +32,18 @@ credentials_for_provider:
placeholder:
en_US: Enter your TTS service API key
zh_Hans: 输入您的 TTS 服务 API 密钥
+ openai_base_url:
+ type: text-input
+ required: false
+ label:
+ en_US: OpenAI base URL
+ zh_Hans: OpenAI base URL
+ pt_BR: OpenAI base URL
+ help:
+ en_US: Please input your OpenAI base URL
+ zh_Hans: 请输入你的 OpenAI base URL
+ pt_BR: Please input your OpenAI base URL
+ placeholder:
+ en_US: Please input your OpenAI base URL
+ zh_Hans: 请输入你的 OpenAI base URL
+ pt_BR: Please input your OpenAI base URL
diff --git a/api/core/tools/provider/builtin/podcast_generator/tools/podcast_audio_generator.py b/api/core/tools/provider/builtin/podcast_generator/tools/podcast_audio_generator.py
index 476e2d01e1d..8f7d4712cca 100644
--- a/api/core/tools/provider/builtin/podcast_generator/tools/podcast_audio_generator.py
+++ b/api/core/tools/provider/builtin/podcast_generator/tools/podcast_audio_generator.py
@@ -5,6 +5,7 @@ import warnings
from typing import Any, Literal, Optional, Union
import openai
+from yarl import URL
from core.tools.entities.tool_entities import ToolInvokeMessage
from core.tools.errors import ToolParameterValidationError, ToolProviderCredentialValidationError
@@ -60,8 +61,18 @@ class PodcastAudioGeneratorTool(BuiltinTool):
if not api_key:
raise ToolProviderCredentialValidationError("OpenAI API key is missing")
+ # Get OpenAI base URL
+ openai_base_url = self.runtime.credentials.get("openai_base_url", None)
+ if not openai_base_url:
+ openai_base_url = None
+ else:
+ openai_base_url = str(URL(openai_base_url) / "v1")
+
# Initialize OpenAI client
- client = openai.OpenAI(api_key=api_key)
+ client = openai.OpenAI(
+ api_key=api_key,
+ base_url=openai_base_url,
+ )
# Create a thread pool
max_workers = 5