Skip to content

Commit 4e04bbe

Browse files
Merge pull request #532 from MervinPraison/develop
Develop
2 parents 3cad06b + b19a9ea commit 4e04bbe

27 files changed

Lines changed: 4124 additions & 2397 deletions

.github/workflows/python-package.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,36 @@ jobs:
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727

28+
- name: Set environment variables
29+
run: |
30+
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
31+
echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
32+
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
33+
echo "LOGLEVEL=DEBUG" >> $GITHUB_ENV
34+
2835
- name: Install dependencies
2936
run: |
3037
cd src/praisonai
3138
python -m pip install --upgrade pip
3239
python -m pip install flake8 pytest
40+
python -m pip install ."[ui,gradio,api,agentops,google,openai,anthropic,cohere,chat,code,realtime,call,crewai,autogen]"
41+
python -m pip install duckduckgo_search
42+
python -m pip install pytest-asyncio pytest-cov
3343
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
44+
45+
- name: Debug API Key Status
46+
run: |
47+
echo "🔍 Checking API key availability..."
48+
if [ -n "${{ secrets.OPENAI_API_KEY }}" ]; then
49+
echo "✅ GitHub secret OPENAI_API_KEY is available"
50+
echo "🔑 API key starts with: $(echo "$OPENAI_API_KEY" | cut -c1-7)..."
51+
else
52+
echo "⚠️ GitHub secret OPENAI_API_KEY is NOT set - using fallback"
53+
echo "🔑 Using fallback key: sk-test-key..."
54+
fi
55+
echo "🌐 API Base: $OPENAI_API_BASE"
56+
echo "🤖 Model: $OPENAI_MODEL_NAME"
57+
3458
# - name: Lint with flake8
3559
# run: |
3660
# # stop the build if there are Python syntax errors or undefined names

.github/workflows/test-core.yml

Lines changed: 178 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,134 @@ jobs:
4040
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
4141
echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
4242
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
43+
echo "LOGLEVEL=DEBUG" >> $GITHUB_ENV
44+
echo "PYTHONPATH=${{ github.workspace }}/src/praisonai-agents:$PYTHONPATH" >> $GITHUB_ENV
45+
# Also export to current shell session for immediate availability
46+
export OPENAI_API_KEY="${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}"
47+
export OPENAI_API_BASE="${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}"
48+
export OPENAI_MODEL_NAME="${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}"
49+
export LOGLEVEL=DEBUG
50+
# Verify immediate availability
51+
echo "🔧 Immediate verification in same step:"
52+
echo " OPENAI_API_KEY length in current session: ${#OPENAI_API_KEY}"
53+
echo " OPENAI_API_KEY starts with sk-: $(echo "$OPENAI_API_KEY" | grep -q '^sk-' && echo 'YES' || echo 'NO')"
54+
55+
- name: Debug API Key Status
56+
run: |
57+
echo "🔍 Checking API key availability..."
58+
if [ -n "${{ secrets.OPENAI_API_KEY }}" ]; then
59+
echo "✅ GitHub secret OPENAI_API_KEY is available"
60+
echo "🔑 API key starts with: $(echo "$OPENAI_API_KEY" | cut -c1-7)..."
61+
else
62+
echo "⚠️ GitHub secret OPENAI_API_KEY is NOT set - using fallback"
63+
echo "🔑 Using fallback key: sk-test-key..."
64+
fi
65+
echo "🌐 API Base: $OPENAI_API_BASE"
66+
echo "🤖 Model: $OPENAI_MODEL_NAME"
67+
echo "🐛 Log Level: $LOGLEVEL"
68+
echo "📊 Environment Check:"
69+
echo " - OPENAI_API_KEY length: ${#OPENAI_API_KEY}"
70+
echo " - OPENAI_API_BASE: $OPENAI_API_BASE"
71+
echo " - OPENAI_MODEL_NAME: $OPENAI_MODEL_NAME"
72+
echo " - LOGLEVEL: $LOGLEVEL"
73+
echo "🔍 Is API key actually set?"
74+
echo " - API key starts with sk-: $(echo "$OPENAI_API_KEY" | grep -q '^sk-' && echo 'YES' || echo 'NO')"
75+
echo " - API key is not test key: $([ "$OPENAI_API_KEY" != 'sk-test-key-for-github-actions-testing-only-not-real' ] && echo 'YES' || echo 'NO')"
76+
77+
- name: Debug Environment Variables Raw
78+
run: |
79+
echo "🔧 Raw environment variable check:"
80+
echo "OPENAI_API_KEY set: $(if [ -n "$OPENAI_API_KEY" ]; then echo 'YES'; else echo 'NO'; fi)"
81+
echo "OPENAI_API_KEY length: ${#OPENAI_API_KEY}"
82+
echo "OPENAI_API_KEY first 10 chars: ${OPENAI_API_KEY:0:10}"
83+
echo "OPENAI_API_KEY last 5 chars: ${OPENAI_API_KEY: -5}"
84+
printenv | grep OPENAI || echo "No OPENAI env vars found"
85+
86+
- name: Debug Python Environment Variables
87+
run: |
88+
python -c "
89+
import os
90+
print('🐍 Python Environment Variable Check:')
91+
api_key = os.environ.get('OPENAI_API_KEY', 'NOT_SET')
92+
if api_key != 'NOT_SET':
93+
print(f' ✅ OPENAI_API_KEY: {api_key[:7]}... (length: {len(api_key)})')
94+
else:
95+
print(' ❌ OPENAI_API_KEY: NOT_SET')
96+
print(f' 🌐 OPENAI_API_BASE: {os.environ.get(\"OPENAI_API_BASE\", \"NOT_SET\")}')
97+
print(f' 🤖 OPENAI_MODEL_NAME: {os.environ.get(\"OPENAI_MODEL_NAME\", \"NOT_SET\")}')
98+
print(f' 📋 All OPENAI env vars:')
99+
for key, value in os.environ.items():
100+
if key.startswith('OPENAI'):
101+
print(f' {key}: {value[:10] if len(value) > 10 else value}...')
102+
"
103+
104+
- name: Validate API Key
105+
run: |
106+
echo "🔑 Testing API key validity with minimal OpenAI call..."
107+
python -c "
108+
import os
109+
try:
110+
from openai import OpenAI
111+
client = OpenAI(api_key=os.environ.get('OPENAI_API_KEY'))
112+
response = client.models.list()
113+
print('✅ API Key is VALID - OpenAI responded successfully')
114+
print(f'📊 Available models: {len(list(response.data))} models found')
115+
except Exception as e:
116+
print(f'❌ API Key is INVALID - Error: {e}')
117+
print('🔍 This explains why all API-dependent tests are failing')
118+
print('💡 The GitHub secret OPENAI_API_KEY needs to be updated with a valid key')
119+
"
120+
continue-on-error: true
121+
122+
- name: Debug PraisonAI API Key Usage
123+
env:
124+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}
125+
OPENAI_API_BASE: ${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}
126+
OPENAI_MODEL_NAME: ${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}
127+
LOGLEVEL: DEBUG
128+
run: |
129+
echo "🔍 Testing PraisonAI API key usage directly..."
130+
cd src/praisonai
131+
python -c "
132+
import os
133+
import sys
134+
sys.path.insert(0, '.')
135+
136+
print('🔧 Direct PraisonAI API Key Check:')
137+
print(f'Environment OPENAI_API_KEY: {os.environ.get(\"OPENAI_API_KEY\", \"NOT_SET\")[:10]}...')
138+
139+
# Test PraisonAI initialization
140+
from praisonai import PraisonAI
141+
praisonai = PraisonAI()
142+
143+
print(f'PraisonAI config_list: {praisonai.config_list}')
144+
api_key_from_config = praisonai.config_list[0].get('api_key', 'NOT_SET')
145+
print(f'API key from PraisonAI config: {api_key_from_config[:10] if api_key_from_config != \"NOT_SET\" else \"NOT_SET\"}...')
146+
147+
# Test PraisonAIModel with explicit API key (the way CrewAI will use it)
148+
from praisonai.inc.models import PraisonAIModel
149+
150+
print('\\n🧪 Testing PraisonAIModel with explicit API key (CrewAI method):')
151+
model_with_explicit_key = PraisonAIModel(
152+
model='openai/gpt-4o-mini',
153+
base_url=praisonai.config_list[0].get('base_url'),
154+
api_key=praisonai.config_list[0].get('api_key')
155+
)
156+
print(f' Model: {model_with_explicit_key.model}')
157+
print(f' Model name: {model_with_explicit_key.model_name}')
158+
print(f' API key var: {model_with_explicit_key.api_key_var}')
159+
print(f' API key (explicit): {model_with_explicit_key.api_key[:10] if model_with_explicit_key.api_key != \"nokey\" else \"NOT_SET\"}...')
160+
print(f' Base URL: {model_with_explicit_key.base_url}')
161+
162+
# Test if the model can be created without errors
163+
try:
164+
llm_instance = model_with_explicit_key.get_model()
165+
print(f' ✅ LLM instance created successfully: {type(llm_instance).__name__}')
166+
print(f' LLM instance API key: {getattr(llm_instance, \"openai_api_key\", \"NOT_FOUND\")[:10] if hasattr(llm_instance, \"openai_api_key\") else \"NO_API_KEY_ATTR\"}...')
167+
except Exception as e:
168+
print(f' ❌ Failed to create LLM instance: {e}')
169+
"
170+
continue-on-error: true
43171

44172
- name: Run Unit Tests
45173
run: |
@@ -49,20 +177,63 @@ jobs:
49177
run: |
50178
cd src/praisonai && python -m pytest tests/integration/ -v --tb=short --disable-warnings
51179
52-
- name: Run AutoGen Framework Tests
180+
- name: Debug Directory Structure
181+
run: |
182+
echo "🔍 Debugging directory structure for CrewAI tests..."
183+
cd src/praisonai
184+
echo "Current working directory: $(pwd)"
185+
echo "📁 Contents of current directory:"
186+
ls -la
187+
echo ""
188+
echo "📁 Contents of tests directory:"
189+
ls -la tests/ || echo "❌ tests/ directory not found"
190+
echo ""
191+
echo "📁 Contents of tests/integration:"
192+
ls -la tests/integration/ || echo "❌ tests/integration/ directory not found"
193+
echo ""
194+
echo "📁 Looking for crewai directory:"
195+
find . -name "crewai" -type d 2>/dev/null || echo "❌ No crewai directories found"
196+
echo ""
197+
echo "📁 Full directory tree of tests:"
198+
tree tests/ || find tests/ -type d 2>/dev/null || echo "❌ Cannot explore tests directory"
199+
200+
- name: Test AutoGen Framework
53201
run: |
54202
echo "🤖 Testing AutoGen Framework Integration..."
55-
cd src/praisonai && python tests/test_runner.py --pattern autogen --verbose || echo "⚠️ AutoGen tests completed with issues"
56-
continue-on-error: true
203+
cd src/praisonai && python tests/test_runner.py --pattern autogen --verbose
57204
58-
- name: Run CrewAI Framework Tests
205+
- name: Test CrewAI Framework
59206
run: |
60207
echo "⛵ Testing CrewAI Framework Integration..."
61-
cd src/praisonai && python tests/test_runner.py --pattern crewai --verbose || echo "⚠️ CrewAI tests completed with issues"
62-
continue-on-error: true
208+
cd src/praisonai
209+
echo "🔍 Trying test runner first..."
210+
python tests/test_runner.py --pattern crewai --verbose || {
211+
echo "❌ Test runner failed, trying direct pytest..."
212+
echo "📁 Current directory: $(pwd)"
213+
echo "📁 Looking for CrewAI tests..."
214+
find . -name "*crewai*" -type f 2>/dev/null
215+
echo "🧪 Trying direct pytest on integration/crewai..."
216+
python -m pytest tests/integration/crewai/ -v --tb=short --disable-warnings || {
217+
echo "❌ Direct path failed, trying relative path..."
218+
python -m pytest integration/crewai/ -v --tb=short --disable-warnings || {
219+
echo "❌ All CrewAI test attempts failed"
220+
exit 1
221+
}
222+
}
223+
}
63224
64-
- name: Run Legacy Tests
225+
- name: Run Legacy Tests with API Key
226+
env:
227+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}
228+
OPENAI_API_BASE: ${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}
229+
OPENAI_MODEL_NAME: ${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}
230+
LOGLEVEL: DEBUG
65231
run: |
232+
echo "🧪 Running legacy tests with real API key..."
233+
echo "🔧 Final environment check before pytest:"
234+
echo " OPENAI_API_KEY set: $([ -n "$OPENAI_API_KEY" ] && echo 'YES' || echo 'NO')"
235+
echo " OPENAI_API_KEY length: ${#OPENAI_API_KEY}"
236+
echo " OPENAI_API_KEY starts with sk-: $(echo "$OPENAI_API_KEY" | grep -q '^sk-' && echo 'YES' || echo 'NO')"
66237
cd src/praisonai && python -m pytest tests/test.py -v --tb=short --disable-warnings
67238
68239
- name: Upload Coverage Reports

.github/workflows/unittest.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,18 @@ jobs:
472472
# Run the fastest, most essential tests
473473
cd src/praisonai && python tests/test_runner.py --pattern fast
474474
475+
- name: Run Real API Tests
476+
run: |
477+
echo "🔑 Running real API tests with actual OpenAI API key..."
478+
cd src/praisonai && python -m pytest tests/test_agents_playbook.py -v --tb=short --disable-warnings -m real
479+
continue-on-error: true
480+
481+
- name: Run E2E Real Tests
482+
run: |
483+
echo "🧪 Running E2E real tests..."
484+
cd src/praisonai && python -m pytest tests/e2e/ -v --tb=short --disable-warnings -m real
485+
continue-on-error: true
486+
475487
- name: Run Legacy Example Tests
476488
run: |
477489
cd src/praisonai && python -m pytest tests/test.py -v --tb=short --disable-warnings

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ agentops.log
5454
crewAI
5555
!tests/integration/crewai
5656
!tests/e2e/crewai
57+
!src/praisonai/tests/integration/crewai
58+
!src/praisonai/tests/e2e/crewai
5759

5860
# virtualenv
5961
.venv

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3.11-slim
22
WORKDIR /app
33
COPY . .
4-
RUN pip install flask praisonai==2.2.16 gunicorn markdown
4+
RUN pip install flask praisonai==2.2.17 gunicorn markdown
55
EXPOSE 8080
66
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]

docker/Dockerfile.chat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1313
RUN pip install --no-cache-dir \
1414
praisonaiagents>=0.0.4 \
1515
praisonai_tools \
16-
"praisonai==2.2.16" \
16+
"praisonai==2.2.17" \
1717
"praisonai[chat]" \
1818
"embedchain[github,youtube]"
1919

docker/Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1515
RUN pip install --no-cache-dir \
1616
praisonaiagents>=0.0.4 \
1717
praisonai_tools \
18-
"praisonai==2.2.16" \
18+
"praisonai==2.2.17" \
1919
"praisonai[ui]" \
2020
"praisonai[chat]" \
2121
"praisonai[realtime]" \

docker/Dockerfile.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1313
RUN pip install --no-cache-dir \
1414
praisonaiagents>=0.0.4 \
1515
praisonai_tools \
16-
"praisonai==2.2.16" \
16+
"praisonai==2.2.17" \
1717
"praisonai[ui]" \
1818
"praisonai[crewai]"
1919

docs/api/praisonai/deploy.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ <h2 id="raises">Raises</h2>
110110
file.write(&#34;FROM python:3.11-slim\n&#34;)
111111
file.write(&#34;WORKDIR /app\n&#34;)
112112
file.write(&#34;COPY . .\n&#34;)
113-
file.write(&#34;RUN pip install flask praisonai==2.2.16 gunicorn markdown\n&#34;)
113+
file.write(&#34;RUN pip install flask praisonai==2.2.17 gunicorn markdown\n&#34;)
114114
file.write(&#34;EXPOSE 8080\n&#34;)
115115
file.write(&#39;CMD [&#34;gunicorn&#34;, &#34;-b&#34;, &#34;0.0.0.0:8080&#34;, &#34;api:app&#34;]\n&#39;)
116116

docs/developers/local-development.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ WORKDIR /app
2727

2828
COPY . .
2929

30-
RUN pip install flask praisonai==2.2.16 watchdog
30+
RUN pip install flask praisonai==2.2.17 watchdog
3131

3232
EXPOSE 5555
3333

0 commit comments

Comments
 (0)