-
|
I've noticed that in the destination_results = await asyncio.gather(
*[transition.dst.wrapped_call(ctx) for transition, _ in transitions_with_priorities]
)
for destination in destination_results:
if isinstance(destination, AbsoluteNodeLabel):
return destination
return NoneThis approach seems inefficient and can lead to errors in logs. For example, when using a Even though the system correctly chooses a higher priority transition, it still attempts to execute all transitions, including those that would fail. Questions
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hello!
The main reason is consistency with how conditions and priorities are executed. I agree that in most cases it would be more efficient to execute destinations consecutively since it's not likely that a destination would raise an error. I'll consider adding an option to choose how destinations are executed.
Yes, you can use logging.Filter. Here's an example: import logging
from chatsky.destinations import Backward
from chatsky import Pipeline, TRANSITIONS, Tr, RESPONSE
pipeline = Pipeline(
script={
"flow": {
"node1": {
TRANSITIONS: [Tr(dst="node2"), Tr(dst=Backward())]
},
"node2": {RESPONSE: "Hi"}
}
},
start_label=("flow", "node1"),
fallback_label=("flow", "node2"),
)
class ExcFilter(logging.Filter):
def __init__(self, msg):
super().__init__()
self.msg = msg
def filter(self, record):
if record.exc_info:
return self.msg not in str(record.exc_info[1])
return True
logger = logging.getLogger("chatsky")
handler = logging.StreamHandler()
handler.addFilter(ExcFilter("Consider using the `loop` flag."))
logger.addHandler(handler)
if __name__ == "__main__":
ctx = pipeline("test")
print(ctx.last_response) |
Beta Was this translation helpful? Give feedback.
Hello!
Sorry for the long reply, I was receiving notifications from issues and PRs only, and only now noticed this discussion.
The main reason is consistency with how conditions and priorities are executed.
I agree that in most cases it would be more efficient to execute destinations consecutively since it's not likely that a destination would raise an error. I'll consider adding an option to choose how destinations are e…