Skip to content

Commit 6ed02d1

Browse files
authored
Merge pull request #127 from buerokratt/wip
Service layer validation in tool classifier (buerokratt#321)
2 parents 068f4e0 + c7b66d0 commit 6ed02d1

File tree

16 files changed

+1883
-393
lines changed

16 files changed

+1883
-393
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Count active services for tool classifier
2+
-- Used by Service Workflow to determine search strategy:
3+
-- - If count <= 50: Use all services for LLM context
4+
-- - If count > 50: Use Qdrant semantic search for top 20
5+
6+
SELECT
7+
COUNT(*) AS active_service_count
8+
FROM
9+
public.services
10+
WHERE
11+
current_state = 'active';
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Get all active services for intent detection
2+
-- Used when active_service_count <= 50
3+
-- Returns all service metadata needed for LLM intent detection
4+
5+
SELECT
6+
service_id,
7+
name,
8+
description,
9+
ruuter_type,
10+
slot,
11+
entities,
12+
examples,
13+
structure,
14+
endpoints
15+
FROM
16+
public.services
17+
WHERE
18+
current_state = 'active'
19+
ORDER BY
20+
name ASC;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-- Get specific service by service_id for validation
2+
-- Used after LLM detects intent to validate the service exists and is active
3+
-- Returns all service details needed to trigger the external service call
4+
5+
SELECT
6+
id,
7+
service_id,
8+
name,
9+
description,
10+
ruuter_type,
11+
current_state,
12+
is_common,
13+
slot,
14+
entities,
15+
examples,
16+
structure,
17+
endpoints,
18+
created_at,
19+
updated_at
20+
FROM
21+
public.services
22+
WHERE
23+
service_id = :serviceId
24+
AND current_state = 'active';
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
declaration:
2+
call: declare
3+
version: 0.1
4+
description: "Get services for intent detection - returns all services if count <= 10, otherwise signals to use semantic search"
5+
method: get
6+
returns: json
7+
namespace: rag-search
8+
9+
# Step 1: Count active services
10+
count_services:
11+
call: http.post
12+
args:
13+
url: "[#RAG_SEARCH_RESQL]/mock-count-active-services"
14+
body: {}
15+
result: count_result
16+
next: check_service_count
17+
18+
# Step 2: Check if count > threshold (10)
19+
check_service_count:
20+
assign:
21+
service_count: ${Number(count_result.response.body[0].active_service_count)}
22+
switch:
23+
- condition: "${service_count > 10}"
24+
next: return_semantic_search_flag
25+
next: fetch_all_services
26+
27+
# Step 3a: If > 10, return flag for semantic search
28+
return_semantic_search_flag:
29+
assign:
30+
semantic_search_response:
31+
use_semantic_search: true
32+
service_count: ${service_count}
33+
message: "Service count exceeds threshold - use semantic search"
34+
next: return_semantic_search_response
35+
36+
return_semantic_search_response:
37+
return: ${semantic_search_response}
38+
next: end
39+
40+
# Step 3b: If <= 10, fetch all services
41+
fetch_all_services:
42+
call: http.post
43+
args:
44+
url: "[#RAG_SEARCH_RESQL]/mock-get-all-active-services"
45+
body: {}
46+
result: services_result
47+
next: return_all_services
48+
49+
# Step 4: Return all services for LLM
50+
return_all_services:
51+
assign:
52+
all_services_response:
53+
use_semantic_search: false
54+
service_count: ${services_result.response.body.length}
55+
services: ${services_result.response.body}
56+
next: return_all_services_response
57+
58+
return_all_services_response:
59+
return: ${all_services_response}
60+
next: end

0 commit comments

Comments
 (0)