({
message,
preferJson = false,
}: {
message: ChatCompletionMessage;
preferJson?: boolean;
})
| 22 | }; |
| 23 | |
| 24 | const FormattedMessage = ({ |
| 25 | message, |
| 26 | preferJson = false, |
| 27 | }: { |
| 28 | message: ChatCompletionMessage; |
| 29 | preferJson?: boolean; |
| 30 | }) => { |
| 31 | if (message.tool_calls) { |
| 32 | return ( |
| 33 | <VStack alignItems="flex-start" whiteSpace="pre-wrap" w="full"> |
| 34 | <Text fontWeight="bold" color="gray.500"> |
| 35 | tool_calls |
| 36 | </Text> |
| 37 | {message.tool_calls.map((toolCall, index) => { |
| 38 | const fn = toolCall.function; |
| 39 | |
| 40 | return <HighlightedJson key={index} fnLabel={fn.name} json={fn.arguments} />; |
| 41 | })} |
| 42 | </VStack> |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | if (preferJson) { |
| 47 | return <HighlightedJson json={message.content ?? ""} />; |
| 48 | } |
| 49 | |
| 50 | return ( |
| 51 | <Text whiteSpace="pre-wrap" maxW="full"> |
| 52 | {message.content} |
| 53 | </Text> |
| 54 | ); |
| 55 | }; |
| 56 | |
| 57 | const HighlightedJson = (props: { json: string; fnLabel?: string }) => { |
| 58 | let formattedJson = props.json; |
nothing calls this directly
no outgoing calls
no test coverage detected