Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -194,7 +194,6 @@ class UniversalCharacterManager:
|
|
| 194 |
print("💡 Note: In production, integrate with your preferred AI API (OpenAI, Anthropic, etc.)")
|
| 195 |
self.loading = False
|
| 196 |
|
| 197 |
-
@spaces.GPU if SPACES_AVAILABLE else lambda func: func
|
| 198 |
def generate_character_response(self, conversation: str, temperature: float = 0.9) -> str:
|
| 199 |
"""
|
| 200 |
Generate character response using loaded model
|
|
@@ -559,16 +558,6 @@ Character Guidelines:
|
|
| 559 |
|
| 560 |
return " | ".join(insights) if insights else "📊 Standard Creed operating parameters"
|
| 561 |
|
| 562 |
-
# Global character manager instance
|
| 563 |
-
_character_manager = None
|
| 564 |
-
|
| 565 |
-
def get_character_manager():
|
| 566 |
-
"""Get or create global character manager instance"""
|
| 567 |
-
global _character_manager
|
| 568 |
-
if _character_manager is None:
|
| 569 |
-
_character_manager = UniversalCharacterManager()
|
| 570 |
-
return _character_manager
|
| 571 |
-
|
| 572 |
# =================== MCP TOOL INTERFACE ===================
|
| 573 |
# This is what gets called by the MCP system
|
| 574 |
|
|
@@ -592,23 +581,32 @@ def creed_thoughts_fixed_interface(
|
|
| 592 |
Complete interaction with response and analytics
|
| 593 |
"""
|
| 594 |
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 600 |
return {
|
| 601 |
-
"
|
| 602 |
-
"
|
| 603 |
-
"
|
| 604 |
-
"session_analytics": analytics,
|
| 605 |
-
"ready_for_interaction": True
|
| 606 |
}
|
| 607 |
-
|
| 608 |
-
# THE ACTUAL INTERACTION - Peanut butter + jelly!
|
| 609 |
-
result = manager.creed_interact_with_analytics(message, context, temperature)
|
| 610 |
-
|
| 611 |
-
return result
|
| 612 |
|
| 613 |
# For backward compatibility with existing MCP interface
|
| 614 |
def legacy_analytics_only() -> dict:
|
|
|
|
| 194 |
print("💡 Note: In production, integrate with your preferred AI API (OpenAI, Anthropic, etc.)")
|
| 195 |
self.loading = False
|
| 196 |
|
|
|
|
| 197 |
def generate_character_response(self, conversation: str, temperature: float = 0.9) -> str:
|
| 198 |
"""
|
| 199 |
Generate character response using loaded model
|
|
|
|
| 558 |
|
| 559 |
return " | ".join(insights) if insights else "📊 Standard Creed operating parameters"
|
| 560 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 561 |
# =================== MCP TOOL INTERFACE ===================
|
| 562 |
# This is what gets called by the MCP system
|
| 563 |
|
|
|
|
| 581 |
Complete interaction with response and analytics
|
| 582 |
"""
|
| 583 |
|
| 584 |
+
try:
|
| 585 |
+
# Initialize fresh manager each time to avoid boot loops
|
| 586 |
+
manager = UniversalCharacterManager()
|
| 587 |
+
|
| 588 |
+
if not message:
|
| 589 |
+
# If no message, return status but also show how to use it properly
|
| 590 |
+
analytics = manager.get_character_analytics()
|
| 591 |
+
return {
|
| 592 |
+
"status": "Ready for interaction",
|
| 593 |
+
"usage_example": "Call with message='Hey Creed, what are you working on?'",
|
| 594 |
+
"available_contexts": ["office", "mysterious", "business", "paranoid"],
|
| 595 |
+
"session_analytics": analytics,
|
| 596 |
+
"ready_for_interaction": True
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
# THE ACTUAL INTERACTION - Peanut butter + jelly!
|
| 600 |
+
result = manager.creed_interact_with_analytics(message, context, temperature)
|
| 601 |
+
|
| 602 |
+
return result
|
| 603 |
+
|
| 604 |
+
except Exception as e:
|
| 605 |
return {
|
| 606 |
+
"error": f"Boot loop prevented: {str(e)}",
|
| 607 |
+
"status": "System recovering",
|
| 608 |
+
"suggestion": "Try with simpler parameters"
|
|
|
|
|
|
|
| 609 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
|
| 611 |
# For backward compatibility with existing MCP interface
|
| 612 |
def legacy_analytics_only() -> dict:
|