Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
b3186283
Commit
b3186283
authored
Jun 21, 2023
by
John Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: uuid json dumps bug
parent
8b6bf432
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
app.py
api/app.py
+10
-0
keyword_table_index.py
api/core/index/keyword_table_index/keyword_table_index.py
+4
-1
No files found.
api/app.py
View file @
b3186283
# -*- coding:utf-8 -*-
import
os
import
uuid
from
datetime
import
datetime
if
not
os
.
environ
.
get
(
"DEBUG"
)
or
os
.
environ
.
get
(
"DEBUG"
)
.
lower
()
!=
'true'
:
...
...
@@ -183,6 +184,15 @@ if app.config['TESTING']:
print
(
"App is running in TESTING mode"
)
def
uuid_encoder
(
self
,
obj
):
if
isinstance
(
obj
,
uuid
.
UUID
):
return
str
(
obj
)
raise
TypeError
(
f
"Object of type '{type(obj)}' is not JSON serializable"
)
json
.
JSONEncoder
.
default
=
uuid_encoder
@
app
.
after_request
def
after_request
(
response
):
"""Add Version headers to the response."""
...
...
api/core/index/keyword_table_index/keyword_table_index.py
View file @
b3186283
import
json
import
uuid
from
collections
import
defaultdict
from
typing
import
Any
,
List
,
Optional
,
Dict
...
...
@@ -235,4 +236,6 @@ class SetEncoder(json.JSONEncoder):
def
default
(
self
,
obj
):
if
isinstance
(
obj
,
set
):
return
list
(
obj
)
return
super
()
.
default
(
obj
)
\ No newline at end of file
elif
isinstance
(
obj
,
uuid
.
UUID
):
return
str
(
obj
)
return
super
()
.
default
(
obj
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment