-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (26 loc) · 1.07 KB
/
Copy pathmain.py
File metadata and controls
36 lines (26 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def _patch_dify_plugin():
"""Patch older dify_plugin versions missing LLMResultChunkWithStructuredOutput."""
try:
import dify_plugin.entities.model.llm as _llm
if hasattr(_llm, "LLMResultChunkWithStructuredOutput"):
return
from pydantic import BaseModel
_LLMResultChunk = _llm.LLMResultChunk
class LLMStructuredOutput(BaseModel):
structured_output: dict = {}
class LLMResultChunkWithStructuredOutput(_LLMResultChunk):
structured_output: dict = {}
class LLMResultWithStructuredOutput(_llm.LLMResult):
structured_output: dict = {}
_llm.LLMStructuredOutput = LLMStructuredOutput
_llm.LLMResultChunkWithStructuredOutput = LLMResultChunkWithStructuredOutput
_llm.LLMResultWithStructuredOutput = LLMResultWithStructuredOutput
except Exception:
pass
_patch_dify_plugin()
from dify_plugin import Plugin, DifyPluginEnv
import logging
logging.basicConfig(level=logging.INFO)
plugin = Plugin(DifyPluginEnv())
if __name__ == "__main__":
plugin.run()