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.
The chat record in Open WebUI is formatted as a JSON object, which is stored in the database. The JSON object contains information such as the chat ID, user ID, title, chat history, and other metadata.
Regarding uploading a chat record, Open WebUI provides an API endpoint to import a chat. This endpoint accepts a JSON payload containing the chat data, which is then stored in the database.
In terms of uploading a chat record from a file, Open WebUI does not provide a direct interface to upload a .csv file. However, you can create a custom script to read the .csv file, convert it to the required JSON format, and then use the import chat API endpoint to upload the chat record.
To load a predefined prompt for LLM for just a few special chats, you can use the "Prompts" feature in Open WebUI. Prompts allow you to define custom commands that can be used to trigger specific actions or responses from the LLM. You can create a prompt with a specific command and associate it with a particular chat or set of chats.
Here's an example of how you can create a prompt:
Go to the "Prompts" page in the Open WebUI interface.
Click on the "Create New Prompt" button.
Enter a command for the prompt (e.g., /special-chat-prompt).
Define the prompt's behavior, such as the response to be generated by the LLM.
Associate the prompt with a specific chat or set of chats.
Once you've created the prompt, you can use the command to trigger the predefined response from the LLM in the specified chats.
Here's an example of how you can use the import chat API endpoint to upload a chat record:
bash
curl -X POST \
http://localhost:8080/chats/import \
-H 'Content-Type: application/json' \
-d '{
"chat": {
"title": "Example Chat",
"history": [
{
"user": "User1",
"message": "Hello!"
},
{
"assistant": "Assistant",
"message": "Hi! How can I help you?"
}
]
}
}'
Note that this is just an example, and you'll need to modify the JSON payload to match the format expected by the import chat API endpoint.
As for uploading a .csv file, you'll need to create a custom script to read the file, convert it to the required JSON format, and then use the import chat API endpoint to upload the chat record. Here's an example of how you can do this using Python:
python
import csv
import json
# Read the .csv file
with open('example.csv', 'r') as csvfile:
reader = csv.DictReader(csvfile)
chat_data = []
for row in reader:
chat_data.append({
'user': row['User'],
'message': row['Message']
})
# Convert the chat data to the required JSON format
chat_json = {
'chat': {
'title': 'Example Chat',
'history': chat_data
}
}
# Use the import chat API endpoint to upload the chat record
import requests
response = requests.post('http://localhost:8080/chats/import', json=chat_json)
if response.status_code == 200:
print('Chat record uploaded successfully!')
else:
print('Error uploading chat record:', response.text)
Note that this is just an example, and you'll need to modify the script to match your specific requirements.