ഫംഗ്ഷൻ കോളിംഗ്
റിക്വസ്റ്റിൽ നിങ്ങളുടെ ഫംഗ്ഷനുകൾ വിവരിക്കുക, മോഡൽ ചെയ്യണമെന്ന് ആഗ്രഹിക്കുന്ന കോളുകളുമായി മറുപടി നൽകും. നിങ്ങളുടെ കോഡ് അവ പ്രവർത്തിപ്പിച്ച് ഫലങ്ങൾ തിരികെ അയയ്ക്കുന്നു: API ടൂൾ കോളുകൾ തിരികെ നൽകുന്നു, ഒരു ടൂൾ സ്വയം പ്രവർത്തിപ്പിക്കുന്നില്ല.
POST https://api.shannon-ai.com/v1/chat/completions
ഈ പേജിലെ സാമ്പിളുകൾ /v1/chat/completions ഉപയോഗിക്കുന്നു. ഇതേ ലൂപ്പ് /v1/responses, /v1/messages എന്നിവയിലും പ്രവർത്തിക്കുന്നു; ഒരു ഫോർമാറ്റ് എന്തെങ്കിലും വ്യത്യസ്തമായി എഴുതുന്നിടത്ത്, താഴെയുള്ള വിഭാഗങ്ങൾ മൂന്നും കാണിക്കുന്നു.
import json
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.shannon-ai.com/v1")
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "City name, for example Paris"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["city"],
},
},
}]
def get_weather(city, unit="celsius"):
# Your code: ask a weather service here.
return {"city": city, "temperature": 18, "unit": unit, "conditions": "cloudy"}
messages = [{"role": "user", "content": "What is the weather in Paris right now?"}]
answer = None
for _ in range(5): # the API sets no limit on rounds: set your own
response = client.chat.completions.create(
model="Kimi-K3-3BIT-REAP",
messages=messages,
tools=tools,
)
choice = response.choices[0]
if choice.finish_reason != "tool_calls":
answer = choice.message.content
break
messages.append(choice.message) # the assistant turn with its tool_calls
for call in choice.message.tool_calls:
args = json.loads(call.function.arguments) # arguments is a JSON string
result = get_weather(**args)
messages.append({
"role": "tool",
"tool_call_id": call.id,
"content": json.dumps(result),
})
print(answer) import OpenAI from "openai";
const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://api.shannon-ai.com/v1" });
const tools = [{
type: "function",
function: {
name: "get_weather",
description: "Get the current weather for a city.",
parameters: {
type: "object",
properties: {
city: { type: "string", description: "City name, for example Paris" },
unit: { type: "string", enum: ["celsius", "fahrenheit"] },
},
required: ["city"],
},
},
}];
// Your code: ask a weather service here.
function getWeather({ city, unit = "celsius" }) {
return { city, temperature: 18, unit, conditions: "cloudy" };
}
const messages = [{ role: "user", content: "What is the weather in Paris right now?" }];
let answer = null;
// The API sets no limit on rounds: set your own.
for (let round = 0; round < 5; round++) {
const response = await client.chat.completions.create({
model: "Kimi-K3-3BIT-REAP",
messages,
tools,
});
const choice = response.choices[0];
if (choice.finish_reason !== "tool_calls") {
answer = choice.message.content;
break;
}
messages.push(choice.message); // the assistant turn with its tool_calls
for (const call of choice.message.tool_calls) {
const args = JSON.parse(call.function.arguments); // arguments is a JSON string
messages.push({
role: "tool",
tool_call_id: call.id,
content: JSON.stringify(getWeather(args)),
});
}
}
console.log(answer); # 1. Send the conversation with the tools.
curl https://api.shannon-ai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Kimi-K3-3BIT-REAP",
"messages": [
{"role": "user", "content": "What is the weather in Paris right now?"}
],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "City name, for example Paris"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["city"]
}
}
}]
}'
# 2. Run the function yourself, then send the assistant turn and the result.
# Use the id of the call you received.
curl https://api.shannon-ai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Kimi-K3-3BIT-REAP",
"messages": [
{"role": "user", "content": "What is the weather in Paris right now?"},
{"role": "assistant", "content": null, "tool_calls": [{
"id": "call_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"city\":\"Paris\"}"}
}]},
{"role": "tool", "tool_call_id": "call_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"content": "{\"city\":\"Paris\",\"temperature\":18,\"unit\":\"celsius\",\"conditions\":\"cloudy\"}"}
],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "City name, for example Paris"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["city"]
}
}
}]
}' ആദ്യ മറുപടി ചോദ്യത്തിന് ഉത്തരം നൽകുന്നില്ല. അത് ഒരു കോൾ ആവശ്യപ്പെടുന്നു:
{
"id": "chatcmpl-5b0c1d8e7f6a4b3c9d2e1f0a8b7c6d5e",
"object": "chat.completion",
"created": 1791590400,
"model": "Kimi-K3-3BIT-REAP",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"reasoning_content": "The user asks for the current weather in Paris. I should call get_weather.",
"tool_calls": [
{
"id": "call_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\":\"Paris\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 312,
"completion_tokens": 58,
"total_tokens": 370,
"prompt_tokens_details": {"cached_tokens": 0},
"completion_tokens_details": {"reasoning_tokens": 31}
}
} ഫലം അയച്ചതിന് ശേഷം, അടുത്ത മറുപടി സാധാരണ ഉത്തരമാണ്: message.content-ൽ ടെക്സ്റ്റ് ഉണ്ടാകും, finish_reason stop ആയിരിക്കും.
ലൂപ്പ്, ഘട്ടം ഘട്ടമായി
| ഘട്ടം | ആര് | എന്ത് സംഭവിക്കുന്നു |
|---|---|---|
| 1 | നിങ്ങൾ | messages-ഉം, മോഡലിന് ആവശ്യപ്പെടാവുന്ന ഫംഗ്ഷനുകളുടെ ലിസ്റ്റായ tools-ഉം ചേർത്ത് അയയ്ക്കുക. |
| 2 | മോഡൽ | മറുപടിയിൽ tool_calls-ഉം finish_reason: "tool_calls"-ഉം ഉണ്ടാകും. ഓരോ കോളും ഒരു ഫംഗ്ഷന്റെ പേരും അതിന്റെ ആർഗ്യുമെന്റുകളും നൽകുന്നു. |
| 3 | നിങ്ങൾ | ഓരോ കോളിന്റെയും arguments പാഴ്സ് ചെയ്ത് നിങ്ങളുടെ ഫംഗ്ഷൻ പ്രവർത്തിപ്പിക്കുക. |
| 4 | നിങ്ങൾ | അസിസ്റ്റന്റ് മെസേജും ഓരോ കോളിനും ഒരു tool മെസേജും messages-ലേക്ക് ചേർക്കുക, തുടർന്ന് അതേ tools ഉപയോഗിച്ച് റിക്വസ്റ്റ് വീണ്ടും അയയ്ക്കുക. |
| 5 | മോഡൽ | മോഡൽ finish_reason: "stop" ഓടെ ടെക്സ്റ്റിൽ ഉത്തരം നൽകുന്നു, അല്ലെങ്കിൽ കൂടുതൽ കോളുകൾ ആവശ്യപ്പെടുന്നു. അങ്ങനെയെങ്കിൽ ഘട്ടം 3-ലേക്ക് മടങ്ങുക. |
ഒരു റിക്വസ്റ്റ് ഒരു മോഡൽ ടേൺ ആണ്. API റിക്വസ്റ്റുകൾക്കിടയിൽ സംഭാഷണം സൂക്ഷിക്കുന്നില്ല, റൗണ്ടുകളുടെ എണ്ണവും നിശ്ചയിക്കുന്നില്ല: messages സൂക്ഷിക്കുന്നതും എപ്പോൾ നിർത്തണമെന്ന് തീരുമാനിക്കുന്നതും നിങ്ങളുടെ കോഡാണ്.
ടൂളുകൾ നിർവചിക്കൽ
tools ഓരോ ഫംഗ്ഷനും ഒരു എൻട്രി വീതമുള്ള അറേ ആണ്. കാറ്റലോഗിലെ എല്ലാ മോഡലുകളും ഇത് സ്വീകരിക്കുന്നു; GET /v1/models എല്ലാ ഐഡിക്കും capabilities.tools: true റിപ്പോർട്ട് ചെയ്യുന്നു.
| ഫീൽഡ് | ടൈപ്പ് | വിവരണം |
|---|---|---|
type | string | എപ്പോഴും function. |
function.name | string | ഈ ഫംഗ്ഷൻ ആവശ്യപ്പെടുമ്പോൾ മോഡൽ ഉപയോഗിക്കുന്ന പേര്. നിർബന്ധം. |
function.description | string | ഫംഗ്ഷൻ എന്ത് ചെയ്യുന്നു, ലളിതമായ ഭാഷയിൽ. |
function.parameters | object | മുകളിൽ type: "object" ഉള്ള JSON Schema ആയി ആർഗ്യുമെന്റുകൾ. താഴെയുള്ള സ്കീമ കീവേഡുകൾ കാണുക. |
ഓരോ എൻഡ്പോയിന്റിനും ടൂൾ എഴുതാൻ സ്വന്തം രീതിയുണ്ട്. നിങ്ങൾ വിളിക്കുന്ന എൻഡ്പോയിന്റിന്റേത് അയയ്ക്കുക:
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name, for example Paris"
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["city"]
}
}
} {
"type": "function",
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name, for example Paris"
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["city"]
}
} {
"name": "get_weather",
"description": "Get the current weather for a city.",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name, for example Paris"
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["city"]
}
} tool_choice
മോഡലിന് ഒരു ടൂൾ വിളിക്കാമോ, വിളിക്കണോ എന്ന് tool_choice പറയുന്നു. ഇത് tools-നൊപ്പം മാത്രമേ വായിക്കൂ.
| മൂല്യം | വിവരണം | ബാധകമാക്കുന്നത് |
|---|---|---|
"auto" | ടെക്സ്റ്റിൽ ഉത്തരം നൽകണോ ടൂൾ വിളിക്കണോ എന്ന് മോഡൽ തീരുമാനിക്കുന്നു. ഇതാണ് ഡിഫോൾട്ട്. | എല്ലാ മോഡലുകളും |
"required" | മറുപടി കുറഞ്ഞത് ഒരു ടൂൾ വിളിക്കുന്നു. | ഹോസ്റ്റ് ചെയ്ത ഓപ്പൺ-വെയിറ്റ് മോഡലുകൾ |
{"type": "function", "function": {"name": "get_weather"}} | മറുപടി ഈ ഫംഗ്ഷൻ വിളിക്കുന്നു. പേര് tools-ലെ ഫംഗ്ഷനുകളിൽ ഒന്നായിരിക്കണം. മറ്റ് ഫംഗ്ഷനുകളിലേക്കുള്ള കോളുകൾ മറുപടിയിൽ നിന്ന് ഒഴിവാക്കും. | ഹോസ്റ്റ് ചെയ്ത ഓപ്പൺ-വെയിറ്റ് മോഡലുകൾ |
Shannon മോഡലുകൾ (shannon-*) auto-യിലെന്നപോലെ ഓരോ റിക്വസ്റ്റിലും തീരുമാനിക്കുന്നു.
required അല്ലെങ്കിൽ പേരുള്ള ഫംഗ്ഷൻ ഉപയോഗിക്കുമ്പോൾ, tool_calls വായിക്കുന്നതിന് മുമ്പ് finish_reason വായിക്കുക. മോഡൽ കോൾ ഉണ്ടാക്കിയില്ലെങ്കിൽ, മറുപടി finish_reason: "stop" ഉള്ള ടെക്സ്റ്റ് ഉത്തരമായിരിക്കും.
| അർത്ഥം | /v1/chat/completions | /v1/responses | /v1/messages |
|---|---|---|---|
| മോഡൽ തീരുമാനിക്കുന്നു | "auto" | "auto" | {"type": "auto"} |
| കുറഞ്ഞത് ഒരു ടൂൾ വിളിക്കുക | "required" | "required" | {"type": "any"} |
| പേരുള്ള ഒരു ഫംഗ്ഷൻ വിളിക്കുക | {"type": "function", "function": {"name": "get_weather"}} | {"type": "function", "name": "get_weather"} | {"type": "tool", "name": "get_weather"} |
അനുയോജ്യതയ്ക്കായി സ്വീകരിക്കുന്നു: tool_choice: "none", parallel_tool_calls. ടൂൾ കോളുകളില്ലാത്ത ടേണിന്, tools ഇല്ലാതെ റിക്വസ്റ്റ് അയയ്ക്കുക.
മറുപടിയിലെ ടൂൾ കോളുകൾ
| ഫീൽഡ് | ടൈപ്പ് | വിവരണം |
|---|---|---|
finish_reason | string | മറുപടിയിൽ കുറഞ്ഞത് ഒരു കോൾ ഉള്ളപ്പോൾ tool_calls. |
message.tool_calls | array | ഓരോ കോളിനും ഒരു എൻട്രി. മോഡൽ കോൾ ആവശ്യപ്പെട്ടപ്പോൾ മാത്രമേ ഈ ഫീൽഡ് ഉണ്ടാകൂ. |
tool_calls[].id | string | call_ എന്നതിന് ശേഷം 32 ഹെക്സാഡെസിമൽ അക്ഷരങ്ങൾ. ഫലത്തോടൊപ്പം ഇത് tool_call_id ആയി തിരികെ അയയ്ക്കുക. |
tool_calls[].type | string | എപ്പോഴും function. |
tool_calls[].function.name | string | പ്രവർത്തിപ്പിക്കേണ്ട ഫംഗ്ഷൻ. |
tool_calls[].function.arguments | string | ആർഗ്യുമെന്റുകൾ ഒരു JSON സ്ട്രിംഗ് ആയി, ഒന്നുമില്ലെങ്കിൽ "{}". ഉപയോഗിക്കുന്നതിന് മുമ്പ് ഇത് പാഴ്സ് ചെയ്യുക. |
message.content | string | null | മറുപടിയിൽ കോളുകൾ മാത്രമുള്ളപ്പോൾ null. ഹോസ്റ്റ് ചെയ്ത ഓപ്പൺ-വെയിറ്റ് മോഡലുകൾക്ക് കോളുകൾക്കൊപ്പം ടെക്സ്റ്റും തിരികെ നൽകാം; Shannon മോഡലുകൾ null നൽകുന്നു. |
ഓരോ ഫോർമാറ്റിലും ഒരേ കോൾ. /v1/responses-ൽ ഇത് output-ലെ ഒരു function_call ഇനമാണ്, arguments JSON സ്ട്രിംഗ് ആയി. /v1/messages-ൽ ഇത് input JSON ഒബ്ജക്റ്റ് ആയ ഒരു tool_use കണ്ടന്റ് ബ്ലോക്ക് ആണ്, അതിന്റെ id toolu_ എന്ന് തുടങ്ങുന്നു, stop_reason tool_use ആണ്.
{
"finish_reason": "tool_calls",
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\":\"Paris\"}"
}
}
]
}
} {
"output": [
{
"id": "fc_3d2c1b0a9f8e4d7c6b5a4f3e2d1c0b9a",
"type": "function_call",
"call_id": "call_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"name": "get_weather",
"arguments": "{\"city\":\"Paris\"}",
"status": "completed"
}
]
} {
"stop_reason": "tool_use",
"content": [
{
"type": "tool_use",
"id": "toolu_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"name": "get_weather",
"input": {"city": "Paris"}
}
]
} ഒരു ടേണിൽ ഒന്നിലധികം കോളുകൾ
ഒരു മറുപടിയിൽ ഒന്നിലധികം കോളുകൾ ഉണ്ടാകാം. അവയെല്ലാം പ്രവർത്തിപ്പിച്ച്, അടുത്ത റിക്വസ്റ്റിൽ ഓരോ കോളിനും, അതിന്റെ സ്വന്തം tool_call_id സഹിതം, ഒരു ഫലം വീതം അയയ്ക്കുക.
ഹോസ്റ്റ് ചെയ്ത ഓപ്പൺ-വെയിറ്റ് മോഡലുകൾ ഓരോ വ്യത്യസ്ത കോളും ഒരിക്കൽ മാത്രം തിരികെ നൽകുന്നു: ഒരേ പേരും ഒരേ ആർഗ്യുമെന്റുകളുമുള്ള രണ്ട് കോളുകൾ ഒന്നായി എത്തും.
സ്ട്രീം ചെയ്ത ടൂൾ കോളുകൾ
stream: true ആയാൽ, കോൾ ഒറ്റ കഷണമായി എത്തുന്നു: ചങ്കിൽ പൂർണ്ണമായ arguments സ്ട്രിംഗ് ഉണ്ട്, അതിനാൽ കൂട്ടിച്ചേർക്കാൻ ശകലങ്ങളില്ല. index ടേണിലെ കോളുകളെ 0 മുതൽ എണ്ണുന്നു.
{
"id": "chatcmpl-5b0c1d8e7f6a4b3c9d2e1f0a8b7c6d5e",
"object": "chat.completion.chunk",
"created": 1791590400,
"model": "Kimi-K3-3BIT-REAP",
"choices": [
{
"index": 0,
"delta": {
"tool_calls": [
{
"index": 0,
"id": "call_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\":\"Paris\"}"
}
}
]
},
"finish_reason": null
}
]
} | എൻഡ്പോയിന്റ് | വരുന്നത് |
|---|---|
/v1/chat/completions | ഓരോ കോളിനും ഒരു chat.completion.chunk, കോൾ delta.tool_calls[0]-ൽ. അവസാന ചങ്കിൽ finish_reason: "tool_calls"-ഉം usage-ഉം ഉണ്ട്. |
/v1/responses | ഓരോ കോളിനും: response.output_item.added (ശൂന്യമായ arguments ഉള്ള function_call ഇനം), response.function_call_arguments.delta (മുഴുവൻ സ്ട്രിംഗ്), response.function_call_arguments.done, response.output_item.done. |
/v1/messages | ഓരോ കോളിനും: content_block_start (ശൂന്യമായ input ഉള്ള tool_use ബ്ലോക്ക്), ഒരു content_block_delta (അതിന്റെ input_json_delta.partial_json ആർഗ്യുമെന്റ് ടെക്സ്റ്റ് മുഴുവനാണ്), content_block_stop. തുടർന്ന് message_delta stop_reason: "tool_use" വഹിക്കുന്നു. |
shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro, shannon-coder-1 എന്നിവയിൽ, tools ഉള്ള സ്ട്രീം ചെയ്ത റിക്വസ്റ്റ് അതിന്റെ ഉത്തര ടെക്സ്റ്റ് ടേണിന്റെ അവസാനം ഒരൊറ്റ content ഡെൽറ്റയിൽ നൽകുന്നു. സ്റ്റ്രീമിംഗ്
ഫലങ്ങൾ തിരികെ അയയ്ക്കൽ
രണ്ടാമത്തെ റിക്വസ്റ്റ് സംഭാഷണം ആവർത്തിക്കുകയും രണ്ട് കാര്യങ്ങൾ ചേർക്കുകയും ചെയ്യുന്നു: കോളുകൾ ആവശ്യപ്പെട്ട അസിസ്റ്റന്റ് ടേൺ, ഓരോ കോളിനും ഒരു ഫലം.
{
"messages": [
{"role": "user", "content": "What is the weather in Paris right now?"},
{
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\":\"Paris\"}"
}
}
]
},
{
"role": "tool",
"tool_call_id": "call_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"content": "{\"city\":\"Paris\",\"temperature\":18,\"unit\":\"celsius\",\"conditions\":\"cloudy\"}"
}
]
} {
"input": [
{"role": "user", "content": "What is the weather in Paris right now?"},
{
"type": "function_call",
"call_id": "call_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"name": "get_weather",
"arguments": "{\"city\":\"Paris\"}"
},
{
"type": "function_call_output",
"call_id": "call_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"output": "{\"city\":\"Paris\",\"temperature\":18,\"unit\":\"celsius\",\"conditions\":\"cloudy\"}"
}
]
} {
"messages": [
{"role": "user", "content": "What is the weather in Paris right now?"},
{
"role": "assistant",
"content": [
{
"type": "tool_use",
"id": "toolu_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"name": "get_weather",
"input": {"city": "Paris"}
}
]
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_9f1c2ab34d5e4f60a7b8c9d0e1f2a3b4",
"content": "{\"city\":\"Paris\",\"temperature\":18,\"unit\":\"celsius\",\"conditions\":\"cloudy\"}"
}
]
}
]
} - ഫലങ്ങൾക്ക് മുമ്പ്, അസിസ്റ്റന്റ് ടേൺ നിങ്ങൾക്ക് ലഭിച്ചതുപോലെ തന്നെ തിരികെ അയയ്ക്കുക. ഓരോ ഫലവും ഐഡി വഴി അതിന്റെ കോളുമായി ചേർക്കുന്നു:
/v1/chat/completions-ൽtool_call_id,/v1/responses-ൽcall_id,/v1/messages-ൽtool_use_id. - ഫലം ടെക്സ്റ്റാണ്. ഒരു ഒബ്ജക്റ്റിനെ
content-ലേക്ക് (/v1/responses-ൽoutput) JSON സ്ട്രിംഗ് ആയി സീരിയലൈസ് ചെയ്യുക./v1/messages-ൽtool_resultബ്ലോക്കിന്റെcontentഒരു സ്ട്രിംഗോ ടെക്സ്റ്റ് ബ്ലോക്കുകളുടെ ലിസ്റ്റോ ആണ്. - അസിസ്റ്റന്റ് ടേണിൽ,
function.argumentsഎത്തിയതുപോലെ തന്നെ ഒരു JSON സ്ട്രിംഗ് ആയി തുടരും. - സംഭാഷണം ഒരു ടൂൾ ഫലത്തോടെ അവസാനിക്കാം. പുതിയ യൂസർ മെസേജ് ആവശ്യമില്ല: മോഡൽ ഫലത്തിൽ നിന്ന് തുടരും.
- നിങ്ങളുടെ ഫംഗ്ഷൻ പരാജയപ്പെടുമ്പോൾ, പരാജയം ഫല ടെക്സ്റ്റായി അയയ്ക്കുക. അപ്പോൾ മോഡലിന് അത് റിപ്പോർട്ട് ചെയ്യാനോ മറ്റൊരു കോൾ ആവശ്യപ്പെടാനോ കഴിയും.
സ്കീമ കീവേഡുകൾ
parameters (/v1/messages-ൽ input_schema) ഒരു JSON Schema ആണ്. Shannon 3 കുടുംബത്തിനും (shannon-3, shannon-3-pro, shannon-3.1, shannon-3.1-pro) ഹോസ്റ്റ് ചെയ്ത ഓപ്പൺ-വെയിറ്റ് മോഡലുകൾക്കും നിങ്ങൾ അയയ്ക്കുന്നതുപോലെ തന്നെ ഇത് ലഭിക്കും.
shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro, shannon-coder-1 എന്നിവയ്ക്ക് മൂന്ന് എൻഡ്പോയിന്റുകളിലും ഈ ഉപസഞ്ചയം ലഭിക്കും:
| കൈകാര്യം ചെയ്യുന്ന രീതി | കീവേഡുകൾ |
|---|---|
| അയച്ചതുപോലെ വായിക്കും | താഴെയുള്ള വരികളിൽ പേരുപറയാത്ത എല്ലാ കീവേഡുകളും, ഉദാഹരണത്തിന് type, properties, required, items, enum, description, minimum, maximum, anyOf, allOf, സ്കീമയുടെ എല്ലാ തലങ്ങളിലും. |
format | int32, int64, float, double, byte, date, date-time, enum എന്നീ മൂല്യങ്ങൾക്ക് വായിക്കും. |
oneOf | anyOf ആയി വായിക്കും. |
| ഈ മോഡലുകൾക്ക് ലഭിക്കുന്ന സ്കീമയുടെ ഭാഗമല്ല | $schema, $id, $ref, $defs, $comment, definitions, additionalProperties, unevaluatedProperties, patternProperties, propertyNames, examples, default, title, const, not, if, then, else, contains, minContains, maxContains, dependentRequired, dependentSchemas, dependencies, readOnly, writeOnly, deprecated, contentEncoding, contentMediaType, contentSchema, multipleOf, uniqueItems; സംഖ്യകളായിരിക്കുമ്പോൾ exclusiveMinimum, exclusiveMaximum; format-ന്റെ മറ്റ് മൂല്യങ്ങൾ. |
പെരുമാറ്റവും പരിധികളും
- API ടൂളുകളുടെ പരമാവധി എണ്ണമോ റൗണ്ടുകളുടെ പരമാവധി എണ്ണമോ നിശ്ചയിക്കുന്നില്ല.
- റിക്വസ്റ്റ് ബോഡി 32 MiB വരെ ആകാം, ഫലങ്ങളോടു കൂടിയ സംഭാഷണം മോഡലിന്റെ കോൺടെക്സ്റ്റ് വിൻഡോയിൽ ഒതുങ്ങണം.
- റിക്വസ്റ്റിൽ
toolsഉള്ളപ്പോൾ,shannon-1.6-lite,shannon-1.6-pro,shannon-2-lite,shannon-2-proഎന്നിവ ഡിഫോൾട്ട്temperatureആയി 0.2 ഉപയോഗിക്കുന്നു. മറ്റൊരു മൂല്യം സജ്ജമാക്കാൻtemperatureഅയയ്ക്കുക. - ഓരോ റൗണ്ടും സ്വന്തമായ ഒരു റിക്വസ്റ്റ് ആണ്: അത് നിങ്ങളുടെ ബാലൻസിൽ നിന്ന് എടുക്കുകയും മറ്റേതൊരു റിക്വസ്റ്റിനെയും പോലെ ഫ്ലഡ് പ്രൊട്ടക്ഷനിൽ കണക്കാക്കുകയും ചെയ്യുന്നു. പരിധികളും ബാലൻസും
പിശകുകൾ
ടൂൾ കോൾ സ്റ്റാറ്റസ് 200 ഉള്ള സാധാരണ മറുപടിയാണ്. ഈ പിശകുകൾ റിക്വസ്റ്റിനെ തന്നെ സംബന്ധിച്ചതാണ്:
| സ്റ്റാറ്റസ് | ടൈപ്പ് | മെസേജ് | എപ്പോൾ |
|---|---|---|---|
400 | invalid_request_error | unknown model: <id> | model പ്രസിദ്ധീകരിച്ച ലിസ്റ്റിലെ ഐഡി അല്ല. |
422 | invalid_request_error | Failed to deserialize the JSON body into the target type: … | tools ഒരു അറേ അല്ല, അല്ലെങ്കിൽ മറ്റൊരു ഫീൽഡിന് തെറ്റായ JSON ടൈപ്പ് ആണ്. |
413 | invalid_request_error | Failed to buffer the request body: … | റിക്വസ്റ്റ് ബോഡി 32 MiB-യേക്കാൾ വലുതാണ്. പിശകിൽ code: "request_too_large" ഉണ്ടാകും. |
ആർഗ്യുമെന്റുകൾ എഴുതുന്നത് മോഡലാണ്. പുറത്തുനിന്നുള്ള ഏതൊരു ഇൻപുട്ടും പരിശോധിക്കുന്നതുപോലെ, ഫംഗ്ഷൻ പ്രവർത്തിപ്പിക്കുന്നതിന് മുമ്പ് നിങ്ങളുടെ സ്കീമയുമായി അവ പരിശോധിക്കുക.
ഓതന്റിക്കേഷൻ, ബാലൻസ്, സെർവർ പിശകുകൾ എല്ലാ റിക്വസ്റ്റുകൾക്കും ഉള്ളതുപോലെ തന്നെയാണ്. എറർ ഹാൻഡ്ലിംഗ്