You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 user
history: previous messages in the converation
context: anything extra coming from API (for example user info)
Output (yields):
str: Regular text responses streamed chunk by chunk
Reference: Source documents used to generate the answer
LiveUpdate: 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
classSimpleChatImplementation(ChatInterface):
"""A simple example implementation of the ChatInterface that demonstrates different response types."""asyncdefchat(
self,
message: str,
history: list[Message] |None=None,
context: dict|None=None,
) ->AsyncGenerator[ChatResponse, None]:
yieldself.create_live_update(
message="Searching for relevant documents...",
)
references=awaitget_document_search().search(message)
forreferenceinreferences:
yieldself.create_reference(reference)
forwordin"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():
yieldself.create_text_response(word+" ")
awaitasyncio.sleep(0.05)
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: