From 915e7234968be687aea489b420fe6f6266107f0c Mon Sep 17 00:00:00 2001 From: Akrem Abayed Date: Fri, 16 Feb 2024 10:14:23 +0100 Subject: [PATCH 1/5] remove useless step --- .github/workflows/run-backend-tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/run-backend-tests.yml b/.github/workflows/run-backend-tests.yml index 8e5145e681..325b5c9531 100644 --- a/.github/workflows/run-backend-tests.yml +++ b/.github/workflows/run-backend-tests.yml @@ -35,6 +35,3 @@ jobs: - name: Docker logs if: always() # run: docker ps -q | xargs -I {} docker logs {} - - - name: Stop Docker Compose - run: docker-compose down From 9baeb34203a4a845e64049705b8a996fc714a058 Mon Sep 17 00:00:00 2001 From: Akrem Abayed Date: Fri, 16 Feb 2024 10:19:08 +0100 Subject: [PATCH 2/5] trigger workflows only on changes in the corresponding folder --- .github/workflows/run-backend-tests.yml | 5 ++++- .github/workflows/run-frontend-tests.yml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-backend-tests.yml b/.github/workflows/run-backend-tests.yml index 325b5c9531..657adfd74d 100644 --- a/.github/workflows/run-backend-tests.yml +++ b/.github/workflows/run-backend-tests.yml @@ -1,6 +1,9 @@ name: Run Backend tests -on: [pull_request] +on: + pull_request: + paths: + - 'agenta-backend/**' jobs: continous_integration: diff --git a/.github/workflows/run-frontend-tests.yml b/.github/workflows/run-frontend-tests.yml index 7fd3c75b7e..73810aa87d 100644 --- a/.github/workflows/run-frontend-tests.yml +++ b/.github/workflows/run-frontend-tests.yml @@ -1,6 +1,9 @@ name: Run Frontend tests -on: [pull_request] +on: + pull_request: + paths: + - 'agenta-web/**' env: OPENAI_API_KEY: ${{ secrets.NEXT_PUBLIC_OPENAI_API_KEY }} From e1a6bd4375e1ad8c817bac4774757e3be4107d2a Mon Sep 17 00:00:00 2001 From: Akrem Abayed Date: Fri, 16 Feb 2024 10:46:49 +0100 Subject: [PATCH 3/5] run logs only when needed --- .github/workflows/run-backend-tests.yml | 12 ++++++++++-- .github/workflows/run-frontend-tests.yml | 11 ++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-backend-tests.yml b/.github/workflows/run-backend-tests.yml index 657adfd74d..c47579d473 100644 --- a/.github/workflows/run-backend-tests.yml +++ b/.github/workflows/run-backend-tests.yml @@ -4,9 +4,17 @@ on: pull_request: paths: - 'agenta-backend/**' + - 'docker-compose.yml' + - 'docker-compose.*.yml' + workflow_dispatch: + inputs: + debug: + description: 'Run Docker logs step (true/false)' + required: true + default: 'false' jobs: - continous_integration: + pytest: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -36,5 +44,5 @@ jobs: run: sleep 10 && docker exec agenta-backend-test pytest - name: Docker logs - if: always() # + if: github.event_name == 'workflow_dispatch' && github.event.inputs.debug == 'true' run: docker ps -q | xargs -I {} docker logs {} diff --git a/.github/workflows/run-frontend-tests.yml b/.github/workflows/run-frontend-tests.yml index 73810aa87d..a77d368bb3 100644 --- a/.github/workflows/run-frontend-tests.yml +++ b/.github/workflows/run-frontend-tests.yml @@ -4,6 +4,15 @@ on: pull_request: paths: - 'agenta-web/**' + - 'docker-compose.yml' + - 'docker-compose.*.yml' + workflow_dispatch: + inputs: + debug: + description: 'Run Docker logs step (true/false)' + required: true + default: 'false' + env: OPENAI_API_KEY: ${{ secrets.NEXT_PUBLIC_OPENAI_API_KEY }} @@ -52,5 +61,5 @@ jobs: run: cd agenta-web/ && npm run test - name: Docker logs - if: always() # + if: github.event_name == 'workflow_dispatch' && github.event.inputs.debug == 'true' run: docker ps -q | xargs -I {} docker logs {} From e39af0adeab653f84d93462fe6e440ddec211013 Mon Sep 17 00:00:00 2001 From: Mahmoud Mabrouk Date: Fri, 16 Feb 2024 11:26:10 +0100 Subject: [PATCH 4/5] Improved the error messages when invoking llm applications --- .../services/llm_apps_service.py | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/agenta-backend/agenta_backend/services/llm_apps_service.py b/agenta-backend/agenta_backend/services/llm_apps_service.py index e9c597e0a3..7bf2230a13 100644 --- a/agenta-backend/agenta_backend/services/llm_apps_service.py +++ b/agenta-backend/agenta_backend/services/llm_apps_service.py @@ -91,13 +91,53 @@ async def invoke_app( result=Result(type="text", value=app_output["message"], error=None) ) - except httpx.HTTPError as e: - logger.error(f"Error occurred during request: {e}") + except httpx.HTTPStatusError as e: + # Parse error details from the API response + error_message = "Errow in invoking the LLM App:" + try: + error_body = e.response.json() + if "message" in error_body: + error_message = error_body["message"] + elif ( + "error" in error_body + ): # Some APIs return error information under an 'error' key + error_message = error_body["error"] + except ValueError: + # Fallback if the error response is not JSON or doesn't have the expected structure + logger.error(f"Failed to parse error response: {e}") + + logger.error(f"Error occurred during request: {error_message}") + return InvokationResult( + result=Result( + type="error", + error=Error( + message=error_message, + stacktrace=str(e), + ), + ) + ) + + except httpx.RequestError as e: + # Handle other request errors (e.g., network issues) + logger.error(f"Request error: {e}") + return InvokationResult( + result=Result( + type="error", + error=Error( + message="Network error while invoking the LLM App", + stacktrace=str(e), + ), + ) + ) + + except Exception as e: + # Catch-all for any other unexpected errors + logger.error(f"Unexpected error: {e}") return InvokationResult( result=Result( type="error", error=Error( - message="An error occurred while invoking the LLM App", + message="Unexpected error while invoking the LLM App", stacktrace=str(e), ), ) From 3928d75eb8d0caf88d14443eaa09c41661848e12 Mon Sep 17 00:00:00 2001 From: Mahmoud Mabrouk Date: Fri, 16 Feb 2024 11:29:19 +0100 Subject: [PATCH 5/5] Revert "Improved the error messages when invoking llm applications" This reverts commit e39af0adeab653f84d93462fe6e440ddec211013. --- .../services/llm_apps_service.py | 46 ++----------------- 1 file changed, 3 insertions(+), 43 deletions(-) diff --git a/agenta-backend/agenta_backend/services/llm_apps_service.py b/agenta-backend/agenta_backend/services/llm_apps_service.py index 7bf2230a13..e9c597e0a3 100644 --- a/agenta-backend/agenta_backend/services/llm_apps_service.py +++ b/agenta-backend/agenta_backend/services/llm_apps_service.py @@ -91,53 +91,13 @@ async def invoke_app( result=Result(type="text", value=app_output["message"], error=None) ) - except httpx.HTTPStatusError as e: - # Parse error details from the API response - error_message = "Errow in invoking the LLM App:" - try: - error_body = e.response.json() - if "message" in error_body: - error_message = error_body["message"] - elif ( - "error" in error_body - ): # Some APIs return error information under an 'error' key - error_message = error_body["error"] - except ValueError: - # Fallback if the error response is not JSON or doesn't have the expected structure - logger.error(f"Failed to parse error response: {e}") - - logger.error(f"Error occurred during request: {error_message}") - return InvokationResult( - result=Result( - type="error", - error=Error( - message=error_message, - stacktrace=str(e), - ), - ) - ) - - except httpx.RequestError as e: - # Handle other request errors (e.g., network issues) - logger.error(f"Request error: {e}") - return InvokationResult( - result=Result( - type="error", - error=Error( - message="Network error while invoking the LLM App", - stacktrace=str(e), - ), - ) - ) - - except Exception as e: - # Catch-all for any other unexpected errors - logger.error(f"Unexpected error: {e}") + except httpx.HTTPError as e: + logger.error(f"Error occurred during request: {e}") return InvokationResult( result=Result( type="error", error=Error( - message="Unexpected error while invoking the LLM App", + message="An error occurred while invoking the LLM App", stacktrace=str(e), ), )