deep-chat icon indicating copy to clipboard operation
deep-chat copied to clipboard

How to use responseInterceptor in vue?

Open mountain-three opened this issue 5 months ago • 2 comments

this is my code,it does not work,any problem with it?

<template>
  <div>
    <h1>Deep Chat</h1>
    <!-- demo/textInput are examples of passing an object directly into a property -->
    <!-- history is an example of passing a data object into a property -->
    <deep-chat
      :demo.prop="true"
      :textInput.prop="{ placeholder: { text: 'Welcome to the demo!' } }"
      :history.prop="history"
      :responseInterceptor="responseInterceptor"
    />
  </div>
</template>

<script>
// If this example does not load the component, try the following:
// https://stackblitz.com/edit/vue2-vue-cli-2rdjuu?file=src%2FApp.vue
import "deep-chat";

export default {
  data() {
    return {
      history: [
        { role: "user", text: "Hey, how are you today?" },
        { role: "ai", text: "I am doing very well!" },
      ],
    };
  },
  methods: {
    responseInterceptor(response) {
      console.log("Response:", response);
      return response;
    },
  },
};
</script>

<style>
div {
  font-family: sans-serif;
  text-align: center;
  justify-content: center;
  display: grid;
}
</style>

mountain-three avatar Jun 19 '25 07:06 mountain-three