tiangong-lca

flow-hybrid-search

1
0
# Install this skill:
npx skills add tiangong-lca/skills --skill "flow-hybrid-search"

Install specific skill from multi-skill repository

# Description

Supabase edge function supabase/functions/flow_hybrid_search that turns a flow description into LCA-aware full-text + embedding queries and calls `hybrid_search_flows`. Use when debugging hybrid search for flows, tuning prompts/models, or wiring auth/env.

# SKILL.md


name: flow-hybrid-search
description: Supabase edge function supabase/functions/flow_hybrid_search that turns a flow description into LCA-aware full-text + embedding queries and calls hybrid_search_flows. Use when debugging hybrid search for flows, tuning prompts/models, or wiring auth/env.


Flow Hybrid Search

Quick start (remote only)

  • Endpoint: https://qgzvkongdjqiiamzbbts.supabase.co/functions/v1/
  • Header: x-region: us-east-1
  • Requires Authorization: Bearer <TOKEN>.
  • TOKEN is either an OAuth JWT or a user key generated in the system (derived from email + password).
  • Example call:
    bash curl -i --location --request POST "https://qgzvkongdjqiiamzbbts.supabase.co/functions/v1/flow_hybrid_search" \ --header 'Content-Type: application/json' \ --header 'x-region: us-east-1' \ --header "Authorization: Bearer $TOKEN" \ --data @assets/example-request.json
  • Model/SageMaker is configured in the deployed function; callers do not set it.

Request & output

  • POST JSON: { "query": string, "filter"?: object|string }.
  • Returns 200 with { data } array or []; 400 if query missing; 500 on RPC/embedding errors.

Processing flow

1) OPTIONS handled for CORS via _shared/cors.
2) Run ChatOpenAI (temperature 0, OPENAI_CHAT_MODEL) with structured output schema: semantic_query_en (string) + fulltext_query_en[] + fulltext_query_zh[]; prompt is flow-specific LCA instructions.
3) Combine full-text queries: (q1) OR (q2)...; generate embedding for semantic_query_en using SageMaker endpoint (JSON {inputs: text}) and extract first number array from response.
4) Call supabase.rpc('hybrid_search_flows', { query_text, query_embedding: "[v1,...]", filter_condition }).
5) Respond with data or empty array; errors logged and returned as JSON 500.

Change points

  • Prompt/fields: edit query schema or system prompt for different outputs.
  • Model: switch OPENAI_CHAT_MODEL or SageMaker endpoint payload/region.
  • Search backend: change RPC name/params to target different table/index.
  • Filter handling: ensure callers send string vs object; function serializes non-string via JSON.stringify.

References

  • references/env.md - env notes.
  • references/request-response.md - payload, filters, and RPC expectations.
  • references/prompts.md - prompt requirements for query generation.
  • references/testing.md - curl and debugging checklist.

Assets

  • assets/example-request.json - sample query/filter body.

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.