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