File tree Expand file tree Collapse file tree 5 files changed +56
-13
lines changed
Expand file tree Collapse file tree 5 files changed +56
-13
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
2- import Markdown from " @/components/Markdown.vue" ;
32import AssistantFunctionCall from " @/components/messages/AssistantFunctionCall.vue" ;
3+ import MessageContent from " @/components/messages/MessageContent.vue" ;
44import type { ChatMessage } from " @/redel/models" ;
55
66const props = defineProps <{
@@ -16,9 +16,7 @@ const props = defineProps<{
1616 </p >
1717 </figure >
1818 <div class =" media-content" >
19- <div class =" content allow-wrap-anywhere" v-if =" message.content" >
20- <Markdown :content =" props.message.content!" />
21- </div >
19+ <MessageContent v-if =" message.content" :content =" props.message.content!" />
2220 <!-- function call -->
2321 <div v-if =" message.tool_calls" >
2422 <AssistantFunctionCall :function-call =" tc.function" v-for =" tc in message.tool_calls" />
Original file line number Diff line number Diff line change 1+ <script setup lang="ts">
2+ import Markdown from " @/components/Markdown.vue" ;
3+ import { computed } from " vue" ;
4+
5+ const props = defineProps <{
6+ content: string | any [] | null ;
7+ }>();
8+
9+ const contentParts = computed (() => {
10+ if (typeof props .content === " string" ) {
11+ return [props .content ];
12+ } else if (! props .content ) {
13+ return [];
14+ }
15+
16+ let parts: any [] = [];
17+ let lastStringContent = " " ;
18+ for (const part of props .content ) {
19+ if (typeof part === " string" ) {
20+ lastStringContent += part ;
21+ } else {
22+ if (lastStringContent ) {
23+ parts .push (lastStringContent );
24+ lastStringContent = " " ;
25+ }
26+ parts .push (part );
27+ }
28+ }
29+ if (lastStringContent ) {
30+ parts .push (lastStringContent );
31+ }
32+
33+ return parts ;
34+ });
35+ </script >
36+
37+ <template >
38+ <div class =" content allow-wrap-anywhere" >
39+ <template v-for =" part in contentParts " >
40+ <Markdown v-if =" typeof part === 'string'" :content =" part" />
41+ <details v-else >
42+ <summary >Unrendered data</summary >
43+ <pre >{{ part }}</pre >
44+ </details >
45+ </template >
46+ </div >
47+ </template >
48+
49+ <style scoped lang="scss"></style >
Original file line number Diff line number Diff line change 11<script setup lang="ts">
2- import Markdown from " @/components/Markdown .vue" ;
2+ import MessageContent from " @/components/messages/MessageContent .vue" ;
33import type { ChatMessage } from " @/redel/models" ;
44
55const props = defineProps <{
@@ -10,9 +10,7 @@ const props = defineProps<{
1010<template >
1111 <div class =" system-message" >
1212 <div class =" box has-text-centered mx-4 p-2" >
13- <div class =" content allow-wrap-anywhere" >
14- <Markdown :content =" props.message.content!" />
15- </div >
13+ <MessageContent v-if =" message.content" :content =" props.message.content!" />
1614 </div >
1715 </div >
1816</template >
Original file line number Diff line number Diff line change 11<script setup lang="ts">
2- import Markdown from " @/components/Markdown .vue" ;
2+ import MessageContent from " @/components/messages/MessageContent .vue" ;
33import type { ChatMessage } from " @/redel/models" ;
44
55const props = defineProps <{
@@ -15,9 +15,7 @@ const props = defineProps<{
1515 </p >
1616 </figure >
1717 <div class =" media-content" >
18- <div class =" content allow-wrap-anywhere" >
19- <Markdown :content =" props.message.content!" />
20- </div >
18+ <MessageContent v-if =" message.content" :content =" props.message.content!" />
2119 </div >
2220 </div >
2321</template >
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export interface ToolCall {
2626
2727export interface ChatMessage {
2828 role : ChatRole ;
29- content : string | null ;
29+ content : string | object [ ] | null ;
3030 name : string | null ;
3131 tool_call_id : string | null ;
3232 tool_calls : ToolCall [ ] | null ;
You can’t perform that action at this time.
0 commit comments