From 3d546e0c408d0b9779fcf83d9262e8656390d606 Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Thu, 23 May 2024 02:48:03 -0400 Subject: [PATCH 1/4] Add run tests in pull request --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db07a32c..6c38a3c9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,8 @@ name: Test on: + pull_request: + schedule: - cron: "0 13 * * *" workflow_dispatch: From 26bb15372f0f4b11ceb299805b106f417a55d99c Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Thu, 23 May 2024 02:51:26 -0400 Subject: [PATCH 2/4] Add trigger dispatch tests based on pull_request event --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6c38a3c9..1fbc1d55 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -64,7 +64,7 @@ jobs: run: poetry install --all-extras - name: Run dispatch tests - if: ${{ github.event_name == 'workflow_dispatch' }} + if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' }} run: | echo "This is a dispatch event" openai_model_input=${{ github.event.inputs.openai_model }} From 9edda2ae80a6ec8048c805e4cccfd0a84fcf0abd Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Thu, 23 May 2024 02:57:03 -0400 Subject: [PATCH 3/4] Update google response assertion --- tests/test_google.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_google.py b/tests/test_google.py index a562ef39..7ec6e048 100644 --- a/tests/test_google.py +++ b/tests/test_google.py @@ -39,4 +39,4 @@ def test_genai_chat_w_history(google_model): text = response.text assert isinstance(text, str) - assert "no" in text.lower() + assert text, "No output from the model." From 6be99d7a28bfa0d22728ab5159b30bb7f79e68c3 Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Thu, 23 May 2024 15:50:45 -0400 Subject: [PATCH 4/4] Update tests assertion to be less strict --- tests/test_google.py | 2 +- tests/test_langchain.py | 5 +++-- tests/test_magentic.py | 3 ++- tests/test_openai.py | 3 --- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/test_google.py b/tests/test_google.py index 7ec6e048..eb0d09a5 100644 --- a/tests/test_google.py +++ b/tests/test_google.py @@ -21,7 +21,7 @@ def test_genai_chat(google_model): text = response.text assert isinstance(text, str) - assert "this is a test" in text.lower() + assert text, "No output from the model." @pytest.mark.chat diff --git a/tests/test_langchain.py b/tests/test_langchain.py index 0fc9936d..663694cb 100644 --- a/tests/test_langchain.py +++ b/tests/test_langchain.py @@ -17,8 +17,9 @@ def test_chat_openai_messages(openai_model): messages = [SystemMessage(content="You are a ping pong machine"), HumanMessage(content="Ping?")] completion = llm.predict_messages(messages) - assert isinstance(completion.content, str) - assert "pong" in completion.content.lower() + content = completion.content + assert isinstance(content, str) + assert content, "No output from the model." @pytest.mark.chat diff --git a/tests/test_magentic.py b/tests/test_magentic.py index 71be2449..792d0b48 100644 --- a/tests/test_magentic.py +++ b/tests/test_magentic.py @@ -143,5 +143,6 @@ async def _generate_title_and_description(query: str, widget_data: str) -> Widge assert isinstance(r, WidgetInfo) assert isinstance(r.title, str) - assert "AAPL" in r.title assert isinstance(r.description, str) + assert r.title, "No title generated." + assert r.description, "No description generated." diff --git a/tests/test_openai.py b/tests/test_openai.py index da5bd2c7..a3d91b8b 100644 --- a/tests/test_openai.py +++ b/tests/test_openai.py @@ -32,7 +32,6 @@ def test_chat(openai_model): content = completion.choices[0].message.content assert isinstance(content, str) assert content, "No output from the model." - assert "did not go to the market" in content @pytest.mark.chat @@ -68,7 +67,6 @@ async def test_chat_async(openai_model): content = completion.choices[0].message.content assert isinstance(content, str) assert content, "No output from the model." - assert "this is a test" in content.lower() @pytest.mark.chat @@ -139,7 +137,6 @@ def test_chat_image(openai_vision_model): content = response.choices[0].message.content assert isinstance(content, str) assert content, "No output from the model." - assert "ant" in content def get_current_weather(location, unit="fahrenheit"):