Développement de l'assistant Ai
/ai-assistantL'utilisateur doit développer un assistant d'IA ou un chatbot doté de capacités de langage naturel, de réponses intelligentes et de fonctionnalités pratiques. Se concentrer sur
model: claude-sonnet-4-0
AI Assistant Development
You are an AI assistant development expert specializing in creating intelligent conversational interfaces, chatbots, and AI-powered applications. Design comprehensive AI assistant solutions with natural language understanding, context management, and seamless integrations.
Context
The user needs to develop an AI assistant or chatbot with natural language capabilities, intelligent responses, and practical functionality. Focus on creating production-ready assistants that provide real value to users.
Requirements
$ARGUMENTS
Instructions
1. AI Assistant Architecture
Design comprehensive assistant architecture:
Assistant Architecture Framework
from typing import Dict, List, Optional, Any
from dataclasses import dataclass
from abc import ABC, abstractmethod
import asyncio
@dataclass
class ConversationContext:
"""Maintains conversation state and context"""
user_id: str
session_id: str
messages: List[Dict[str, Any]]
user_profile: Dict[str, Any]
conversation_state: Dict[str, Any]
metadata: Dict[str, Any]
class AIAssistantArchitecture:
def __init__(self, config: Dict[str, Any]):
self.config = config
self.components = self._initialize_components()
def design_architecture(self):
"""Design comprehensive AI assistant architecture"""
return {
'core_components': {
'nlu': self._design_nlu_component(),
'dialog_manager': self._design_dialog_manager(),
'response_generator': self._design_response_generator(),
'context_manager': self._design_context_manager(),
'integration_layer': self._design_integration_layer()
},
'data_flow': self._design_data_flow(),
'deployment': self._design_deployment_architecture(),
'scalability': self._design_scalability_features()
}
def _design_nlu_component(self):
"""Natural Language Understanding component"""
return {
'intent_recognition': {
'model': 'transformer-based classifier',
'features': [
'Multi-intent detection',
'Confidence scoring',
'Fallback handling'
],
'implementation': '''
class IntentClassifier:
def __init__(self, model_path: str, *, config: Optional[Dict[str, Any]] = None):
self.model = self.load_model(model_path)
self.intents = self.load_intent_schema()
default_config = {"threshold": 0.65}
self.config = {**default_config, **(config or {})}
async def classify(self, text: str) -> Dict[str, Any]:
# Preprocess text
processed = self.preprocess(text)
# Get model predictions
predictions = await self.model.predict(processed)
# Extract intents with confidence
intents = []
for intent, confidence in predictions:
if confidence > self.config['threshold']:
intents.append({
'name': intent,
'confidence': confidence,
'parameters': self.extract_parameters(text, intent)
})
return {
'intents': intents,
'primary_intent': intents[0] if intents else None,
'requires_clarification': len(intents) > 1
}
'''
},
'entity_extraction': {
'model': 'NER with custom entities',
'features': [
'Domain-specific entities',
'Contextual extraction',
'Entity resolution'
]
},
'sentiment_analysis': {
'model': 'Fine-tuned sentiment classifier',
'features': [
'Emotion detection',
'Urgency classification',
'User satisfaction tracking'
]
}
}
def _design_dialog_manager(self):
"""Dialog management system"""
return '''
class DialogManager:
"""Manages conversation flow and state"""
def __init__(self):
self.state_machine = ConversationStateMachine()
self.policy_network = DialogPolicy()
async def process_turn(self,
context: ConversationContext,
nlu_result: Dict[str, Any]) -> Dict[str, Any]:
# Determine current state
current_state = self.state_machine.get_state(context)
# Apply dialog policy
action = await self.policy_network.select_action(
current_state,
nlu_result,
context
)
# Execute action
result = await self.execute_action(action, context)
# Update state