Open
Description
Feature description
Goal of this task is to create a minimal wrapper around typical use-case that we develop - chat interface. ChatInterface should allow to get standardized inputs and stream text and rich elements.
Input:
message
: current message from the userhistory
: previous messages in the converationcontext
: anything extra coming from API (for example user info)
Output (yields):
str
: Regular text responses streamed chunk by chunkReference
: Source documents used to generate the answerLiveUpdate
: Status updates during processing (tool-call, searching, etc.)Action
: Suggested actions for the user to take (follow-up questions, write action, etc.)
Motivation
While #330 will provide a generic approach to define workflows, we still need a dead simple way of orchestrating any chat-like workload without forcing users to write code in any specific way.
Idea behind ChatInterface is to provide light-weight guidelines what input and output can be handled in such scenario and allow user to write any code using components already provided in ragbits.
Additional context
class SimpleChatImplementation(ChatInterface):
"""A simple example implementation of the ChatInterface that demonstrates different response types."""
async def chat(
self,
message: str,
history: list[Message] | None = None,
context: dict | None = None,
) -> AsyncGenerator[ChatResponse, None]:
yield self.create_live_update(
message="Searching for relevant documents...",
)
references = await get_document_search().search(message)
for reference in references:
yield self.create_reference(reference)
for word in "Hello my name is John Doe, I'm a software engineer and I'm looking for a new job. Please help me find a new job.".split():
yield self.create_text_response(word + " ")
await asyncio.sleep(0.05)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Backlog