upstash / rag-chat

Batteries included SDK for RAG development.
https://upstash.com/docs/vector/sdks/rag-chat/gettingstarted
MIT License
143 stars 30 forks source link

feat: add metadata to PrepareChatResult.context #29

Closed CahidArda closed 1 month ago

CahidArda commented 1 month ago

Makes possible to define onContextFetched like:

const response = await ragChat.chat(question.content,
  {
    streaming: true,
    onContextFetched: (context: PrepareChatResult["context"]) => {
      const result: PrepareChatResult["context"] = context.map(contextBit => {
        return {
          id: contextBit.id,
          data: JSON.stringify({
            text: contextBit.data,
            url: contextBit.metadata.url
          }),
          metadata: contextBit.metadata
        }
      })
      return result
    }
  }
);
CahidArda commented 1 month ago

handled in #33