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
ff493d01
Unverified
Commit
ff493d01
authored
Oct 11, 2023
by
takatost
Committed by
GitHub
Oct 11, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: minimax tests (#1313)
parent
7f6ad965
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
69 deletions
+4
-69
check_no_chinese_comments.py
.github/workflows/check_no_chinese_comments.py
+0
-37
check_no_chinese_comments.yml
.github/workflows/check_no_chinese_comments.yml
+0
-31
test_minimax_provider.py
...tests/unit_tests/model_providers/test_minimax_provider.py
+4
-1
No files found.
.github/workflows/check_no_chinese_comments.py
deleted
100644 → 0
View file @
7f6ad965
import
os
import
re
from
zhon.hanzi
import
punctuation
def
has_chinese_characters
(
text
):
for
char
in
text
:
if
'
\u4e00
'
<=
char
<=
'
\u9fff
'
or
char
in
punctuation
:
return
True
return
False
def
check_file_for_chinese_comments
(
file_path
):
with
open
(
file_path
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
for
line_number
,
line
in
enumerate
(
file
,
start
=
1
):
if
has_chinese_characters
(
line
):
print
(
f
"Found Chinese characters in {file_path} on line {line_number}:"
)
print
(
line
.
strip
())
return
True
return
False
def
main
():
has_chinese
=
False
excluded_files
=
[
"model_template.py"
,
'stopwords.py'
,
'commands.py'
,
'indexing_runner.py'
,
'web_reader_tool.py'
,
'spark_provider.py'
,
'prompts.py'
]
for
root
,
_
,
files
in
os
.
walk
(
"."
):
for
file
in
files
:
if
file
.
endswith
(
".py"
)
and
file
not
in
excluded_files
:
file_path
=
os
.
path
.
join
(
root
,
file
)
if
check_file_for_chinese_comments
(
file_path
):
has_chinese
=
True
if
has_chinese
:
raise
Exception
(
"Found Chinese characters in Python files. Please remove them."
)
if
__name__
==
"__main__"
:
main
()
.github/workflows/check_no_chinese_comments.yml
deleted
100644 → 0
View file @
7f6ad965
name
:
Check for Chinese comments
on
:
push
:
branches
:
-
'
main'
pull_request
:
branches
:
-
main
jobs
:
check-chinese-comments
:
runs-on
:
ubuntu-latest
steps
:
-
name
:
Check out repository
uses
:
actions/checkout@v2
-
name
:
Set up Python
uses
:
actions/setup-python@v2
with
:
python-version
:
3.9
-
name
:
Install dependencies
run
:
|
python -m pip install --upgrade pip
pip install zhon
-
name
:
Run script to check for Chinese comments
run
:
|
python .github/workflows/check_no_chinese_comments.py
api/tests/unit_tests/model_providers/test_minimax_provider.py
View file @
ff493d01
...
...
@@ -2,6 +2,8 @@ import pytest
from
unittest.mock
import
patch
import
json
from
langchain.schema
import
ChatResult
,
ChatGeneration
,
AIMessage
from
core.model_providers.providers.base
import
CredentialsValidateFailedError
from
core.model_providers.providers.minimax_provider
import
MinimaxProvider
from
models.provider
import
ProviderType
,
Provider
...
...
@@ -24,7 +26,8 @@ def decrypt_side_effect(tenant_id, encrypted_key):
def
test_is_provider_credentials_valid_or_raise_valid
(
mocker
):
mocker
.
patch
(
'langchain.llms.minimax.Minimax._call'
,
return_value
=
'abc'
)
mocker
.
patch
(
'core.third_party.langchain.llms.minimax_llm.MinimaxChatLLM._generate'
,
return_value
=
ChatResult
(
generations
=
[
ChatGeneration
(
message
=
AIMessage
(
content
=
'abc'
))]))
MODEL_PROVIDER_CLASS
.
is_provider_credentials_valid_or_raise
(
VALIDATE_CREDENTIAL
)
...
...
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