-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: Enterprise WeChat docking sub application cannot output thinking process #2489
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
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 |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ def to_block_response(self, chat_id, chat_record_id, content, is_end, completion | |
| other_params = {} | ||
| data = ChatCompletion(id=chat_record_id, choices=[ | ||
| BlockChoice(finish_reason='stop', index=0, chat_id=chat_id, | ||
| reasoning_content=other_params.get('reasoning_content', ""), | ||
| answer_list=other_params.get('answer_list', ""), | ||
| message=ChatCompletionMessage(role='assistant', content=content))], | ||
| created=datetime.datetime.now().second, model='', object='chat.completion', | ||
| usage=CompletionUsage(completion_tokens=completion_tokens, | ||
|
Contributor
Author
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. The provided code snippet seems mostly correct, but there are a few minor adjustments and clarifications that can be made to ensure it works as intended:
Here’s the code with these points addressed: import datetime
def to_block_response(self, chat_id, chat_record_id, content, is_end, completion_tokens, other_params):
# Using get() to safely retrieve reasoning_content from other_params
reasoning_content = other_params.get('reasoning_content', "")
# Similarly, use get() to safely retrieve answer_list from other_params
answer_list = other_params.get('answer_list', [])
data = ChatCompletion(
id=chat_record_id,
choices=[
BlockChoice(
finish_reason='stop',
index=0,
chat_id=chat_id,
reasoning_content=reasoning_content,
- answer_list answer_list,
message=ChatCompletionMessage(role='assistant', content=content)
)
],
created=datetime.datetime.now().timestamp(),
model='',
object='chat.completion',
usage=CompletionUsage(completion_tokens=completion_tokens)
)
# Example usage with an empty list for completeness
example_other_params = {}
to_block_response("id_123", "record_1", "Hello!", True, 20, example_other_params)This should prevent any runtime errors related to missing keys in the |
||
|
|
||
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.
Here are the identified issues and potential improvements:
Issues:
Variable Access:
node_variable['application_node_dict']is accessing a variable namedresponse, which does not exist at that stage of the function execution. This will likely raise an error.Answer List Handling:
${{answer.get('real_node_id')contains interpolation syntax, but it's missing the opening brace{.node_variable['application_node_dict']seems incorrect because both keys ("real_node_id"and"index") should be included in each entry.Function Parameters:
_write_context()isworkflow, but there is no such parameter defined in the original code snippet you provided.Potential Improvements:
Correct Variable Name:
responsevariable is correctly referenced if needed or removed if unnecessary.Fix Template Syntax:
${{answer.get('real_node_id')}}with simplyanswer.get('real_node_id').Re-evaluate Data Structure:
node_variable['application_node_dict']. If you mean to store different types of data under'actual_node_id', adjust the dictionary accordingly.Parameter Correctness:
_write_context()match those expected, and add any necessary parameters that might have been omitted from the previous version.Error Handling:
'prompt_tokens', 'content', ..., 'might not always be available in theresponse.Without additional context on how these variables interact, some further refinement may be required.