ຄົ້ນຫາເວັບ
ຕັ້ງ web_search: true ແລ້ວ model ຈະອີງຄຳຕອບຂອງມັນກັບຜົນລັບສົດ.
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
}' ຄຳຕອບແມ່ນ chat completion ທຳມະດາ ບວກກັບສອງສ່ວນເພີ່ມ. ຄຳຕອບຊີ້ໄປຫາຜົນການຄົ້ນຫາດ້ວຍເລກໃນວົງເລັບສີ່ຫຼ່ຽມ, sources ບອກວ່າແຕ່ລະເລກແທນຫຍັງ, ແລະ annotations ໝາຍວ່າແຕ່ລະອັນຖືກອ້າງອີງຢູ່ບ່ອນໃດ:
{
"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"
}
]
} ການເປີດການຄົ້ນຫາ
ການຄົ້ນຫາແມ່ນຟີລດ໌ຂອງຄຳຮ້ອງຂໍ, ປິດເປັນຄ່າເລີ່ມຕົ້ນ. ບໍ່ມີຫຍັງຖືກຄົ້ນຫາເວັ້ນແຕ່ຄຳຮ້ອງຂໍສົ່ງມັນ.
| ຟີລດ໌ | ປະເພດ | ຄ່າເລີ່ມຕົ້ນ | ຄຳອະທິບາຍ | ໃຊ້ໂດຍ |
|---|---|---|---|---|
web_search | boolean | false | true ຮັນການຄົ້ນຫາເວັບສຳລັບຄຳຮ້ອງຂໍນີ້ ແລະ ສົ່ງຜົນໃຫ້ model ກ່ອນມັນຕອບ. | ທຸກ model Shannon ຍົກເວັ້ນ shannon-coder-1 |
| Endpoint | ຄົ້ນຫາເວັບ | ວິທີ |
|---|---|---|
/v1/chat/completions | ແມ່ນ | "web_search": true ໃນ body ຂອງຄຳຮ້ອງຂໍ. |
/v1/messages | ແມ່ນ | "web_search": true ໃນ body ຂອງຄຳຮ້ອງຂໍ. |
/v1/responses | — | endpoint ນີ້ຕອບຈາກ model ເທົ່ານັ້ນ. ໃຊ້ໜຶ່ງໃນສອງອັນຂ້າງເທິງເພື່ອຄຳຕອບທີ່ຄົ້ນຫາ. |
ໃນ /v1/messages ຟີລດ໌ຢູ່ລະດັບເທິງສຸດຂອງ body, ຂ້າງ model ແລະ messages:
{
"model": "shannon-3",
"web_search": true,
"messages": [
{
"role": "user",
"content": "What is the weather forecast for Lisbon this weekend?"
}
]
} ສິ່ງທີ່ຄຳຮ້ອງຂໍທີ່ຄົ້ນຫາເຮັດ
- API ຄົ້ນຫາເວັບສຳລັບຂໍ້ຄວາມ user ສຸດທ້າຍ. ຮອບກ່ອນໜ້າຂອງການສົນທະນາໃຫ້ບໍລິບົດແກ່ການຄົ້ນຫາ.
- ການຄົ້ນຫາຮັນໃນທຸກຄຳຮ້ອງຂໍທີ່ສົ່ງ
web_search: true. model ບໍ່ໄດ້ເລືອກວ່າຈະຄົ້ນຫາຫຼືບໍ່. - ຜົນລັບຖືກວາງຕໍ່ໜ້າ model ເປັນແຫຼ່ງທີ່ມີເລກລຳດັບ, ແລະ model ຂຽນຄຳຕອບຈາກພວກມັນ.
- ຄຳຕອບເລີ່ມເມື່ອການຄົ້ນຫາສຳເລັດ. ຄຳຮ້ອງຂໍແບບ stream ບໍ່ສົ່ງຫຍັງ, ທັງ header ແລະ event, ຈົນຮອດຕອນນັ້ນ, ດັ່ງນັ້ນໃຫ້ເຜື່ອເວລາລໍຖ້າທີ່ຍາວຂຶ້ນກ່ອນ chunk ທຳອິດ.
ສິ່ງທີ່ຄຳຕອບມີ
- ຄຳຕອບມີຮູບຮ່າງປົກກະຕິຂອງ endpoint ຂອງມັນ. ຄຳຕອບຢູ່ໃນ
choices[0].message.content(blocktextໃນ/v1/messages). - ຂໍ້ຄວາມອາດມີເຄື່ອງໝາຍເຊັ່ນ
[1]ແລະ[2]ຫຼັງປະໂຫຍກທີ່ມັນສະໜັບສະໜູນ. ແຕ່ລະເລກແທນໜຶ່ງໃນຜົນລັບທີ່ model ອ່ານ. sourcesບອກຊື່ຜົນລັບເຫຼົ່ານັ້ນ: ໜຶ່ງລາຍການຕໍ່ທຸກຜົນລັບທີ່ model ໄດ້ຮັບ, ມີindex,titleແລະurl. ເຄື່ອງໝາຍ[1]ແມ່ນລາຍການທີ່ມີindexເປັນ 1. ຜົນລັບທີ່ຄຳຕອບບໍ່ໄດ້ອ້າງອີງກໍມີຢູ່ໃນລາຍການນຳ.- ໃນ
/v1/chat/completionsຂໍ້ຄວາມຍັງມີannotationsນຳ, ໃນຮູບແບບ OpenAI: ໜຶ່ງurl_citationຕໍ່ທຸກແຫຼ່ງທີ່ເຄື່ອງໝາຍຊີ້ເຖິງ, ມີurl,title, ແລະstart_indexກັບend_index, ຄືຕຳແໜ່ງຂອງເຄື່ອງໝາຍໃນcontentນັບເປັນຕົວອັກສອນ (ບໍ່ລວມຈຸດສິ້ນສຸດ). - ໃນ stream,
sourcesມາພ້ອມກັບ chunk ສຸດທ້າຍ, ແລະໃນ/v1/messagesມາພ້ອມກັບ eventmessage_delta. annotations ມາໃນ chunk ດຽວກ່ອນອັນສຸດທ້າຍ, ເປັນdelta.annotations. sourcesມີສະເພາະເມື່ອການຄົ້ນຫາຂອງຄຳຮ້ອງຂໍນີ້ພົບບາງຢ່າງ. ຄຳຕອບທີ່ບໍ່ມີມັນຖືກຂຽນໂດຍບໍ່ມີຜົນການຄົ້ນຫາ.
ການຄົ້ນຫາຖືກນັບແນວໃດ
ທຸກແຜນມີຈຳນວນການຄົ້ນຫາຕໍ່ວັນ:
| ແຜນ | ການຄົ້ນຫາຕໍ່ວັນ |
|---|---|
| ຟຣີ | 3 |
| ບວກ | 30 |
| Standard | 50 |
| ໂປຣ | 60 |
- ຄຳຮ້ອງຂໍທີ່ການຄົ້ນຫາພົບບາງຢ່າງໃຊ້ການຄົ້ນຫາໜຶ່ງຄັ້ງຂອງໂຄວຕາປະຈຳວັນ. ການຄົ້ນຫາທີ່ບໍ່ພົບຫຍັງບໍ່ໃຊ້ຄັ້ງໃດ.
- Chat ແລະ API ໃຊ້ໂຄວຕາຮ່ວມກັນຂອງບັນຊີທີ່ເປັນເຈົ້າຂອງ key.
- ການນັບເລີ່ມໃໝ່ທຸກວັນເວລາ 00:00 UTC.
- ຜົນການຄົ້ນຫາແມ່ນ input tokens ຂອງຄຳຮ້ອງຂໍ ແລະ ຖືກຄິດເງິນພ້ອມກັບສ່ວນທີ່ເຫຼືອຂອງ prompt.
ເມື່ອການຄົ້ນຫາຂອງມື້ຖືກໃຊ້ໝົດ
ຄຳຮ້ອງຂໍທີ່ສົ່ງ web_search: true ຫຼັງການຄົ້ນຫາຄັ້ງສຸດທ້າຍຂອງມື້ບໍ່ຖືກປະຕິເສດ. ມັນຖືກຕອບໂດຍບໍ່ມີການຄົ້ນຫາ: status ເປັນ 200 ແລະ ຄຳຕອບບໍ່ມີ sources.
ການຄົ້ນຫາເປັນ tool ຂອງທ່ານເອງ
web_search: true ແມ່ນສະວິດດຽວຂອງການຄົ້ນຫາທີ່ອະທິບາຍຢູ່ນີ້. function ທີ່ທ່ານກຳນົດໃນ tools ແລະ ຕັ້ງຊື່ web_search ແມ່ນໜຶ່ງໃນ tool ຂອງທ່ານເອງ: model ສົ່ງການເອີ້ນກັບຄືນ, ແລະ ໂຄ້ດຂອງທ່ານຮັນການຄົ້ນຫາ ແລະ ສົ່ງຜົນກັບຄືນ.
ປະເພດ tool ຄົ້ນຫາຂອງແພລດຟອມອື່ນ, ເຊັ່ນ web_search_20250305 ໃນ /v1/messages ຫຼື {"type": "web_search"} ໃນ /v1/responses, ບໍ່ເລີ່ມການຄົ້ນຫາຢູ່ນີ້.
ຂໍ້ຜິດພາດ
ການຄົ້ນຫາເວັບບໍ່ເພີ່ມ status code ແລະ ບໍ່ເພີ່ມປະເພດຂໍ້ຜິດພາດ. ການຄົ້ນຫາທີ່ບໍ່ພົບຫຍັງ, ຫຼື ມື້ທີ່ບໍ່ເຫຼືອການຄົ້ນຫາ, ໃຫ້ຄຳຕອບປົກກະຕິທີ່ບໍ່ມີຜົນການຄົ້ນຫາ. ຂໍ້ຜິດພາດອື່ນທັງໝົດຄືກັນກັບຄຳຮ້ອງຂໍທີ່ບໍ່ມີການຄົ້ນຫາ. ການຈັດການຂໍ້ຜິດພາດ