Skip to content

Commit 2e63a14

Browse files
Merge pull request #510 from MervinPraison/develop
Develop
2 parents dfb62e8 + 9b8c5f6 commit 2e63a14

14 files changed

Lines changed: 302 additions & 15 deletions

File tree

.github/workflows/unittest.yml

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,24 @@ jobs:
3131
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
3232
echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
3333
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
34+
echo "LOGLEVEL=DEBUG" >> $GITHUB_ENV
3435
echo "PYTHONPATH=${{ github.workspace }}/src/praisonai-agents:$PYTHONPATH" >> $GITHUB_ENV
3536
37+
- name: Backup Root Config Files
38+
run: |
39+
echo "🔄 Backing up root configuration files to prevent default file resolution interference..."
40+
echo "ℹ️ PraisonAI automatically uses 'agents.yaml' in working directory when no file specified"
41+
echo "ℹ️ This can interfere with test files that specify their own YAML files"
42+
if [ -f "agents.yaml" ]; then
43+
mv agents.yaml agents.yaml.backup
44+
echo "✅ Moved root agents.yaml to agents.yaml.backup"
45+
echo " - This prevents default file fallback during tests"
46+
fi
47+
if [ -f "tools.py" ]; then
48+
mv tools.py tools.py.backup
49+
echo "✅ Moved tools.py to tools.py.backup"
50+
fi
51+
3652
- name: Debug API Key Status
3753
run: |
3854
echo "🔍 Checking API key availability..."
@@ -45,10 +61,12 @@ jobs:
4561
fi
4662
echo "🌐 API Base: $OPENAI_API_BASE"
4763
echo "🤖 Model: $OPENAI_MODEL_NAME"
64+
echo "🐛 Log Level: $LOGLEVEL"
4865
echo "📊 Environment Check:"
4966
echo " - OPENAI_API_KEY length: ${#OPENAI_API_KEY}"
5067
echo " - OPENAI_API_BASE: $OPENAI_API_BASE"
5168
echo " - OPENAI_MODEL_NAME: $OPENAI_MODEL_NAME"
69+
echo " - LOGLEVEL: $LOGLEVEL"
5270
5371
- name: Debug Python Environment Variables
5472
run: |
@@ -68,6 +86,124 @@ jobs:
6886
print(f' {key}: {value[:10] if len(value) > 10 else value}...')
6987
"
7088
89+
- name: Find Researcher Role Source
90+
run: |
91+
echo "🔍 Hunting for the mysterious 'Researcher' role..."
92+
python -c "
93+
import os
94+
import yaml
95+
import glob
96+
97+
print('📋 Searching for Researcher role in all YAML files:')
98+
yaml_files = glob.glob('tests/*.yaml')
99+
100+
for yaml_file in yaml_files:
101+
try:
102+
with open(yaml_file, 'r') as f:
103+
config = yaml.safe_load(f)
104+
105+
# Check if any role contains 'researcher'
106+
roles = config.get('roles', {})
107+
for role_key, role_data in roles.items():
108+
role_name = role_data.get('role', '')
109+
if 'researcher' in role_key.lower() or 'researcher' in role_name.lower():
110+
print(f' 🎯 FOUND in {yaml_file}:')
111+
print(f' Framework: {config.get(\"framework\", \"NOT_SET\")}')
112+
print(f' Role key: {role_key}')
113+
print(f' Role name: {role_name}')
114+
print(f' All roles: {list(roles.keys())}')
115+
print()
116+
except Exception as e:
117+
print(f' ❌ Error reading {yaml_file}: {e}')
118+
119+
print('🔍 Checking for default configurations...')
120+
# Check if there are any default configs or hardcoded roles
121+
try:
122+
import praisonai
123+
print(f' PraisonAI package location: {praisonai.__file__}')
124+
125+
# Check if there are any example YAML files in the package
126+
package_dir = os.path.dirname(praisonai.__file__)
127+
for root, dirs, files in os.walk(package_dir):
128+
for file in files:
129+
if file.endswith(('.yaml', '.yml')):
130+
file_path = os.path.join(root, file)
131+
print(f' 📁 Found YAML in package: {file_path}')
132+
except Exception as e:
133+
print(f' ❌ Error checking package: {e}')
134+
"
135+
continue-on-error: true
136+
137+
- name: Trace AutoGen Execution Path
138+
run: |
139+
echo "🔍 Tracing AutoGen execution to find where it diverges..."
140+
python -c "
141+
import os
142+
import sys
143+
sys.path.insert(0, '.')
144+
145+
try:
146+
from praisonai import PraisonAI
147+
from praisonai.agents_generator import AgentsGenerator
148+
149+
# Test the exact execution path
150+
print('🎯 Testing AutoGen execution path:')
151+
152+
praisonai = PraisonAI(agent_file='tests/autogen-agents.yaml')
153+
print(f' 1. PraisonAI framework: \"{praisonai.framework}\"')
154+
155+
agents_gen = AgentsGenerator(
156+
agent_file='tests/autogen-agents.yaml',
157+
framework=praisonai.framework,
158+
config_list=praisonai.config_list
159+
)
160+
print(f' 2. AgentsGenerator framework: \"{agents_gen.framework}\"')
161+
162+
# Load the YAML to check what it contains
163+
import yaml
164+
with open('tests/autogen-agents.yaml', 'r') as f:
165+
config = yaml.safe_load(f)
166+
167+
framework = agents_gen.framework or config.get('framework')
168+
print(f' 3. Final framework decision: \"{framework}\"')
169+
print(f' 4. Available frameworks:')
170+
171+
# Check framework availability
172+
try:
173+
import autogen
174+
print(f' ✅ AutoGen available')
175+
except ImportError:
176+
print(f' ❌ AutoGen NOT available')
177+
178+
try:
179+
from praisonaiagents import Agent
180+
print(f' ✅ PraisonAI agents available')
181+
except ImportError:
182+
print(f' ❌ PraisonAI agents NOT available')
183+
184+
try:
185+
from crewai import Agent
186+
print(f' ✅ CrewAI available')
187+
except ImportError:
188+
print(f' ❌ CrewAI NOT available')
189+
190+
print(f' 5. Roles in YAML: {list(config.get(\"roles\", {}).keys())}')
191+
192+
# Now test the actual framework execution
193+
if framework == 'autogen':
194+
print(f' 6. ✅ Should execute _run_autogen')
195+
elif framework == 'praisonai':
196+
print(f' 6. ❌ Would execute _run_praisonai (WRONG!)')
197+
else:
198+
print(f' 6. ❌ Would execute _run_crewai (DEFAULT FALLBACK)')
199+
200+
except Exception as e:
201+
print(f'❌ Error tracing execution: {e}')
202+
import traceback
203+
traceback.print_exc()
204+
"
205+
continue-on-error: true
206+
71207
- name: Debug YAML Loading and Roles
72208
run: |
73209
echo "🔍 Tracing YAML file loading and role creation..."
@@ -216,6 +352,114 @@ jobs:
216352
python -m praisonai tests/autogen-agents.yaml
217353
continue-on-error: true
218354

355+
- name: Comprehensive Execution Debug
356+
run: |
357+
echo "🔍 Comprehensive debugging of PraisonAI execution path..."
358+
python -c "
359+
import os
360+
import sys
361+
import yaml
362+
sys.path.insert(0, '.')
363+
364+
print('=' * 60)
365+
print('🔍 COMPREHENSIVE EXECUTION DEBUG')
366+
print('=' * 60)
367+
368+
# Check current working directory
369+
print(f'📁 Current working directory: {os.getcwd()}')
370+
371+
# List files in current directory
372+
print('📋 Files in current directory:')
373+
for f in os.listdir('.'):
374+
print(f' {f}')
375+
376+
print()
377+
print('📋 Files in tests/ directory:')
378+
for f in os.listdir('tests'):
379+
if f.endswith('.yaml'):
380+
print(f' tests/{f}')
381+
382+
# Check if root agents.yaml exists
383+
print()
384+
if os.path.exists('agents.yaml'):
385+
print('❌ ROOT agents.yaml EXISTS (this is the problem!)')
386+
with open('agents.yaml', 'r') as f:
387+
root_config = yaml.safe_load(f)
388+
print(f' Root framework: {root_config.get(\"framework\")}')
389+
print(f' Root roles: {list(root_config.get(\"roles\", {}).keys())}')
390+
else:
391+
print('✅ ROOT agents.yaml does NOT exist (good!)')
392+
393+
# Test the actual execution path
394+
print()
395+
print('🎯 Testing EXACT execution path:')
396+
397+
try:
398+
from praisonai import PraisonAI
399+
from praisonai.agents_generator import AgentsGenerator
400+
401+
# Test with full path
402+
test_file = 'tests/autogen-agents.yaml'
403+
print(f' Using test file: {test_file}')
404+
print(f' File exists: {os.path.exists(test_file)}')
405+
406+
# Load the test file directly
407+
with open(test_file, 'r') as f:
408+
test_config = yaml.safe_load(f)
409+
print(f' Test file framework: {test_config.get(\"framework\")}')
410+
print(f' Test file roles: {list(test_config.get(\"roles\", {}).keys())}')
411+
412+
# Create PraisonAI instance
413+
praisonai = PraisonAI(agent_file=test_file)
414+
print(f' PraisonAI.agent_file: {praisonai.agent_file}')
415+
print(f' PraisonAI.framework: {praisonai.framework}')
416+
417+
# Create AgentsGenerator
418+
agents_gen = AgentsGenerator(
419+
agent_file=test_file,
420+
framework=praisonai.framework,
421+
config_list=praisonai.config_list
422+
)
423+
print(f' AgentsGenerator.agent_file: {agents_gen.agent_file}')
424+
print(f' AgentsGenerator.framework: {agents_gen.framework}')
425+
426+
# Test what would happen in generate_crew_and_kickoff
427+
print()
428+
print('🔧 Testing generate_crew_and_kickoff logic:')
429+
430+
# Simulate the loading logic
431+
if agents_gen.agent_yaml:
432+
loaded_config = yaml.safe_load(agents_gen.agent_yaml)
433+
print(' Would load from agent_yaml')
434+
else:
435+
if agents_gen.agent_file == '/app/api:app' or agents_gen.agent_file == 'api:app':
436+
agents_gen.agent_file = 'agents.yaml'
437+
print(f' Would change agent_file to: {agents_gen.agent_file}')
438+
try:
439+
with open(agents_gen.agent_file, 'r') as f:
440+
loaded_config = yaml.safe_load(f)
441+
print(f' Successfully loaded: {agents_gen.agent_file}')
442+
except FileNotFoundError:
443+
print(f' FileNotFoundError: {agents_gen.agent_file}')
444+
loaded_config = None
445+
446+
if loaded_config:
447+
final_framework = agents_gen.framework or loaded_config.get('framework')
448+
print(f' Final framework decision: {final_framework}')
449+
print(f' Loaded roles: {list(loaded_config.get(\"roles\", {}).keys())}')
450+
451+
if 'researcher' in loaded_config.get('roles', {}):
452+
print(' ❌ FOUND Researcher role in loaded config!')
453+
else:
454+
print(' ✅ No Researcher role in loaded config')
455+
456+
except Exception as e:
457+
print(f'❌ Error during execution debug: {e}')
458+
import traceback
459+
traceback.print_exc()
460+
"
461+
continue-on-error: true
462+
219463
- name: Run Fast Tests
220464
run: |
221465
# Run the fastest, most essential tests
@@ -225,3 +469,16 @@ jobs:
225469
run: |
226470
python -m pytest tests/test.py -v --tb=short --disable-warnings
227471
continue-on-error: true
472+
473+
- name: Restore Root Config Files
474+
run: |
475+
echo "🔄 Restoring root configuration files..."
476+
if [ -f "agents.yaml.backup" ]; then
477+
mv agents.yaml.backup agents.yaml
478+
echo "✅ Restored agents.yaml"
479+
fi
480+
if [ -f "tools.py.backup" ]; then
481+
mv tools.py.backup tools.py
482+
echo "✅ Restored tools.py"
483+
fi
484+
if: always() # Always run this step, even if previous steps failed

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.10 gunicorn markdown
4+
RUN pip install flask praisonai==2.2.11 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.10" \
16+
"praisonai==2.2.11" \
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.10" \
18+
"praisonai==2.2.11" \
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.10" \
16+
"praisonai==2.2.11" \
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.10 gunicorn markdown\n&#34;)
113+
file.write(&#34;RUN pip install flask praisonai==2.2.11 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.10 watchdog
30+
RUN pip install flask praisonai==2.2.11 watchdog
3131

3232
EXPOSE 5555
3333

docs/ui/chat.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ To facilitate local development with live reload, you can use Docker. Follow the
155155

156156
COPY . .
157157

158-
RUN pip install flask praisonai==2.2.10 watchdog
158+
RUN pip install flask praisonai==2.2.11 watchdog
159159

160160
EXPOSE 5555
161161

docs/ui/code.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ To facilitate local development with live reload, you can use Docker. Follow the
208208

209209
COPY . .
210210

211-
RUN pip install flask praisonai==2.2.10 watchdog
211+
RUN pip install flask praisonai==2.2.11 watchdog
212212

213213
EXPOSE 5555
214214

0 commit comments

Comments
 (0)