Quansight / ragna

RAG orchestration framework ⛵️
https://ragna.chat
BSD 3-Clause "New" or "Revised" License
177 stars 22 forks source link

Load message history to core chat from schema chat #429

Closed blakerosenthal closed 3 months ago

blakerosenthal commented 3 months ago

Basic prereq for passing chat history down the pipeline. History is already present in the schema.Chat object loaded from the database, so we just need to make sure it also gets loaded into the ragna.core.Chat object inside schema_to_core_chat.

https://github.com/Quansight/ragna/blob/647a61e3103cb2e54b7c5bc2da5df1e2906b059b/ragna/deploy/_api/core.py#L290-L297

blakerosenthal commented 3 months ago

@pmeier Mypy points out that you can't construct a ragna.core.Document from a schema.Document because it's missing the metadata field. I see a couple ways around that:

  1. Add a metadata field to schema.Document, although it seems like that might interact weirdly with the multi-document code that's strewn around that keeps the documents and metadata separate. It would create some redundancies to clean up, but I think it could be nice to just have metadata on the schema object.
  2. Cascade all the object conversions directly in schema_to_core_chat kind of like the functions found in database.py.

I'm leaning toward option 1 unless there's a simpler way.

pmeier commented 3 months ago

Ah yeah, I'm hitting the same on a another branch as well. I agree we should go with option 1 especially in the light of #256.

No need to duplicate work here. Just set metadata={} and add a comment that this will be resolved later.