Skip to content

Commit 357e10d

Browse files
xainazxainaz
andauthored
Eng 544 ai xplain sdk update llm functional tests to cover all new llm models (#248)
* Added recent model to LLM test * Added combined models to test * Passing in instantiated model * Passing in instantiated model --------- Co-authored-by: xainaz <[email protected]>
1 parent 1700304 commit 357e10d

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

tests/functional/model/run_model_test.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11
__author__ = "thiagocastroferreira"
22

3-
import pytest
43

54
from aixplain.enums import Function
65
from aixplain.factories import ModelFactory
76
from aixplain.modules import LLM
7+
from datetime import datetime, timedelta, timezone
8+
9+
10+
def pytest_generate_tests(metafunc):
11+
if "llm_model" in metafunc.fixturenames:
12+
four_weeks_ago = datetime.now(timezone.utc) - timedelta(weeks=4)
13+
models = ModelFactory.list(function=Function.TEXT_GENERATION)["results"]
14+
15+
predefined_models = ["Groq Llama 3 70B", "Chat GPT 3.5", "GPT-4o", "GPT 4 (32k)"]
16+
recent_models = [model for model in models if model.created_at and model.created_at >= four_weeks_ago]
17+
combined_models = recent_models + [
18+
ModelFactory.list(query=model, function=Function.TEXT_GENERATION)["results"][0] for model in predefined_models
19+
]
20+
metafunc.parametrize("llm_model", combined_models)
821

922

10-
@pytest.mark.parametrize("llm_model", ["Groq Llama 3 70B", "Chat GPT 3.5", "GPT-4o", "GPT 4 (32k)"])
1123
def test_llm_run(llm_model):
1224
"""Testing LLMs with history context"""
13-
model = ModelFactory.list(query=llm_model, function=Function.TEXT_GENERATION)["results"][0]
1425

15-
assert isinstance(model, LLM)
26+
assert isinstance(llm_model, LLM)
1627

17-
response = model.run(
28+
response = llm_model.run(
1829
data="What is my name?",
1930
history=[{"role": "user", "content": "Hello! My name is Thiago."}, {"role": "assistant", "content": "Hello!"}],
2031
)

0 commit comments

Comments
 (0)