diff --git a/public/elements/tind-refs.jsx b/public/elements/tind-refs.jsx new file mode 100644 index 0000000..fd1faa2 --- /dev/null +++ b/public/elements/tind-refs.jsx @@ -0,0 +1,21 @@ +import { + Accordion, + AccordionContent, + AccordionItem, + AccordionTrigger, +} from "@/components/ui/accordion" + +export default function TindRefs () { + return ( + + + Metadata + +

+ {props.tind_message || 'no references supplied'} +

+
+
+
+ ) +} \ No newline at end of file diff --git a/willa/web/app.py b/willa/web/app.py index 3595813..d304cb1 100644 --- a/willa/web/app.py +++ b/willa/web/app.py @@ -38,6 +38,18 @@ async def ocs() -> None: async def on_chat_resume(thread: ThreadDict) -> None: """Resume chat session for data persistence.""" await cl.context.emitter.set_commands(COMMANDS) + + # recreate custom elements from metadata + # results in a duplicate message in data layer!! + # for msg in thread['steps']: + # if 'tind_message' in msg['metadata']: + # tind_refs = cl.CustomElement(name='tind-refs', props=msg['metadata']) + # await cl.Message( + # author='TIND', + # content='References:', + # elements=[tind_refs], + # metadata=msg['metadata'] + # ).send() # pylint: enable="unused-argument" @@ -89,8 +101,22 @@ async def chat(message: cl.Message) -> None: await cl.Message(content=reply['ai_message']).send() if 'tind_message' in reply: - await cl.Message(author='TIND', - content=reply['tind_message']).send() + tind_refs = cl.CustomElement( + name='tind-refs', + props={'tind_message': reply['tind_message']} + ) + msg = cl.Message( + author='TIND', + content='References:', + elements=[tind_refs], + metadata={'tind_message': reply['tind_message']} + ) + await msg.send() + + # print(f"Message ID: {msg.id}") + # print(f"Elements: {msg.elements}") + # print(f"Thread ID: {message.thread_id}") + # print(f"msg: {msg}") if 'no_results' in reply: await cl.Message(author='System', type='system_message',