From 741843cead577e1e24e9844fba2dd2954d76b97b Mon Sep 17 00:00:00 2001 From: MervinPraison Date: Sat, 24 May 2025 17:03:52 +0100 Subject: [PATCH 1/2] Enhance GitHub Actions workflows and update test assertions - Added environment variable setup in `test-extended.yml` for OpenAI API configuration. - Updated test command in `unittest.yml` to use a pattern for faster execution. - Refined assertions in `test_base_url_api_base_fix.py` to reflect changes in parameter naming from `base_url` to `api_base`. - Improved mock tool listing in `test_mcp_integration.py` for clarity. - Adjusted knowledge update logic in `test_rag_integration.py` to handle existing knowledge more effectively. - Ensured minimal changes to existing code while enhancing test clarity and functionality. --- .github/workflows/test-extended.yml | 7 +++++++ .github/workflows/unittest.yml | 2 +- tests/integration/test_base_url_api_base_fix.py | 10 +++++----- tests/integration/test_mcp_integration.py | 8 ++++---- tests/integration/test_rag_integration.py | 16 +++++++++++----- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test-extended.yml b/.github/workflows/test-extended.yml index 3f3aec928..76fb779f6 100644 --- a/.github/workflows/test-extended.yml +++ b/.github/workflows/test-extended.yml @@ -33,6 +33,13 @@ jobs: uv pip install --system ."[ui,gradio,api,agentops,google,openai,anthropic,cohere,chat,code,realtime,call,crewai,autogen]" uv pip install --system duckduckgo_search + - name: Set environment variables + run: | + echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> $GITHUB_ENV + echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE }}" >> $GITHUB_ENV + echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME }}" >> $GITHUB_ENV + echo "PYTHONPATH=${{ github.workspace }}/src/praisonai-agents:$PYTHONPATH" >> $GITHUB_ENV + - name: Test Key Example Scripts run: | echo "🧪 Testing key example scripts from praisonai-agents..." diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index bcc5c939d..80a7b1baa 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -36,7 +36,7 @@ jobs: - name: Run Fast Tests run: | # Run the fastest, most essential tests - python tests/test_runner.py --fast + python tests/test_runner.py --pattern fast - name: Run Legacy Example Tests run: | diff --git a/tests/integration/test_base_url_api_base_fix.py b/tests/integration/test_base_url_api_base_fix.py index c1418be07..6af71c96d 100644 --- a/tests/integration/test_base_url_api_base_fix.py +++ b/tests/integration/test_base_url_api_base_fix.py @@ -92,19 +92,19 @@ def test_agent_with_llm_dict_base_url_parameter(self, mock_completion): @patch('litellm.image_generation') def test_image_agent_base_url_consistency(self, mock_image_generation): - """Test that ImageAgent maintains parameter consistency with base_url.""" + """Test that ImageAgent maintains parameter consistency with api_base.""" mock_image_generation.return_value = { 'data': [{'url': 'http://example.com/image.png'}] } image_agent = ImageAgent( - base_url='http://localhost:4000', + api_base='http://localhost:4000', api_key='sk-test' ) - # Verify that ImageAgent was created with base_url - assert image_agent.base_url == 'http://localhost:4000' - assert image_agent.api_key == 'sk-test' + # Verify that ImageAgent was created with api_base + assert image_agent.image_config.api_base == 'http://localhost:4000' + assert image_agent.image_config.api_key == 'sk-test' @patch('litellm.completion') def test_koboldcpp_specific_scenario(self, mock_completion): diff --git a/tests/integration/test_mcp_integration.py b/tests/integration/test_mcp_integration.py index 24e1000e8..9731108cb 100644 --- a/tests/integration/test_mcp_integration.py +++ b/tests/integration/test_mcp_integration.py @@ -30,11 +30,11 @@ async def test_mcp_server_connection(self): mock_session = AsyncMock() mock_session_class.return_value.__aenter__.return_value = mock_session - # Mock session methods + # Mock tool listing mock_session.initialize.return_value = None - mock_session.list_tools.return_value = Mock(tools=[ - Mock(name='get_stock_price', description='Get stock price') - ]) + mock_tool = Mock() + mock_tool.name = 'get_stock_price' # Set as string, not Mock + mock_session.list_tools.return_value = Mock(tools=[mock_tool]) # Test MCP connection simulation async with mock_stdio_client(Mock()) as (read, write): diff --git a/tests/integration/test_rag_integration.py b/tests/integration/test_rag_integration.py index da01aabaa..0d63bb7b4 100644 --- a/tests/integration/test_rag_integration.py +++ b/tests/integration/test_rag_integration.py @@ -395,14 +395,20 @@ def test_rag_knowledge_update(self, sample_agent_config): def mock_update_knowledge(agent, new_documents: list, mode: str = "append"): """Mock updating agent knowledge.""" if mode == "append": - current_knowledge = getattr(agent, 'knowledge', []) - updated_knowledge = current_knowledge + new_documents + current_knowledge = getattr(agent, 'knowledge', None) + if current_knowledge is not None: + # If Knowledge object exists, get count from it + previous_count = 1 # Mock that there's existing knowledge + else: + previous_count = 0 + updated_count = previous_count + len(new_documents) else: # replace - updated_knowledge = new_documents + previous_count = 1 if getattr(agent, 'knowledge', None) else 0 + updated_count = len(new_documents) return { - 'previous_count': len(getattr(agent, 'knowledge', [])), - 'new_count': len(updated_knowledge), + 'previous_count': previous_count, + 'new_count': updated_count, 'added_documents': new_documents } From 246989a91173d24c03a053773d65df4faed5ec23 Mon Sep 17 00:00:00 2001 From: MervinPraison Date: Sat, 24 May 2025 17:09:45 +0100 Subject: [PATCH 2/2] Update version to 2.2.4 across project files - Incremented PraisonAI version from 2.2.3 to 2.2.4 in `pyproject.toml`, `uv.lock`, and all relevant Dockerfiles for consistency. - Ensured minimal changes to existing code while maintaining versioning accuracy. --- docker/Dockerfile | 2 +- docker/Dockerfile.chat | 2 +- docker/Dockerfile.dev | 2 +- docker/Dockerfile.ui | 2 +- docs/api/praisonai/deploy.html | 2 +- docs/developers/local-development.mdx | 2 +- docs/ui/chat.mdx | 2 +- docs/ui/code.mdx | 2 +- praisonai/cli.py | 2 +- praisonai/deploy.py | 2 +- pyproject.toml | 4 ++-- uv.lock | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 18c8b1599..a450dcae4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.11-slim WORKDIR /app COPY . . -RUN pip install flask praisonai==2.2.3 gunicorn markdown +RUN pip install flask praisonai==2.2.4 gunicorn markdown EXPOSE 8080 CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"] diff --git a/docker/Dockerfile.chat b/docker/Dockerfile.chat index fceb774ae..66a8eecda 100644 --- a/docker/Dockerfile.chat +++ b/docker/Dockerfile.chat @@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ RUN pip install --no-cache-dir \ praisonaiagents>=0.0.4 \ praisonai_tools \ - "praisonai==2.2.3" \ + "praisonai==2.2.4" \ "praisonai[chat]" \ "embedchain[github,youtube]" diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev index 2fb470cf3..4e8e7b92b 100644 --- a/docker/Dockerfile.dev +++ b/docker/Dockerfile.dev @@ -15,7 +15,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ RUN pip install --no-cache-dir \ praisonaiagents>=0.0.4 \ praisonai_tools \ - "praisonai==2.2.3" \ + "praisonai==2.2.4" \ "praisonai[ui]" \ "praisonai[chat]" \ "praisonai[realtime]" \ diff --git a/docker/Dockerfile.ui b/docker/Dockerfile.ui index 0b1487777..551e608b3 100644 --- a/docker/Dockerfile.ui +++ b/docker/Dockerfile.ui @@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ RUN pip install --no-cache-dir \ praisonaiagents>=0.0.4 \ praisonai_tools \ - "praisonai==2.2.3" \ + "praisonai==2.2.4" \ "praisonai[ui]" \ "praisonai[crewai]" diff --git a/docs/api/praisonai/deploy.html b/docs/api/praisonai/deploy.html index eb1dd207b..861540260 100644 --- a/docs/api/praisonai/deploy.html +++ b/docs/api/praisonai/deploy.html @@ -110,7 +110,7 @@

Raises

file.write("FROM python:3.11-slim\n") file.write("WORKDIR /app\n") file.write("COPY . .\n") - file.write("RUN pip install flask praisonai==2.2.3 gunicorn markdown\n") + file.write("RUN pip install flask praisonai==2.2.4 gunicorn markdown\n") file.write("EXPOSE 8080\n") file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n') diff --git a/docs/developers/local-development.mdx b/docs/developers/local-development.mdx index 4e7519e4d..fc68ba563 100644 --- a/docs/developers/local-development.mdx +++ b/docs/developers/local-development.mdx @@ -27,7 +27,7 @@ WORKDIR /app COPY . . -RUN pip install flask praisonai==2.2.3 watchdog +RUN pip install flask praisonai==2.2.4 watchdog EXPOSE 5555 diff --git a/docs/ui/chat.mdx b/docs/ui/chat.mdx index 0314ce404..27ccc857d 100644 --- a/docs/ui/chat.mdx +++ b/docs/ui/chat.mdx @@ -155,7 +155,7 @@ To facilitate local development with live reload, you can use Docker. Follow the COPY . . - RUN pip install flask praisonai==2.2.3 watchdog + RUN pip install flask praisonai==2.2.4 watchdog EXPOSE 5555 diff --git a/docs/ui/code.mdx b/docs/ui/code.mdx index 2090569d3..0b2af7ef3 100644 --- a/docs/ui/code.mdx +++ b/docs/ui/code.mdx @@ -208,7 +208,7 @@ To facilitate local development with live reload, you can use Docker. Follow the COPY . . - RUN pip install flask praisonai==2.2.3 watchdog + RUN pip install flask praisonai==2.2.4 watchdog EXPOSE 5555 diff --git a/praisonai/cli.py b/praisonai/cli.py index 397d69cd2..97a46eb2f 100644 --- a/praisonai/cli.py +++ b/praisonai/cli.py @@ -130,7 +130,7 @@ def run(self): """ Run the PraisonAI application. """ - self.main() + return self.main() def main(self): """ diff --git a/praisonai/deploy.py b/praisonai/deploy.py index 0bf2f755c..72190e554 100644 --- a/praisonai/deploy.py +++ b/praisonai/deploy.py @@ -56,7 +56,7 @@ def create_dockerfile(self): file.write("FROM python:3.11-slim\n") file.write("WORKDIR /app\n") file.write("COPY . .\n") - file.write("RUN pip install flask praisonai==2.2.3 gunicorn markdown\n") + file.write("RUN pip install flask praisonai==2.2.4 gunicorn markdown\n") file.write("EXPOSE 8080\n") file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n') diff --git a/pyproject.toml b/pyproject.toml index 9fccaba79..4034ea8d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "PraisonAI" -version = "2.2.3" +version = "2.2.4" description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration." readme = "README.md" license = "" @@ -89,7 +89,7 @@ autogen = ["pyautogen>=0.2.19", "praisonai-tools>=0.0.15", "crewai"] [tool.poetry] name = "PraisonAI" -version = "2.2.3" +version = "2.2.4" description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration." authors = ["Mervin Praison"] license = "" diff --git a/uv.lock b/uv.lock index 2be98c702..cda3f0f66 100644 --- a/uv.lock +++ b/uv.lock @@ -3614,7 +3614,7 @@ wheels = [ [[package]] name = "praisonai" -version = "2.2.3" +version = "2.2.4" source = { editable = "." } dependencies = [ { name = "instructor" },