Skip to content

Commit d7a2a10

Browse files
authored
Merge branch 'Agents-and-Actions-Modal-Updates' into Development
2 parents cf24854 + b739f05 commit d7a2a10

File tree

76 files changed

+7960
-1042
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+7960
-1042
lines changed

.github/instructions/code_to_run_flask_app.instructions.md

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
---
2+
applyTo: '**'
3+
---
4+
5+
# Functional Tests Management Instructions
6+
7+
## 📍 **Location**
8+
All functional tests are stored in: `.\simplechat\application\single_app\functional_tests\`
9+
10+
## 📂 **Directory Structure**
11+
The functional tests directory contains:
12+
- **Python test files** (`test_*.py`) - Executable test scripts
13+
- **JavaScript test files** (`test_*.js`) - Client-side/browser test scripts
14+
- **Documentation files** (`*.md`) - Test documentation and fix summaries
15+
- **flask_session/** - Session data for tests requiring authenticated state
16+
17+
## 🎯 **When to Create Functional Tests**
18+
19+
### **Always Create Tests For:**
20+
**Bug Fixes** - Validate the fix works and prevents regression
21+
**New Features** - Ensure functionality works as designed
22+
**API Changes** - Verify operation consistency and compatibility
23+
**Plugin Integration** - Test plugin loading, operation calls, error handling
24+
**Database Migration** - Validate data migration and container operations
25+
**UI/UX Changes** - Test display logic, user interactions, data flow
26+
**Authentication/Security** - Verify access controls and data isolation
27+
28+
### **Test Categories:**
29+
- **Integration Tests** - End-to-end functionality across multiple components
30+
- **Regression Tests** - Prevent previously fixed bugs from returning
31+
- **Consistency Tests** - Validate behavior remains consistent across iterations
32+
- **Migration Tests** - Verify data and schema migrations work correctly
33+
34+
## 📝 **Naming Conventions**
35+
36+
### **File Naming:**
37+
- **Python Tests**: `test_{feature_area}_{specific_test}.py`
38+
- **JavaScript Tests**: `test_{feature_area}_{specific_test}.js`
39+
- **Documentation**: `{FEATURE_AREA}_{DESCRIPTION}.md`
40+
41+
### **Examples:**
42+
```
43+
test_agent_citations_fix.py # Agent citation bug fix
44+
test_semantic_kernel_operation_consistency.py # SK operation reliability
45+
test_openapi_operation_lookup.py # OpenAPI plugin testing
46+
test_conversation_id_display.py # UI feature testing
47+
test_migration.py # Database migration testing
48+
AGENT_MODEL_DISPLAY_FIXES.md # Fix documentation
49+
```
50+
51+
## 🏗️ **Test Structure Patterns**
52+
53+
### **Python Test Template:**
54+
```python
55+
#!/usr/bin/env python3
56+
"""
57+
Brief description of what this test validates.
58+
59+
This test ensures [specific functionality] works correctly and
60+
prevents regression of [specific issue/bug].
61+
"""
62+
63+
import sys
64+
import os
65+
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
66+
67+
def test_primary_functionality():
68+
"""Test the main functionality."""
69+
print("🔍 Testing [Feature Name]...")
70+
71+
try:
72+
# Setup
73+
# Test execution
74+
# Validation
75+
# Cleanup
76+
77+
print("✅ Test passed!")
78+
return True
79+
80+
except Exception as e:
81+
print(f"❌ Test failed: {e}")
82+
import traceback
83+
traceback.print_exc()
84+
return False
85+
86+
if __name__ == "__main__":
87+
success = test_primary_functionality()
88+
sys.exit(0 if success else 1)
89+
```
90+
91+
### **Multi-Test Pattern:**
92+
```python
93+
def test_feature_a():
94+
"""Test specific aspect A."""
95+
# Implementation
96+
97+
def test_feature_b():
98+
"""Test specific aspect B."""
99+
# Implementation
100+
101+
if __name__ == "__main__":
102+
tests = [test_feature_a, test_feature_b]
103+
results = []
104+
105+
for test in tests:
106+
print(f"\n🧪 Running {test.__name__}...")
107+
results.append(test())
108+
109+
success = all(results)
110+
print(f"\n📊 Results: {sum(results)}/{len(results)} tests passed")
111+
sys.exit(0 if success else 1)
112+
```
113+
114+
## 🔍 **Test Discovery & Reuse**
115+
116+
### **Before Creating New Tests:**
117+
1. **Search existing tests**: `grep -r "test_.*{feature}" functional_tests/`
118+
2. **Check for similar patterns**: Look for tests in the same feature area
119+
3. **Review related documentation**: Check for `*.md` files describing fixes
120+
4. **Examine imports**: See what modules/functions are already being tested
121+
122+
### **Reusable Test Components:**
123+
- **OpenAPI Testing**: Use `OpenApiPluginFactory` patterns from `test_openapi_*.py`
124+
- **Agent Testing**: Reference citation and model display test patterns
125+
- **Database Testing**: Follow migration test patterns for Cosmos DB operations
126+
- **Plugin Testing**: Use plugin logging patterns for function call validation
127+
128+
## 🔧 **Common Testing Utilities**
129+
130+
### **Available Imports:**
131+
```python
132+
# OpenAPI Plugin Testing
133+
from semantic_kernel_plugins.openapi_plugin_factory import OpenApiPluginFactory
134+
135+
# Database Operations (Personal Containers)
136+
from functions_personal_agents import get_personal_agents, save_personal_agent
137+
from functions_personal_actions import get_personal_actions, save_personal_action
138+
139+
# Plugin Logging
140+
from semantic_kernel_plugins.plugin_logging import get_plugin_logger
141+
142+
# Conversation Management
143+
from conversation_manager import ConversationManager
144+
```
145+
146+
### **Test Data Patterns:**
147+
```python
148+
# Test User ID
149+
test_user_id = "test-user-12345"
150+
151+
# Test Agent Configuration
152+
test_agent = {
153+
"name": "TestAgent",
154+
"display_name": "Test Agent",
155+
"description": "A test agent for validation",
156+
"instructions": "You are a test agent",
157+
"azure_openai_gpt_deployment": "gpt-4o"
158+
}
159+
160+
# Test OpenAPI Plugin Configuration
161+
test_config = {
162+
'name': 'test_plugin',
163+
'base_url': 'https://api.example.com',
164+
'openapi_spec_content': {
165+
'openapi': '3.0.0',
166+
'info': {'title': 'Test API', 'version': '1.0.0'},
167+
'paths': {
168+
'/test': {
169+
'get': {
170+
'operationId': 'testOperation',
171+
'summary': 'Test operation'
172+
}
173+
}
174+
}
175+
}
176+
}
177+
```
178+
179+
## 🎯 **Where to Store Tests**
180+
181+
### **Test Categories by Directory Usage:**
182+
- **Core Functionality Tests** → Direct in `functional_tests/`
183+
- **Fix Validation Tests**`functional_tests/` with accompanying `.md` documentation
184+
- **Plugin Integration Tests**`functional_tests/` (follow `test_openapi_*.py` patterns)
185+
- **Migration Tests**`functional_tests/` (follow `test_migration.py` pattern)
186+
- **UI/Display Tests**`functional_tests/` (follow `test_*_display.py` patterns)
187+
188+
### **Documentation Requirements:**
189+
- **For Bug Fixes**: Create accompanying `.md` file describing the issue and solution
190+
- **For New Features**: Include comprehensive test documentation in docstrings
191+
- **For Complex Integrations**: Add setup/teardown documentation
192+
193+
## **Execution Patterns**
194+
195+
### **Standalone Execution:**
196+
```bash
197+
cd functional_tests
198+
python test_specific_feature.py
199+
```
200+
201+
### **Multiple Test Execution:**
202+
```bash
203+
# Run all Python tests
204+
for test in test_*.py; do python $test; done
205+
206+
# Run specific test pattern
207+
python test_openapi_*.py
208+
```
209+
210+
### **Integration with Development Workflow:**
211+
- Run relevant tests after making changes in related areas
212+
- Create/update tests as part of bug fix or feature development
213+
- Use tests to validate fixes before marking issues as resolved
214+
215+
## 📋 **Best Practices**
216+
217+
### **Test Design:**
218+
**Independent Tests** - Each test should run standalone without dependencies
219+
**Clear Output** - Use emojis and descriptive messages for test progress
220+
**Proper Cleanup** - Clean up test data to avoid pollution
221+
**Error Handling** - Include comprehensive error reporting with stack traces
222+
**Validation** - Test both positive and negative scenarios
223+
224+
### **Code Organization:**
225+
**Meaningful Names** - Test and function names should describe what they validate
226+
**Documentation** - Include docstrings explaining test purpose and approach
227+
**Imports** - Group imports logically and include only necessary dependencies
228+
**Modularity** - Break complex tests into smaller, focused functions
229+
230+
### **Maintenance:**
231+
**Regular Review** - Periodically review and update tests for relevance
232+
**Refactoring** - Extract common patterns into reusable utilities
233+
**Documentation Updates** - Keep test documentation current with code changes

AGENT_CITATIONS_BUG_FIX.md

Whitespace-only changes.

application/external_apps/databaseseeder/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def main():
182182
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), settings_file_path)
183183

184184
#azure_openai_gpt_key = settings_json_from_file['azure_openai_gpt_key']
185-
#print(f"Debug: azure_openai_gpt_key: {azure_openai_gpt_key}")
185+
print(f"DEBUG: azure_openai_gpt_key: {azure_openai_gpt_key}")
186186
# Single value modification example
187187
#settings_json["azure_openai_gpt_key"] = f"{azure_openai_gpt_key}" # Example modification
188188

application/single_app/agent_logging_chat_completion.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,23 @@ class LoggingChatCompletionAgent(ChatCompletionAgent):
1212
display_name: str | None = Field(default=None)
1313
default_agent: bool = Field(default=False)
1414
tool_invocations: list = Field(default_factory=list)
15+
deployment_name: str | None = Field(default=None)
16+
azure_endpoint: str | None = Field(default=None)
17+
api_version: str | None = Field(default=None)
1518

16-
def __init__(self, *args, display_name=None, default_agent=False, **kwargs):
19+
def __init__(self, *args, display_name=None, default_agent=False, deployment_name=None, azure_endpoint=None, api_version=None, **kwargs):
1720
# Remove these from kwargs so the base class doesn't see them
1821
kwargs.pop('display_name', None)
1922
kwargs.pop('default_agent', None)
23+
kwargs.pop('deployment_name', None)
24+
kwargs.pop('azure_endpoint', None)
25+
kwargs.pop('api_version', None)
2026
super().__init__(*args, **kwargs)
2127
self.display_name = display_name
2228
self.default_agent = default_agent
29+
self.deployment_name = deployment_name
30+
self.azure_endpoint = azure_endpoint
31+
self.api_version = api_version
2332
# tool_invocations is now properly declared as a Pydantic field
2433

2534
def log_tool_execution(self, tool_name, arguments=None, result=None):

application/single_app/app.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
def before_first_request():
8888
print("Initializing application...")
8989
settings = get_settings()
90-
print(f"Application settings: {settings}")
90+
print(f"DEBUG:Application settings: {settings}")
9191
initialize_clients(settings)
9292
ensure_custom_logo_file_exists(app, settings)
9393
# Enable Application Insights logging globally if configured
@@ -423,9 +423,16 @@ def list_semantic_kernel_plugins():
423423
# ------------------- Extenral Admin Settings Routes ----------
424424
register_route_external_admin_settings(app)
425425

426-
427426
if __name__ == '__main__':
428427
settings = get_settings()
429-
print(f"Starting Single App. Initializing clients...")
430428
initialize_clients(settings)
431-
app.run(host="0.0.0.0", port=5000, debug=False)
429+
430+
env = os.environ.get("FLASK_ENV", "production")
431+
432+
if env == "development":
433+
# Local dev with HTTPS
434+
app.run(host="0.0.0.0", port=5000, debug=True, ssl_context='adhoc')
435+
else:
436+
# Production - use WSGI server like Gunicorn
437+
port = int(os.environ.get("PORT", 5000))
438+
app.run(host="0.0.0.0", port=port, debug=False)

application/single_app/config.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
executor = Executor()
9292
executor.init_app(app)
9393
app.config['SESSION_TYPE'] = 'filesystem'
94-
app.config['VERSION'] = "0.224.112"
94+
app.config['VERSION'] = "0.226.082"
9595

9696
Session(app)
9797

@@ -318,6 +318,18 @@
318318
partition_key=PartitionKey(path="/group_id")
319319
)
320320

321+
cosmos_global_agents_container_name = "global_agents"
322+
cosmos_global_agents_container = cosmos_database.create_container_if_not_exists(
323+
id=cosmos_global_agents_container_name,
324+
partition_key=PartitionKey(path="/id")
325+
)
326+
327+
cosmos_global_actions_container_name = "global_actions"
328+
cosmos_global_actions_container = cosmos_database.create_container_if_not_exists(
329+
id=cosmos_global_actions_container_name,
330+
partition_key=PartitionKey(path="/id")
331+
)
332+
321333
cosmos_agent_facts_container_name = "agent_facts"
322334
cosmos_agent_facts_container = cosmos_database.create_container_if_not_exists(
323335
id=cosmos_agent_facts_container_name,

application/single_app/functional_tests/AGENT_CITATIONS_PER_MESSAGE_FIX.md

Whitespace-only changes.

application/single_app/functional_tests/AGENT_MODEL_DISPLAY_FIXES.md

Whitespace-only changes.

application/single_app/functional_tests/CONVERSATION_ID_DISPLAY_FIX.md

Whitespace-only changes.

0 commit comments

Comments
 (0)