reasonmethis/docdocgo-core

How to use the core engine standalone?

Closed this issue · 3 comments

Hi - do you have any guidance on using docdocgo-core such that UI changes/customizations can be made independently of the back end (such that they won't be wiped when upgrading). Perhaps the Streamlit side could be wrapped in a module of sorts (a Streamlit client library) which other hosting Streamlit apps can use. There could be a client state object that is available for the host app to retrieve data values (or can be notified via a host-supplied callback). The client lib would also allow doc collections to be switched. A hosting app might use the new st.partial to avoid reruns in itself when interactions occur in the docdocgo-core client lib component.

Just some thoughts.

It's a great idea to create a more modular architecture. I have been planning along similar lines recently, since I would like to integrate the core logic into Telegram, Discord, Slack etc. The version of DocDocGo I sold to a company was integrated with a Google Chat App, but since then there have been a great many new features added, so I'll need to think carefully how I will reorganize things to facilitate such integrations. I haven't started down this road yet because I have been heavily focused on improving the research functionality and other core features, but it may soon be time to start.

For now, if you'd like, we can add the customizations you mentioned as options controllable by environment variables and/or settings in the UI itself. The word-by-word "slow write" is probably better than my current way anyway, since it's more similar to how streaming text appears.

There's no hurry. I can see you're not being hacky.

Here's the slow write code that works quite well:

def write_slowly(message_placeholder, answer):
    """Write a message to the message placeholder slowly, word by word."""
    delay = min(0.0025, 2 / (len(answer) + 1))
    for i in range(1, len(answer) + 1):
        if answer[i - 1] == " ":
            message_placeholder.markdown(fix_markdown(answer[:i]))
            time.sleep(delay)