mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 01:29:01 +08:00
refactor(tools): Avoid warnings. (#10161)
This commit is contained in:
parent
bf048b8d7c
commit
3c85136279
@ -1,5 +1,5 @@
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
from matplotlib.font_manager import FontProperties
|
from matplotlib.font_manager import FontProperties, fontManager
|
||||||
|
|
||||||
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
||||||
|
|
||||||
@ -17,9 +17,10 @@ def set_chinese_font():
|
|||||||
]
|
]
|
||||||
|
|
||||||
for font in font_list:
|
for font in font_list:
|
||||||
chinese_font = FontProperties(font)
|
if font in fontManager.ttflist:
|
||||||
if chinese_font.get_name() == font:
|
chinese_font = FontProperties(font)
|
||||||
return chinese_font
|
if chinese_font.get_name() == font:
|
||||||
|
return chinese_font
|
||||||
|
|
||||||
return FontProperties()
|
return FontProperties()
|
||||||
|
|
||||||
|
@ -2,14 +2,17 @@ import concurrent.futures
|
|||||||
import io
|
import io
|
||||||
import random
|
import random
|
||||||
from typing import Any, Literal, Optional, Union
|
from typing import Any, Literal, Optional, Union
|
||||||
|
from warnings import catch_warnings
|
||||||
|
|
||||||
import openai
|
import openai
|
||||||
from pydub import AudioSegment
|
|
||||||
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
from core.tools.errors import ToolParameterValidationError, ToolProviderCredentialValidationError
|
from core.tools.errors import ToolParameterValidationError, ToolProviderCredentialValidationError
|
||||||
from core.tools.tool.builtin_tool import BuiltinTool
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
with catch_warnings(action="ignore", category=RuntimeWarning):
|
||||||
|
from pydub import AudioSegment
|
||||||
|
|
||||||
|
|
||||||
class PodcastAudioGeneratorTool(BuiltinTool):
|
class PodcastAudioGeneratorTool(BuiltinTool):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user