chore(api/tests): apply ruff reformat #7590 (#7591)

Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
Bowen Liang
2024-08-23 23:52:25 +08:00
committed by GitHub
parent 2da63654e5
commit b035c02f78
155 changed files with 4279 additions and 5925 deletions

View File

@@ -14,19 +14,15 @@ def test_validate_credentials():
with pytest.raises(CredentialsValidateFailedError):
model.validate_credentials(
model='hunyuan-standard',
credentials={
'secret_id': 'invalid_key',
'secret_key': 'invalid_key'
}
model="hunyuan-standard", credentials={"secret_id": "invalid_key", "secret_key": "invalid_key"}
)
model.validate_credentials(
model='hunyuan-standard',
model="hunyuan-standard",
credentials={
'secret_id': os.environ.get('HUNYUAN_SECRET_ID'),
'secret_key': os.environ.get('HUNYUAN_SECRET_KEY')
}
"secret_id": os.environ.get("HUNYUAN_SECRET_ID"),
"secret_key": os.environ.get("HUNYUAN_SECRET_KEY"),
},
)
@@ -34,23 +30,16 @@ def test_invoke_model():
model = HunyuanLargeLanguageModel()
response = model.invoke(
model='hunyuan-standard',
model="hunyuan-standard",
credentials={
'secret_id': os.environ.get('HUNYUAN_SECRET_ID'),
'secret_key': os.environ.get('HUNYUAN_SECRET_KEY')
"secret_id": os.environ.get("HUNYUAN_SECRET_ID"),
"secret_key": os.environ.get("HUNYUAN_SECRET_KEY"),
},
prompt_messages=[
UserPromptMessage(
content='Hi'
)
],
model_parameters={
'temperature': 0.5,
'max_tokens': 10
},
stop=['How'],
prompt_messages=[UserPromptMessage(content="Hi")],
model_parameters={"temperature": 0.5, "max_tokens": 10},
stop=["How"],
stream=False,
user="abc-123"
user="abc-123",
)
assert isinstance(response, LLMResult)
@@ -61,23 +50,15 @@ def test_invoke_stream_model():
model = HunyuanLargeLanguageModel()
response = model.invoke(
model='hunyuan-standard',
model="hunyuan-standard",
credentials={
'secret_id': os.environ.get('HUNYUAN_SECRET_ID'),
'secret_key': os.environ.get('HUNYUAN_SECRET_KEY')
},
prompt_messages=[
UserPromptMessage(
content='Hi'
)
],
model_parameters={
'temperature': 0.5,
'max_tokens': 100,
'seed': 1234
"secret_id": os.environ.get("HUNYUAN_SECRET_ID"),
"secret_key": os.environ.get("HUNYUAN_SECRET_KEY"),
},
prompt_messages=[UserPromptMessage(content="Hi")],
model_parameters={"temperature": 0.5, "max_tokens": 100, "seed": 1234},
stream=True,
user="abc-123"
user="abc-123",
)
assert isinstance(response, Generator)
@@ -93,19 +74,17 @@ def test_get_num_tokens():
model = HunyuanLargeLanguageModel()
num_tokens = model.get_num_tokens(
model='hunyuan-standard',
model="hunyuan-standard",
credentials={
'secret_id': os.environ.get('HUNYUAN_SECRET_ID'),
'secret_key': os.environ.get('HUNYUAN_SECRET_KEY')
"secret_id": os.environ.get("HUNYUAN_SECRET_ID"),
"secret_key": os.environ.get("HUNYUAN_SECRET_KEY"),
},
prompt_messages=[
SystemPromptMessage(
content='You are a helpful AI assistant.',
content="You are a helpful AI assistant.",
),
UserPromptMessage(
content='Hello World!'
)
]
UserPromptMessage(content="Hello World!"),
],
)
assert num_tokens == 14