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

@@ -12,17 +12,17 @@ def test_validate_credentials():
with pytest.raises(CredentialsValidateFailedError):
model.validate_credentials(
model='NOT IMPORTANT',
model="NOT IMPORTANT",
credentials={
'server_url': 'ww' + os.environ.get('OPENLLM_SERVER_URL'),
}
"server_url": "ww" + os.environ.get("OPENLLM_SERVER_URL"),
},
)
model.validate_credentials(
model='NOT IMPORTANT',
model="NOT IMPORTANT",
credentials={
'server_url': os.environ.get('OPENLLM_SERVER_URL'),
}
"server_url": os.environ.get("OPENLLM_SERVER_URL"),
},
)
@@ -30,33 +30,28 @@ def test_invoke_model():
model = OpenLLMTextEmbeddingModel()
result = model.invoke(
model='NOT IMPORTANT',
model="NOT IMPORTANT",
credentials={
'server_url': os.environ.get('OPENLLM_SERVER_URL'),
"server_url": os.environ.get("OPENLLM_SERVER_URL"),
},
texts=[
"hello",
"world"
],
user="abc-123"
texts=["hello", "world"],
user="abc-123",
)
assert isinstance(result, TextEmbeddingResult)
assert len(result.embeddings) == 2
assert result.usage.total_tokens > 0
def test_get_num_tokens():
model = OpenLLMTextEmbeddingModel()
num_tokens = model.get_num_tokens(
model='NOT IMPORTANT',
model="NOT IMPORTANT",
credentials={
'server_url': os.environ.get('OPENLLM_SERVER_URL'),
"server_url": os.environ.get("OPENLLM_SERVER_URL"),
},
texts=[
"hello",
"world"
]
texts=["hello", "world"],
)
assert num_tokens == 2