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
0e239a4f
Unverified
Commit
0e239a4f
authored
Jan 04, 2024
by
newsouther
Committed by
GitHub
Jan 04, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: read file encoding error (#1902)
Co-authored-by:
maple
<
1071520@gi
>
parent
ca85b0af
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
7 deletions
+7
-7
extensible.py
api/core/extension/extensible.py
+2
-2
ai_model.py
api/core/model_runtime/model_providers/__base/ai_model.py
+2
-2
model_provider.py
...re/model_runtime/model_providers/__base/model_provider.py
+1
-1
model_provider_factory.py
...e/model_runtime/model_providers/model_provider_factory.py
+1
-1
prompt_transform.py
api/core/prompt/prompt_transform.py
+1
-1
No files found.
api/core/extension/extensible.py
View file @
0e239a4f
...
...
@@ -61,7 +61,7 @@ class Extensible:
builtin_file_path
=
os
.
path
.
join
(
subdir_path
,
'__builtin__'
)
if
os
.
path
.
exists
(
builtin_file_path
):
with
open
(
builtin_file_path
,
'r'
)
as
f
:
with
open
(
builtin_file_path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
position
=
int
(
f
.
read
()
.
strip
())
if
(
extension_name
+
'.py'
)
not
in
file_names
:
...
...
@@ -93,7 +93,7 @@ class Extensible:
json_path
=
os
.
path
.
join
(
subdir_path
,
'schema.json'
)
json_data
=
{}
if
os
.
path
.
exists
(
json_path
):
with
open
(
json_path
,
'r'
)
as
f
:
with
open
(
json_path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
json_data
=
json
.
load
(
f
)
extensions
[
extension_name
]
=
ModuleExtension
(
...
...
api/core/model_runtime/model_providers/__base/ai_model.py
View file @
0e239a4f
...
...
@@ -147,13 +147,13 @@ class AIModel(ABC):
# read _position.yaml file
position_map
=
{}
if
os
.
path
.
exists
(
position_file_path
):
with
open
(
position_file_path
,
'r'
)
as
f
:
with
open
(
position_file_path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
position_map
=
yaml
.
safe_load
(
f
)
# traverse all model_schema_yaml_paths
for
model_schema_yaml_path
in
model_schema_yaml_paths
:
# read yaml data from yaml file
with
open
(
model_schema_yaml_path
,
'r'
)
as
f
:
with
open
(
model_schema_yaml_path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
yaml_data
=
yaml
.
safe_load
(
f
)
new_parameter_rules
=
[]
...
...
api/core/model_runtime/model_providers/__base/model_provider.py
View file @
0e239a4f
...
...
@@ -47,7 +47,7 @@ class ModelProvider(ABC):
yaml_path
=
os
.
path
.
join
(
current_path
,
f
'{provider_name}.yaml'
)
yaml_data
=
{}
if
os
.
path
.
exists
(
yaml_path
):
with
open
(
yaml_path
,
'r'
)
as
f
:
with
open
(
yaml_path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
yaml_data
=
yaml
.
safe_load
(
f
)
try
:
...
...
api/core/model_runtime/model_providers/model_provider_factory.py
View file @
0e239a4f
...
...
@@ -212,7 +212,7 @@ class ModelProviderFactory:
# read _position.yaml file
position_map
=
{}
if
os
.
path
.
exists
(
position_file_path
):
with
open
(
position_file_path
,
'r'
)
as
f
:
with
open
(
position_file_path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
position_map
=
yaml
.
safe_load
(
f
)
# traverse all model_provider_dir_paths
...
...
api/core/prompt/prompt_transform.py
View file @
0e239a4f
...
...
@@ -207,7 +207,7 @@ class PromptTransform:
json_file_path
=
os
.
path
.
join
(
prompt_path
,
f
'{prompt_name}.json'
)
# Open the JSON file and read its content
with
open
(
json_file_path
,
'r'
)
as
json_file
:
with
open
(
json_file_path
,
'r'
,
encoding
=
'utf-8'
)
as
json_file
:
return
json
.
load
(
json_file
)
def
_get_simple_chat_app_chat_model_prompt_messages
(
self
,
prompt_rules
:
dict
,
...
...
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