mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-13 04:46:52 +08:00
Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user