Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
671 changes: 671 additions & 0 deletions docs/how-to/chatbots/extending-ui.md

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions examples/chat/offline_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from collections.abc import AsyncGenerator
from typing import Literal

from fastapi import UploadFile
from pydantic import BaseModel, ConfigDict, Field

from ragbits.chat.interface import ChatInterface
Expand Down Expand Up @@ -150,3 +151,25 @@ async def chat(
yield self.create_text_response(chunk)

yield self.create_followup_messages(["Example Response 1", "Example Response 2", "Example Response 3"])

async def upload_handler(self, file: UploadFile) -> None: # noqa: PLR6301
"""
Handle file uploads.

Args:
file: The uploaded file (FastAPI UploadFile)
"""
# Read the file content
content = await file.read()
file_size = len(content)
filename = file.filename

# In a real application, you might process the file, ingest it into a vector store, etc.
# Here we just print some info to the console.
print(f"Received file: {filename}, size: {file_size} bytes")

# Note: The upload_handler doesn't return a response to the chat stream directly.
# The frontend receives a success status.
# If you want to notify the user in the chat, the user would usually send a message
# mentioning they uploaded a file, or you could potentially trigger something else.
# Currently the flow is: UI uploads -> Backend handles -> UI gets 200 OK.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ nav:
- "Setup guardrails": how-to/guardrails/use_guardrails.md
- Chatbots:
- "Setup API & UI": how-to/chatbots/api.md
- "Extend and customize the UI": how-to/chatbots/extending-ui.md
- Evaluate:
- "Evaluate pipelines": how-to/evaluate/evaluate.md
- "Agent simulation": how-to/evaluate/agent_simulation.md
Expand Down
1 change: 1 addition & 0 deletions packages/ragbits-chat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

## Unreleased
- Decoupling of components from ragbits specific logic. Introduction of slot based plugin architecture. Minimal history store implementation (#917)
- Add timezone field to ChatContext, automatically populated from browser (#916)
- Fix PostgreSQL conversation persistence by ensuring session flush after creating new conversation in SQL storage (#903)
- Add file upload ingestion support with `upload_handler` in `ChatInterface` and `/api/upload` endpoint in `RagbitsAPI`.
Expand Down
1 change: 1 addition & 0 deletions packages/ragbits-chat/src/ragbits/chat/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ async def config() -> JSONResponse:
auth_types=auth_types,
oauth2_providers=oauth2_providers,
),
supports_upload=self.chat_interface.upload_handler is not None,
)

return JSONResponse(content=config_response.model_dump())
Expand Down
1 change: 1 addition & 0 deletions packages/ragbits-chat/src/ragbits/chat/interface/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ class ConfigResponse(BaseModel):
feedback: FeedbackConfig = Field(..., description="Feedback configuration")
customization: UICustomization | None = Field(default=None, description="UI customization")
user_settings: UserSettings = Field(default_factory=UserSettings, description="User settings")
supports_upload: bool = Field(default=False, description="Flag indicating whether API supports file upload")
debug_mode: bool = Field(default=False, description="Debug mode flag")
conversation_history: bool = Field(default=False, description="Flag to enable conversation history")
show_usage: bool = Field(default=False, description="Flag to enable usage statistics")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Loading