Skip to content

refactor(tools): Avoid warnings. #10161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions api/core/tools/provider/builtin/chart/chart.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
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
Expand Down