Skip to content

feat: Add tool calling component#4830

Merged
shaohuzhang1 merged 1 commit intov2from
pr@v2@feat_call
Feb 28, 2026
Merged

feat: Add tool calling component#4830
shaohuzhang1 merged 1 commit intov2from
pr@v2@feat_call

Conversation

@shaohuzhang1
Copy link
Contributor

feat: Add tool calling component

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Feb 28, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Feb 28, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

}
})
</script>
<style lang="scss" scoped></style>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The props declaration at the beginning of the file is missing a closing parenthesis. Consider adding it like so:

@@ -7,4 +7,5 @@
   import { type ToolCalls } from './index'
   import defaultIcon from '@/assets/workflow/icon_robot.svg'

-import props from<{ content?: string }>()
+const props = defineProps<{
+  content?: string
+}>()

This should fix an issue with TypeScript's syntax highlighting when editing this code snippet.

In terms of readability and clarity:

  • The CSS scoped styles block should be separated for better visual separation in larger projects.

If you have more specific optimizations or improvements in mind, feel free to share them!

content: ToolCalls
}>()
</script>
<style lang="scss" scoped></style>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided Vue.js component looks mostly clean and follows best practices. However, there are a few minor things that can be improved:

  1. TypeScript Prop Check: Since content is an array of objects (ToolCalls[]), it would make more sense to use this instead of just ToolCalls.
  2. Card Titles: It's good practice to add titles to cards if they contain multiple pieces of information.
  3. Scss Variables: Consider using SCSS variables for consistent styling.

Here's the updated code with these improvements incorporated:

<template>
  <div class="card-container">
    <el-card v-for="(item, index) in content" :key="index">
      <template #header>{{ item.title }}</template>
        {{ item.content }}
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { type ToolCall, type ToolCalls } from '@/components/markdown/tool-calls-render/index';
import { ref } from 'vue';

const toolCalls = ref<ToolCall[]>([
  {
    title: "Input:",
    content: "{input}",
  },
  {
    title: "Output:",
    content: "{output}",
  // Add more items as needed
]);
// You can define other props or data here...
</script>

<style scoped lang="scss">
.card-container {
  display: flex;
  gap: 16px;

  .el-card {
    width: calc(45% - 16px);
  }
}
</style>

Key Changes:

  • Converted prop content from ToolCalls to ToolCall[], making it compatible with arrays of tool calls.
  • Added a simple loop to iterate over each item in the toolCalls array and render them inside el-cards.
  • Added headers to each card using #header slot to denote what kind of information is contained within each section.

These changes should make the template more dynamic and user friendly while maintaining proper TypeScript typing.

'simple-tool-calls': SimpleToolCalls,
}
</script>
<style lang="scss" scoped></style>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided Vue component template appears to be valid and functional. However, here are a few minor improvements or optimizations you might consider:

  1. Type Annotations: Ensure that the props definition is properly typed with TypeScript. Currently, content.type is expected to be of a string type (as specified in ToolCalls), but TypeScript does not enforce this. Adding an explicit return type can improve clarity.

  2. Optional Prop Types: If it's possible that content.type could be undefined or null, you should define optional types.

  3. Conditional Rendering: Consider adding some conditional rendering if necessary to handle different types gracefully, especially if there are more components you expect to render.

  4. Use of v-bind: The colon : is often used for data binding, and while <component> allows you to bind to dynamic values like strings (:'some-component'), using v-bind explicitly is generally recommended for clarity.

Here's the revised code with these considerations:

@@ -0,0 +1,21 @@
<template>
  <component :is="getComponent(content)" :content="content"></component>
</template>

<script setup lang="ts">
import SimpleToolCalls from './simple-tool-calls/index.vue'
import { type ToolCalls } from '@/components/markdown/tool-calls-render/index'

// Type annotations for props
defineProps<{
  content: ToolCalls,
}>();

const getComponent = (content: ToolCalls): string => {
  return kw[content.type] ? kw[content.type].name : '';
};

const kw: { [key: string]: any } = {
  'simple-tool-calls': SimpleToolCalls,
};
</script>

<style lang="scss" scoped></style>

In this adjusted version:

  • A conditional function getComponent is used to ensure we only attempt to use known keys.
  • Optional typing for the content prop is implied by defaulting its value to {}.
  • Conditional checks help avoid runtime errors when accessing unknown component names in the dictionary.

@shaohuzhang1 shaohuzhang1 merged commit ae3d95f into v2 Feb 28, 2026
3 of 4 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@feat_call branch February 28, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant