Routing Studio
根據糾正記錄建議規則
根據最近一組路由糾正記錄,生成一條安全的正則表達式規則。
POST
/
api
/
v1
/
routing-preferences
/
suggest-rule
根據糾正記錄建議規則
curl --request POST \
--url https://api.example.com/api/v1/routing-preferences/suggest-rule \
--header 'Content-Type: application/json' \
--data '
{
"expected_mode": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/routing-preferences/suggest-rule"
payload = { "expected_mode": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({expected_mode: '<string>'})
};
fetch('https://api.example.com/api/v1/routing-preferences/suggest-rule', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/routing-preferences/suggest-rule",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'expected_mode' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/routing-preferences/suggest-rule"
payload := strings.NewReader("{\n \"expected_mode\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/routing-preferences/suggest-rule")
.header("Content-Type", "application/json")
.body("{\n \"expected_mode\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/routing-preferences/suggest-rule")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"expected_mode\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body針對指定模式,根據調用方最近的糾正記錄生成一條建議規則。分兩級處理:
當模式由確定性輔助函數生成時,
- 優先使用確定性方法。 一個純輔助函數會在該糾正記錄簇的提示詞中提取文檔頻率(DF)最高的內容令牌,並組裝出安全的
\b(token1|token2|…)\b模式。已做供應商名稱清洗。 - LLM 回退。 如果確定性輔助函數沒有返回任何結果(沒有可用的令牌存留),Theo 會請求內部分類模型給出一條能匹配樣本提示詞的正則表達式。輸出會被重新掃描以排查供應商名稱,並在被信任前完成編譯。若回退結果未通過任一檢查,則返回
404,確保不安全的規則永遠不會泄露出去。
PATCH /api/v1/routing-preferences/{id} 將建議規則 PATCH 到某個現有偏好設置上(或將其添加到新的偏好設置中)。
身份驗證
需要攜帶具有billing API 密鑰作用域的 Bearer 令牌。
請求體
string
必填
你希望獲取規則建議的 Theo 模式對應的糾正記錄簇。
請求示例
curl
curl -X POST https://www.hitheo.ai/api/v1/routing-preferences/suggest-rule \
-H "Authorization: Bearer $THEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "expected_mode": "think" }'
響應
{
"suggested_rule": {
"pattern": "\\b(clause|provision|indemnity)\\b",
"target_mode": "think",
"confidence": 0.88,
"description": "Generated from 4 corrections that all routed to think."
},
"source_correction_ids": ["corr_a", "corr_b", "corr_c", "corr_d"],
"confidence": 0.88
}
confidence 為 0.88;當由 LLM 回退生成時,為 0.78。
錯誤
400 routing_suggest_below_threshold— 所請求模式對應的糾正記錄簇中,糾正記錄數量未達到簇閾值。404 not_found—expected_mode不存在對應的記錄簇,或無法從現有樣本中推導出安全的規則。
這個頁面有幫助嗎?
根據糾正記錄建議規則
curl --request POST \
--url https://api.example.com/api/v1/routing-preferences/suggest-rule \
--header 'Content-Type: application/json' \
--data '
{
"expected_mode": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/routing-preferences/suggest-rule"
payload = { "expected_mode": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({expected_mode: '<string>'})
};
fetch('https://api.example.com/api/v1/routing-preferences/suggest-rule', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/routing-preferences/suggest-rule",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'expected_mode' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/routing-preferences/suggest-rule"
payload := strings.NewReader("{\n \"expected_mode\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/routing-preferences/suggest-rule")
.header("Content-Type", "application/json")
.body("{\n \"expected_mode\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/routing-preferences/suggest-rule")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"expected_mode\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body