Skip to content

Latest commit

 

History

History
54 lines (34 loc) · 3.34 KB

File metadata and controls

54 lines (34 loc) · 3.34 KB

GitHub Copilot Agent Mode - Prompt 2A: Architecture Framework Discussions

Prompt: I think the structure of FASTAPI route is a bit rigid while the SK is flexible 'routing' to functions. How do you see these two schemes working together in a more natural way? Maybe the FASTAPI route needs to be focused on user interaction messages.

Agent : Great insight! You’re correct: FastAPI’s routes are static and explicit (one route per endpoint), while Semantic Kernel (SK) enables dynamic, intent-driven “routing” based on user input and context. Here’s how you can combine their strengths for a more natural, flexible architecture:

The Agent generated updated architecture ideas...

Agent: Would you like a sample FastAPI + SK integration code snippet or a more detailed architectural diagram for this pattern?

Prompt Response: I do not need a diagram. I'd like you to update the scaffolding code for this app based on the new architecture idea which I documented in P2A-Architecture-Design-Framework-Discussions.md

The Agent updated all the scaffolding code....


1. FastAPI as the Gateway for User Interactions

  • FastAPI routes become “entry points” for user actions—especially chat, message, or command endpoints.
  • Instead of one route per business action, you can have a single /chat or /message endpoint that receives all user input (text, voice, etc.).

2. Semantic Kernel as the Dynamic Orchestrator

  • The FastAPI endpoint passes the user message and context to SK.
  • SK uses LLMs and planners to classify the message (intent detection) and decide which skills (functions, plugins, or business logic) to invoke.
  • SK can chain together multiple skills, call external APIs, or query your database as needed.

3. Example Flow

  1. User sends a message (e.g., “Add two bags of coffee to my cart and show me my wishlist”).
  2. FastAPI /chat endpoint receives the message and forwards it to SK.
  3. SK classifies the intent(s) (add to cart, show wishlist) and routes to the right skills/agents.
  4. SK executes the skills (calls your cart and wishlist logic, possibly in parallel or sequence).
  5. SK composes a response and returns it to FastAPI, which sends it to the frontend.

4. Benefits

  • Natural User Experience: Users interact in free-form language; SK handles the complexity of mapping intent to actions.
  • Minimal API Surface: You only need a few endpoints (e.g., /chat, /action, /feedback), not one for every possible operation.
  • Easy to Extend: Add new skills/agents to SK without changing your FastAPI routes.
  • Centralized Orchestration: All business logic and AI reasoning live in SK, keeping FastAPI focused on HTTP and security.

5. Practical Suggestion

  • Use FastAPI for authentication, session management, and as a secure HTTP interface.
  • Use a single /chat or /message endpoint for all conversational input.
  • Let SK handle message classification, intent detection, and function routing.
  • Optionally, expose a few “direct” API endpoints for non-chat integrations (e.g., admin, health checks).

Summary: Let FastAPI handle the “plumbing” (HTTP, auth, security), and let Semantic Kernel handle the “thinking” (intent, orchestration, dynamic routing). This hybrid approach gives you the best of both worlds: robust APIs and flexible, AI-driven user experiences.