Skip to content
Closed
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
37 changes: 32 additions & 5 deletions api/controllers/service_api/dataset/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,31 @@


class DocumentListApi(DatasetApiResource):
"""Resource for documents."""

"""
Resource for documents.
Request example:
POST /v1/documents
Headers: Authorization: Bearer dataset-xxx
Body:
{
"name": "api_insert_data_name",
"doc_type": "im_chat_log",
"doc_metadata": {
"chat_platform": "lt",
"chat_participants/group_name": "7d202b9bf50da74c084baae18b39944b",
"start_date": "2023-07-12",
"end_date": "2023-07-12",
"participants": "shaddock",
"topicsKeywords": "topic1",
"fileType": "text"
},
"text": "data...\n"
}
:return: The created document_id
{
"id": "a80560e5-ebe4-4f2c-8941-3ec9dbe81722"
}
"""
def post(self, dataset):
"""Create document."""
parser = reqparse.RequestParser()
Expand All @@ -44,7 +67,7 @@ def post(self, dataset):
file_key = 'upload_files/' + dataset.tenant_id + '/' + file_uuid + '.txt'

# save file to storage
storage.save(file_key, args.get('text'))
storage.save(file_key, args.get('text').encode())

# save file to db
config = current_app.config
Expand All @@ -69,9 +92,13 @@ def post(self, dataset):
document_data = {
'data_source': {
'type': 'upload_file',
'info': [
'info_list': [
{
'upload_file_id': upload_file.id
'file_info_list': {
'file_ids': [
upload_file.id
]
}
}
]
}
Expand Down
5 changes: 4 additions & 1 deletion web/app/components/app/overview/embedded/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ const OPTION_MAP = {
scripts: {
getContent: (url: string, token: string, isTestEnv?: boolean) =>
`<script>
window.difyChatbotConfig = { token: '${token}'${isTestEnv ? ', isDev: true' : ''} }
window.difyChatbotConfig = {
// baseUrl: '${url}', // self-host need set.
token: '${token}'${isTestEnv ? ',isDev: true' : ''}
}
</script>
<script
src="${url}/embed.min.js"
Expand Down