feat: add Server Expert AI with search/docs tools for trend-aware recommendations
- Add server-agent.ts with 30-year senior architect persona - Implement KV-based session management for multi-turn conversations - Add search_trends (Brave Search) and lookup_framework_docs (Context7) tools - Function Calling support with max 3 tool calls per request - Auto-infer tech stack and expected users from use case/scale - Prohibit competitor provider mentions (AWS, GCP, Azure, etc.) - Simplify main AI system prompt, delegate complex logic to expert AI Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -93,6 +93,25 @@ export async function generateOpenAIResponse(
|
||||
telegramUserId?: string,
|
||||
db?: D1Database
|
||||
): Promise<string> {
|
||||
// Check if server consultation session is active
|
||||
if (telegramUserId && env.SESSION_KV) {
|
||||
try {
|
||||
const { getServerSession, processServerConsultation } = await import('./server-agent');
|
||||
const session = await getServerSession(env.SESSION_KV, telegramUserId);
|
||||
|
||||
if (session && session.status !== 'completed') {
|
||||
logger.info('Active server session detected, routing to consultation', {
|
||||
userId: telegramUserId,
|
||||
status: session.status
|
||||
});
|
||||
return await processServerConsultation(userMessage, session, env);
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Session check failed, continuing with normal flow', error as Error);
|
||||
// Continue with normal flow if session check fails
|
||||
}
|
||||
}
|
||||
|
||||
if (!env.OPENAI_API_KEY) {
|
||||
throw new Error('OPENAI_API_KEY not configured');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user