How is chat record formatted? Is there any functionality or interface provided to upload a chat record? And from user interface, is there any interface to upload chat record by uploading some formatted .csv file etc?
By the way, is there some way to load a predefined prompt for LLM for just a few special chat, not all chats?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
From the context provided, chat records in Open WebUI are stored as JSON objects. Here's the relevant structure from the ChatModel definition in chats.py:
python
class ChatModel(BaseModel):
id: str
user_id: str
title: str
chat: dict # The actual chat content as a dictionary
created_at: int # Timestamp in epoch
updated_at: int # Timestamp in epoch
share_id: Optional[str] = None
archived: bool = False
pinned: Optional[bool] = False
meta: dict = {} # Metadata, including tags
folder_id: Optional[str] = None
Key Fields:
id: Unique identifier for the chat.
user_id: The user who owns the chat.
title: Title of the chat.
chat: Contains the actual conversation data in a dictionary.
meta: Metadata, such as tags or other useful information.
2. Uploading a Chat Record
Yes, Open WebUI provides functionality to upload chat records via an API endpoint.
API for Importing Chats
In the backend, the function import_chat in routers/chats.py handles the import of chat records:
There isn’t explicit mention of a UI for uploading chat records via a .csv or similar file. However:
The chat import functionality is API-driven, meaning it could be extended to support file uploads by transforming the file (e.g., .csv or .json) into the required JSON format and sending it to the /chats/import endpoint.
This could be implemented using a simple file upload dialog in the frontend and a parser to convert the file's content into the required structure.
3. Predefining Prompts for Specific Chats
Yes, there is a way to load predefined prompts for specific chats.
Prompts Integration
Open WebUI supports custom prompts through its prompts.py and prompts/index.ts interfaces. You can define a specific prompt and use it for selected chats.
Steps to Use Predefined Prompts for Special Chats
Create a New Prompt:
Use the /prompts/create endpoint to define a new prompt specifically for your special chats.
Example payload for creating a prompt:
json
{
"command": "/special_prompt",
"title": "Special Chat Prompt",
"content": "This is a predefined instruction for special chats.",
"access_control": null
}
Apply the Prompt in Chats:
When starting a new chat or updating an existing one, include the predefined prompt's content as the initial message or system instruction.
You can call /prompts/command/{command} to retrieve the predefined prompt and inject it into the chat's chat field.
Frontend Implementation:
The frontend can integrate this by providing a dropdown or selection interface to choose a predefined prompt when starting a chat.
Using Prompts for Specific Chats Only
Prompts are not globally applied to all chats. They need to be explicitly loaded via the frontend or backend when creating/updating a chat. This allows you to restrict their use to specific chats.
Summary
Chat Record Format:
Chat records are stored as JSON objects with fields like id, user_id, title, chat, and meta.
Uploading Chat Records:
Chats can be uploaded via the /chats/import API endpoint using a ChatImportForm JSON payload.
There is no direct support for file uploads like .csv, but this can be implemented by parsing the file and sending the data to the endpoint.
Predefined Prompts for Special Chats:
Prompts can be created and applied to specific chats using the /prompts API.
Prompts are not globally applied and must be explicitly loaded for the relevant chats.
If you need further customization, these features can be extended in both the backend and frontend.