Rapu paetukutuku
Tautuhia te web_search: true, ā, ka whakapūmau te model i tana whakautu ki ngā hua ora.
POST https://api.shannon-ai.com/v1/chat/completions
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.shannon-ai.com/v1")
response = client.chat.completions.create(
model="shannon-3",
messages=[{"role": "user", "content": "What is the weather forecast for Lisbon this weekend?"}],
extra_body={"web_search": True}, # a Shannon field, so it goes in extra_body
)
print(response.choices[0].message.content) import OpenAI from "openai";
const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://api.shannon-ai.com/v1" });
const response = await client.chat.completions.create({
model: "shannon-3",
messages: [{ role: "user", content: "What is the weather forecast for Lisbon this weekend?" }],
web_search: true,
});
console.log(response.choices[0].message.content); curl https://api.shannon-ai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "shannon-3",
"messages": [
{"role": "user", "content": "What is the weather forecast for Lisbon this weekend?"}
],
"web_search": true
}' He chat completion noa te whakautu me ētahi tāpiritanga e rua. Ka tohu te whakautu ki ngā hua rapu mā ngā tau i ngā taiapa tapawhā, ka kī te sources he aha te tikanga o ia tau, ā, ka tohu te annotations i hea tonu e whakahuatia ana ia tētahi:
{
"id": "chatcmpl-3e5a7c9b1d2f4a6c8e0b2d4f6a8c1e3b",
"object": "chat.completion",
"created": 1791590400,
"model": "shannon-3",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Saturday in Lisbon is forecast to be sunny with a high near 24 °C [1]. Sunday turns cloudy, with a chance of light rain in the afternoon [2].",
"reasoning_content": null,
"annotations": [
{
"type": "url_citation",
"url_citation": {
"start_index": 66,
"end_index": 69,
"url": "https://weather.example/lisbon/weekend",
"title": "Lisbon weather: weekend outlook"
}
},
{
"type": "url_citation",
"url_citation": {
"start_index": 137,
"end_index": 140,
"url": "https://forecast.example/pt/lisbon/sunday",
"title": "Sunday forecast for Lisbon"
}
}
]
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 2874,
"completion_tokens": 41,
"total_tokens": 2915
},
"sources": [
{
"index": 1,
"title": "Lisbon weather: weekend outlook",
"url": "https://weather.example/lisbon/weekend"
},
{
"index": 2,
"title": "Sunday forecast for Lisbon",
"url": "https://forecast.example/pt/lisbon/sunday"
},
{
"index": 3,
"title": "Portugal: the week ahead",
"url": "https://news.example/portugal/weather-week"
}
]
} Te whakakā i te rapu
He āpure o te tono te rapu, kua whakakorea i te taunoa. Kāore he mea e rapua mēnā kāore tētahi tono e tuku.
| Āpure | Momo | Taunoa | Whakaahuatanga | Whakamahia e |
|---|---|---|---|---|
web_search | boolean | false | Ka whakahaere te true i tētahi rapu tukutuku mō tēnei tono, ā, ka hoatu ngā hua ki te model i mua i tana whakautu. | Ia model Shannon haunga te shannon-coder-1 |
| Endpoint | Rapu tukutuku | Te tikanga |
|---|---|---|
/v1/chat/completions | Āe | "web_search": true i te tinana tono. |
/v1/messages | Āe | "web_search": true i te tinana tono. |
/v1/responses | — | Ka whakautu tēnei endpoint mai i te model anake. Whakamahia tētahi o ngā mea e rua i runga ake mō tētahi whakautu kua rapua. |
I runga i te /v1/messages kei te taumata o runga o te tinana te āpure, i te taha o te model me te messages:
{
"model": "shannon-3",
"web_search": true,
"messages": [
{
"role": "user",
"content": "What is the weather forecast for Lisbon this weekend?"
}
]
} Te mahi a tētahi tono kua rapua
- Ka rapu te API i te tukutuku mō te karere kaiwhakamahi whakamutunga. Ka hoatu e ngā hurihanga o mua o te kōrero te horopaki ki te rapu.
- Ka rere te rapu i ia tono e tuku ana i te
web_search: true. Kāore te model e kōwhiri mēnā ka rapu. - Ka whakanōhia ngā hua ki mua i te model hei pūtake kua tau, ā, ka tuhi te model i tana whakautu mai i a rātou.
- Ka tīmata te whakautu ina oti te rapu. Kāore tētahi tono stream e tuku i tētahi mea, ahakoa ngā header, ngā kaupapa rānei, tae noa ki reira, nō reira whakaarohia he tatari roa ake i mua i te chunk tuatahi.
Te mea kei te whakautu
- Kei te whakautu te āhua noa o tōna endpoint. Kei te
choices[0].message.contentte whakautu (he porakatexti te/v1/messages). - Ka taea e te kuputuhi te kawe i ngā tohu pēnei i te
[1]me te[2]i muri i ngā kī e tautokohia ana e rātou. Ko ia tau he tohu mō tētahi o ngā hua i pānuitia e te model. - Ka ingoatia e te
sourcesērā hua: kotahi te tāurunga mō ia hua i hoatu ki te model, me teindex, tetitleme teurl. Ko te tohu[1]te tāurunga whaiindex1. Kei te rārangi anō ngā hua kāore te whakautu i whakahua. - I runga i te
/v1/chat/completionskei te karere hoki teannotations, i te āhua OpenAI: kotahi teurl_citationmō ia pūtake e ingoatia ana e tētahi tohu, me teurl, tetitle, me testart_indexme teend_index, te tūnga o te tohu i tecontente tātaihia ana ki ngā tohu tuhi (kāore te mutunga e whakaurua). - I roto i te stream ka tae mai te
sourcesme te chunk whakamutunga, ā, i runga i te/v1/messagesme te takunetangamessage_delta. Ka tae mai ngā annotations i tētahi chunk i mua tonu i te whakamutunga, heidelta.annotations. - Kei reira te
sourcesina kitea he mea e te rapu o tēnei tono anake. I tuhia te whakautu kāore i a ia he hua rapu.
Te āhua o te tatau rapu
Kei ia mahere tētahi maha o ngā rapu ia rā:
| Mahere | Ngā rapu ia rā |
|---|---|
| Kore Utu | 3 |
| Tāpiri | 30 |
| Standard | 50 |
| Ngaio | 60 |
- Ka whakamahi tētahi tono i kitea tētahi mea e tana rapu i tētahi rapu o te whakaaetanga o te rā. Kāore te rapu kāore i kitea tētahi mea e whakamahi i tētahi.
- Ka tiritiri te Chat me te API i te whakaaetanga o te pūkete nōna te key.
- Ka tīmata anō te tatau ia rā i te 00:00 UTC.
- He token input o te tono ngā hua rapu, ā, ka whakaritea tahi me te toenga o te prompt.
Ina pau ngā rapu o te rā
Kāore e whakakāhoretia tētahi tono e tuku ana i te web_search: true i muri i te rapu whakamutunga o te rā. Ka whakautua me te kore rapu: ko 200 te tūnga, ā, kāore he sources o te whakautu.
Te rapu hei tool nāu ake
Ko te web_search: true anake te pana mō te rapu kua whakaahuatia i konei. Ko tētahi function ka tautuhia e koe i te tools ka whakaingoatia web_search he tool nāu: ka whakahoki te model i tētahi karanga, ā, ka whakahaere tō waehere i te rapu ka tuku whakamuri i te hua.
Kāore ngā momo tool rapu o ētahi atu pūhera, pēnei i te web_search_20250305 i te /v1/messages i te {"type": "web_search"} rānei i te /v1/responses, e tīmata i tētahi rapu i konei.
Ngā hapa
Kāore te rapu tukutuku e tāpiri i tētahi waehere tūnga, i tētahi momo hapa rānei. Ka hoatu he whakautu noa me te kore hua rapu mō tētahi rapu kāore e kitea tētahi mea, mō tētahi rā kāore he rapu e toe ana rānei. He ōrite ia hapa kē atu ki tērā mō tētahi tono kāore he rapu. Whakahaere hapa