Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
8b6bf432
Commit
8b6bf432
authored
Jun 21, 2023
by
John Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: ignore llm print when not debug mode
parent
84519c6c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
1 deletion
+25
-1
agent_loop_gather_callback_handler.py
...re/callback_handler/agent_loop_gather_callback_handler.py
+1
-0
dataset_tool_callback_handler.py
api/core/callback_handler/dataset_tool_callback_handler.py
+1
-1
llm_callback_handler.py
api/core/callback_handler/llm_callback_handler.py
+1
-0
main_chain_gather_callback_handler.py
...re/callback_handler/main_chain_gather_callback_handler.py
+1
-0
std_out_callback_handler.py
api/core/callback_handler/std_out_callback_handler.py
+21
-0
No files found.
api/core/callback_handler/agent_loop_gather_callback_handler.py
View file @
8b6bf432
...
...
@@ -12,6 +12,7 @@ from core.conversation_message_task import ConversationMessageTask
class
AgentLoopGatherCallbackHandler
(
BaseCallbackHandler
):
"""Callback Handler that prints to std out."""
raise_error
:
bool
=
True
def
__init__
(
self
,
model_name
,
conversation_message_task
:
ConversationMessageTask
)
->
None
:
"""Initialize callback handler."""
...
...
api/core/callback_handler/dataset_tool_callback_handler.py
View file @
8b6bf432
...
...
@@ -3,7 +3,6 @@ import logging
from
typing
import
Any
,
Dict
,
List
,
Union
,
Optional
from
langchain.callbacks.base
import
BaseCallbackHandler
from
langchain.schema
import
AgentAction
,
AgentFinish
,
LLMResult
from
core.callback_handler.entity.dataset_query
import
DatasetQueryObj
from
core.conversation_message_task
import
ConversationMessageTask
...
...
@@ -11,6 +10,7 @@ from core.conversation_message_task import ConversationMessageTask
class
DatasetToolCallbackHandler
(
BaseCallbackHandler
):
"""Callback Handler that prints to std out."""
raise_error
:
bool
=
True
def
__init__
(
self
,
conversation_message_task
:
ConversationMessageTask
)
->
None
:
"""Initialize callback handler."""
...
...
api/core/callback_handler/llm_callback_handler.py
View file @
8b6bf432
...
...
@@ -12,6 +12,7 @@ from core.llm.streamable_open_ai import StreamableOpenAI
class
LLMCallbackHandler
(
BaseCallbackHandler
):
raise_error
:
bool
=
True
def
__init__
(
self
,
llm
:
Union
[
StreamableOpenAI
,
StreamableChatOpenAI
],
conversation_message_task
:
ConversationMessageTask
):
...
...
api/core/callback_handler/main_chain_gather_callback_handler.py
View file @
8b6bf432
...
...
@@ -13,6 +13,7 @@ from core.conversation_message_task import ConversationMessageTask
class
MainChainGatherCallbackHandler
(
BaseCallbackHandler
):
"""Callback Handler that prints to std out."""
raise_error
:
bool
=
True
def
__init__
(
self
,
conversation_message_task
:
ConversationMessageTask
)
->
None
:
"""Initialize callback handler."""
...
...
api/core/callback_handler/std_out_callback_handler.py
View file @
8b6bf432
import
os
import
sys
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Union
...
...
@@ -123,6 +124,26 @@ class DifyStdOutCallbackHandler(BaseCallbackHandler):
"""Run on agent end."""
print_text
(
"[on_agent_finish] "
+
finish
.
return_values
[
'output'
]
+
"
\n
"
,
color
=
'green'
,
end
=
"
\n
"
)
@
property
def
ignore_llm
(
self
)
->
bool
:
"""Whether to ignore LLM callbacks."""
return
not
os
.
environ
.
get
(
"DEBUG"
)
or
os
.
environ
.
get
(
"DEBUG"
)
.
lower
()
!=
'true'
@
property
def
ignore_chain
(
self
)
->
bool
:
"""Whether to ignore chain callbacks."""
return
not
os
.
environ
.
get
(
"DEBUG"
)
or
os
.
environ
.
get
(
"DEBUG"
)
.
lower
()
!=
'true'
@
property
def
ignore_agent
(
self
)
->
bool
:
"""Whether to ignore agent callbacks."""
return
not
os
.
environ
.
get
(
"DEBUG"
)
or
os
.
environ
.
get
(
"DEBUG"
)
.
lower
()
!=
'true'
@
property
def
ignore_chat_model
(
self
)
->
bool
:
"""Whether to ignore chat model callbacks."""
return
not
os
.
environ
.
get
(
"DEBUG"
)
or
os
.
environ
.
get
(
"DEBUG"
)
.
lower
()
!=
'true'
class
DifyStreamingStdOutCallbackHandler
(
DifyStdOutCallbackHandler
):
"""Callback handler for streaming. Only works with LLMs that support streaming."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment