langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
53.37k stars 7.8k forks source link

fix: chart tool chinese font display and raise error #11058

Closed hjlarry closed 6 days ago

hjlarry commented 6 days ago

Summary

[!Tip] Close issue syntax: Fixes #<issue number> or Resolves #<issue number>, see documentation for more details.

fixed 2 errors:

  1. fix https://github.com/langgenius/dify/issues/10777
  2. when you run the tool to generate a bar, then change params to generate another bar will raise:
    [on_tool_start] ToolCall:bar_chart
    {'data': '15000', 'x_axis': '测试汉字'}
    C:\Users\hejl\PycharmProjects\dify\api\core\tools\provider\builtin\chart\tools\bar.py:31: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail.
    flg, ax = plt.subplots(figsize=(10, 8))
    C:\Users\hejl\PycharmProjects\dify\api\core\tools\provider\builtin\chart\tools\bar.py:35: UserWarning: set_ticklabels() should only be used with a fixed number of ticks, i.e. after set_ticks() or using a FixedLocator.
    ax.set_xticklabels(axis, rotation=45, ha="right")
    Exception ignored in: <function Image.__del__ at 0x0000018D0AC99080>
    Traceback (most recent call last):
    File "C:\Users\hejl\.pyenv\pyenv-win\versions\3.12.0\Lib\tkinter\__init__.py", line 4081, in __del__
    self.tk.call('image', 'delete', self.name)
    RuntimeError: main thread is not in main loop
    2024-11-24 21:31:55,681.681 INFO [Thread-9 (process_request_thread)] [_internal.py:97] - 127.0.0.1 - - [25/Nov/2024 13:31:55] "OPTIONS /console/api/apps/d0f351d8-946d-4a62-a074-dc8ac0bf2e11/workflows/draft HTTP/1.1" 200 -
    2024-11-24 21:31:55,710.710 INFO [Thread-11 (process_request_thread)] [_internal.py:97] - 127.0.0.1 - - [25/Nov/2024 13:31:55] "POST /console/api/apps/d0f351d8-946d-4a62-a074-dc8ac0bf2e11/workflows/draft HTTP/1.1" 200 -
    Exception ignored in: <function Variable.__del__ at 0x0000018D0AC02AC0>
    Traceback (most recent call last):
    File "C:\Users\hejl\.pyenv\pyenv-win\versions\3.12.0\Lib\tkinter\__init__.py", line 410, in __del__
    if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    RuntimeError: main thread is not in main loop
    Exception ignored in: <function Variable.__del__ at 0x0000018D0AC02AC0>
    Traceback (most recent call last):
    File "C:\Users\hejl\.pyenv\pyenv-win\versions\3.12.0\Lib\tkinter\__init__.py", line 410, in __del__
    if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    RuntimeError: main thread is not in main loop
    Exception ignored in: <function Variable.__del__ at 0x0000018D0AC02AC0>
    Traceback (most recent call last):
    File "C:\Users\hejl\.pyenv\pyenv-win\versions\3.12.0\Lib\tkinter\__init__.py", line 410, in __del__
    if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    RuntimeError: main thread is not in main loop
    Exception ignored in: <function Variable.__del__ at 0x0000018D0AC02AC0>
    Traceback (most recent call last):
    File "C:\Users\hejl\.pyenv\pyenv-win\versions\3.12.0\Lib\tkinter\__init__.py", line 410, in __del__
    if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    RuntimeError: main thread is not in main loop
    Tcl_AsyncDelete: async handler deleted by the wrong thread

Screenshots

Before: After:

Checklist

[!IMPORTANT]
Please review the checklist below before submitting your pull request.