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,19 @@ def test_validate_credentials():
with pytest.raises(CredentialsValidateFailedError):
model.validate_credentials(
model='meta/llama-2-13b-chat',
model="meta/llama-2-13b-chat",
credentials={
'replicate_api_token': 'invalid_key',
'model_version': 'f4e2de70d66816a838a89eeeb621910adffb0dd0baba3976c96980970978018d'
}
"replicate_api_token": "invalid_key",
"model_version": "f4e2de70d66816a838a89eeeb621910adffb0dd0baba3976c96980970978018d",
},
)
model.validate_credentials(
model='meta/llama-2-13b-chat',
model="meta/llama-2-13b-chat",
credentials={
'replicate_api_token': os.environ.get('REPLICATE_API_KEY'),
'model_version': 'f4e2de70d66816a838a89eeeb621910adffb0dd0baba3976c96980970978018d'
}
"replicate_api_token": os.environ.get("REPLICATE_API_KEY"),
"model_version": "f4e2de70d66816a838a89eeeb621910adffb0dd0baba3976c96980970978018d",
},
)
@@ -34,27 +34,25 @@ def test_invoke_model():
model = ReplicateLargeLanguageModel()
response = model.invoke(
model='meta/llama-2-13b-chat',
model="meta/llama-2-13b-chat",
credentials={
'replicate_api_token': os.environ.get('REPLICATE_API_KEY'),
'model_version': 'f4e2de70d66816a838a89eeeb621910adffb0dd0baba3976c96980970978018d'
"replicate_api_token": os.environ.get("REPLICATE_API_KEY"),
"model_version": "f4e2de70d66816a838a89eeeb621910adffb0dd0baba3976c96980970978018d",
},
prompt_messages=[
SystemPromptMessage(
content='You are a helpful AI assistant.',
content="You are a helpful AI assistant.",
),
UserPromptMessage(
content='Who are you?'
)
UserPromptMessage(content="Who are you?"),
],
model_parameters={
'temperature': 1.0,
'top_k': 2,
'top_p': 0.5,
"temperature": 1.0,
"top_k": 2,
"top_p": 0.5,
},
stop=['How'],
stop=["How"],
stream=False,
user="abc-123"
user="abc-123",
)
assert isinstance(response, LLMResult)
@@ -65,27 +63,25 @@ def test_invoke_stream_model():
model = ReplicateLargeLanguageModel()
response = model.invoke(
model='mistralai/mixtral-8x7b-instruct-v0.1',
model="mistralai/mixtral-8x7b-instruct-v0.1",
credentials={
'replicate_api_token': os.environ.get('REPLICATE_API_KEY'),
'model_version': '2b56576fcfbe32fa0526897d8385dd3fb3d36ba6fd0dbe033c72886b81ade93e'
"replicate_api_token": os.environ.get("REPLICATE_API_KEY"),
"model_version": "2b56576fcfbe32fa0526897d8385dd3fb3d36ba6fd0dbe033c72886b81ade93e",
},
prompt_messages=[
SystemPromptMessage(
content='You are a helpful AI assistant.',
content="You are a helpful AI assistant.",
),
UserPromptMessage(
content='Who are you?'
)
UserPromptMessage(content="Who are you?"),
],
model_parameters={
'temperature': 1.0,
'top_k': 2,
'top_p': 0.5,
"temperature": 1.0,
"top_k": 2,
"top_p": 0.5,
},
stop=['How'],
stop=["How"],
stream=True,
user="abc-123"
user="abc-123",
)
assert isinstance(response, Generator)
@@ -100,19 +96,17 @@ def test_get_num_tokens():
model = ReplicateLargeLanguageModel()
num_tokens = model.get_num_tokens(
model='',
model="",
credentials={
'replicate_api_token': os.environ.get('REPLICATE_API_KEY'),
'model_version': '2b56576fcfbe32fa0526897d8385dd3fb3d36ba6fd0dbe033c72886b81ade93e'
"replicate_api_token": os.environ.get("REPLICATE_API_KEY"),
"model_version": "2b56576fcfbe32fa0526897d8385dd3fb3d36ba6fd0dbe033c72886b81ade93e",
},
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