refactor(tools): Avoid warnings. (#10161)

This commit is contained in:
-LAN- 2024-11-01 17:17:27 +08:00 committed by Joel
parent 07787366cd
commit 8f14c422a7
2 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,5 @@
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
@ -17,9 +17,10 @@ def set_chinese_font():
]
for font in font_list:
chinese_font = FontProperties(font)
if chinese_font.get_name() == font:
return chinese_font
if font in fontManager.ttflist:
chinese_font = FontProperties(font)
if chinese_font.get_name() == font:
return chinese_font
return FontProperties()

View File

@ -2,14 +2,17 @@ import concurrent.futures
import io
import random
from typing import Any, Literal, Optional, Union
from warnings import catch_warnings
import openai
from pydub import AudioSegment
from core.tools.entities.tool_entities import ToolInvokeMessage
from core.tools.errors import ToolParameterValidationError, ToolProviderCredentialValidationError
from core.tools.tool.builtin_tool import BuiltinTool
with catch_warnings(action="ignore", category=RuntimeWarning):
from pydub import AudioSegment
class PodcastAudioGeneratorTool(BuiltinTool):
@staticmethod