Routing Studio
記錄一次路由糾正
提交 playground 中的“重新路由(Reroute)”操作,幫助 Theo 瞭解全局分類器在哪裏出錯。
POST
/
api
/
v1
/
routing-preferences
/
corrections
記錄一次路由糾正
curl --request POST \
--url https://api.example.com/api/v1/routing-preferences/corrections \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"expected_mode": "<string>",
"source_message_id": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/routing-preferences/corrections"
payload = {
"prompt": "<string>",
"expected_mode": "<string>",
"source_message_id": "<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({prompt: '<string>', expected_mode: '<string>', source_message_id: '<string>'})
};
fetch('https://api.example.com/api/v1/routing-preferences/corrections', 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/corrections",
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([
'prompt' => '<string>',
'expected_mode' => '<string>',
'source_message_id' => '<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/corrections"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<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/corrections")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/routing-preferences/corrections")
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 \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body記錄一次路由糾正——即開發者對已解析的模式表示不認同,並提供了他們期望的模式的一次對話輪次。Theo 會為每個調用方保留最近 30 天的糾正記錄,並按
當
expected_mode 對其進行聚類;一旦某個聚類超過閾值,playground 就會顯示一條“我發現了一個規律”的提示,開發者可以據此讓 Theo 建議一條規則,該規則由該聚類推導而來。
糾正記錄的作用域為個人或團隊級別(與調用方當前激活的組織上下文一致),因此個人的糾正記錄不會觸發團隊級別的建議提示條。
身份驗證
需要攜帶具備billing API 密鑰作用域的 Bearer 令牌。該接口是冪等的:相同的 Idempotency-Key 請求頭會重放相同的響應。
請求體
string
必填
產生了非預期模式的提示詞。長度為 1–4096 個字符。會在服務層做供應商名稱脫敏處理。
string
必填
開發者期望的 Theo 模式(例如
"think"、"image"、"insurance_quote")。string
可選參數,指該糾正所關聯對話輪次的消息 id。長度不超過 128 個字符。
請求示例
curl
curl -X POST https://www.hitheo.ai/api/v1/routing-preferences/corrections \
-H "Authorization: Bearer $THEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Look at this indemnity clause",
"expected_mode": "think"
}'
響應
{
"id": "corr_abc123",
"ok": true,
"cluster_threshold": 3,
"pattern_suggestion_available": true,
"pattern_expected_mode": "think",
"pattern_count": 3
}
pattern_suggestion_available 為 true 時,可調用 POST /api/v1/routing-preferences/suggest-rule,並傳入匹配的 expected_mode,即可獲得一條由該聚類推導出的確定性正則表達式。
錯誤
400 routing_correction_invalid—— 通用的請求結構校驗失敗。400 routing_correction_vendor_name—— 提示詞中提及了上游供應商名稱(如 Claude、OpenAI 等)。400 routing_correction_invalid_mode——expected_mode不是已知的 Theo 模式。
這個頁面有幫助嗎?
記錄一次路由糾正
curl --request POST \
--url https://api.example.com/api/v1/routing-preferences/corrections \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"expected_mode": "<string>",
"source_message_id": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/routing-preferences/corrections"
payload = {
"prompt": "<string>",
"expected_mode": "<string>",
"source_message_id": "<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({prompt: '<string>', expected_mode: '<string>', source_message_id: '<string>'})
};
fetch('https://api.example.com/api/v1/routing-preferences/corrections', 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/corrections",
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([
'prompt' => '<string>',
'expected_mode' => '<string>',
'source_message_id' => '<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/corrections"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<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/corrections")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/routing-preferences/corrections")
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 \"prompt\": \"<string>\",\n \"expected_mode\": \"<string>\",\n \"source_message_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body