-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat: AI dialogue roles support obtaining data from other nodes #1925
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,8 @@ def execute(self, model_id, system, prompt, dialogue_number, history_chat_record | |
self.context['history_message'] = history_message | ||
question = self.generate_prompt_question(prompt) | ||
self.context['question'] = question.content | ||
system = self.workflow_manage.generate_prompt(system) | ||
self.context['system'] = question.content | ||
message_list = self.generate_message_list(system, prompt, history_message) | ||
self.context['message_list'] = message_list | ||
if stream: | ||
|
@@ -138,7 +140,7 @@ def get_details(self, index: int, **kwargs): | |
'name': self.node.properties.get('stepName'), | ||
"index": index, | ||
'run_time': self.context.get('run_time'), | ||
'system': self.node_params.get('system'), | ||
'system': self.context.get('system'), | ||
'history_message': [{'content': message.content, 'role': message.type} for message in | ||
(self.context.get('history_message') if self.context.get( | ||
'history_message') is not None else [])], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a few issues in the code you've provided:
Overall, make sure that |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided C# code snippet appears to be part of an AI dialog execution function within a workflow management system. Here are some potential improvements and suggestions:
Potential Issues:
Duplicate
system
Variable Assignment: Thesystem
variable is assigned twice before use. This can lead to confusion or unintended behavior because the second assignment does not change the original value.Unnecessary Condition Check: After assigning
self.context['system']
, there's an unnecessary condition check to ensurequestion.content
is notNone
.Simplify Stream Handling: Ensure that the rest of the logic handling
stream
does not rely on whetherquestion.content
exists.Consistent Access Patterns: Decide whether to access context via
self.context[key]
or through specific method calls (node_properties
, etc.). Consistency will make the code easier to maintain.Here’s an improved version of the code incorporating these suggestions:
This updated version removes the redundant assignment of
system
, simplifies the stream handling block, and aims for consistent key access patterns.