-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: Unable to clear the last call result after the tool workflow call returns #4937
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 |
|---|---|---|
|
|
@@ -129,7 +129,7 @@ const details = { | |
| const activeName = ref<string>('result') | ||
| const currentToolId = ref<string>() | ||
| const currentData = ref<any>({}) | ||
|
|
||
| const emit = defineEmits(['close']) | ||
| const output = computed(() => { | ||
| if (toolRecord.value) { | ||
| return toolRecord.value.meta.output | ||
|
|
@@ -246,6 +246,7 @@ const open = (toolId: string, data: any) => { | |
| } | ||
| const close = () => { | ||
| ChatManagement.close(currentChat.id) | ||
| emit('close') | ||
| resultDrawer.value = false | ||
| toolRecord.value = null | ||
| currentChat.value = { | ||
|
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. There are no immediate irregularities or major issues with the provided code. Here are some minor suggestions for optimization:
Here is an optimized version of your code: const details = { ... };
const activeName = ref<string>('result');
const currentToolId = ref<string>('');
const currentData = ref<{} | undefined>(); // Replace any with a more appropriate type
const emit = defineEmits(['close']);
const output = computed(() => {
if (!toolRecord.value) return '';
return toolRecord.value.meta?.output || '';
});
const open = (toolId: string, data?: Record<string, unknown>) => {
chatManagement.open(chat.value);
// Add additional logic here as needed
}
const close = () => {
ChatManagement.close(current-chat.chatId);
emit('close');
resultDrawer.value = false;
toolRecord.value = null;
}Summary:
|
||
|
|
||
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 current code has the following suggestions for improvement:
Dynamic Key Usage:
Consider removing the
:key="index"attribute since it's not necessary when the component is re-rendered due to other changes.Function Redundancy:
The
closeResultfunction currently increments theindex, which might not be intended behavior unless there's a specific reason for updating a reactive variable each time the dialog closes.Form Validation and Input Field List Check:
Ensure that validation on form submission handles cases where the input field list is empty gracefully.
Avoid Unnecessary Imports:
For example, importing unused package
numberfrom ECharts can be removed.Optimize Code Flow:
Simplify some logic flow, especially related to handling user inputs or responses within a tool execution.
Here's an optimized version of the code with these considerations:
Key Changes:
@key="index"fromResultDrawer.next()andback()methods for state management and improved readability.These adjustments should improve the robustness and maintainability of the given Vue.js component.