Skip to content

[FEATURE] Implement Example Question Resolver & Incremental Streaming Support #524

@AndlerRL

Description

@AndlerRL

Context:
This issue is created based on this comment by @AndlerRL regarding a new approach for handling example questions and streamlining the user experience when starting conversations with pre-selected questions.


Description

We need to restructure how we handle example questions and how we serve answers for them when the user does not modify the question. The main idea is:

  • Pre-load 16–24 example questions per bot (50% deep expertise, 50% regular) into constants to avoid unnecessary chain requests on load.

  • When the user selects an example question without modifying it, the backend should detect that and serve the answer immediately, skipping the standard AI processing flow.

  • If feasible, reuse the same api/chat route but adapt its logic to:

    • Detect these pre-defined example question IDs or content hash.
    • Return pre-stored answers instantly or through a custom stream resolver.
    • Optionally build this using Vercel AI SDK and Next.js routes to improve UI responsiveness.

Tasks

Immediate Tasks (Simplified flow for this PR)

  • Grab the selected example question (even if slightly modified).
  • Start a conversation using that question via the regular api/chat route.
  • Continue the usual flow for now (skip optimization).

Future Tasks (Create new PR later)

  • Research feasibility of using Vercel AI SDK to:

    • Override api/chat with a custom stream response.
    • Render UI incrementally as response is streamed.
  • Design a stream resolver that can detect when an example question is selected.

  • Serve pre-defined answers quickly from constant object/cache if question is recognized.

  • Document structure of pre-selected constant questions and their associated metadata (e.g., deepExpertise flag, score, etc).


Technical Considerations

  • Ensure that a custom api/chat resolver can support:

    • Distinction between real user input vs selected template questions.
    • Return a mock/constant answer fast.
  • Might need a dedicated streamer function to reflect real-time changes in UI.

  • Use ICL (In-Context Learning) examples based on scoring logic (e.g., top 50%).


Follow-up

This task can remain unassigned until the base infrastructure decision is made (Vercel AI SDK vs custom route middleware). Meanwhile, implement simplified logic in current PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions