400-638-8808
|
微信公眾號




穩(wěn)定可靠 永不間斷

海外收發(fā) 暢通無阻

協(xié)同辦公 資源管理

超大郵件 超級功能

智能反垃圾郵件技術
易管理 免維護

OpenAI官方在2023.06.13發(fā)布了API層面的重磅升級,主要變化如下:
gpt-4和gpt-3.5-turbo模型。gpt-3.5-turbo支持的上下文長度擴容到16K,之前只支持4K個token。gpt-3.5-turbo模型的input token的成本降低25%,從原來的0.002美金 / 1K token降低為0.0015美金 / 1K token。gpt-3.5-turbo-0301、gpt-4-0314和gpt-4-32k-0314 模型,過了這個時間點調(diào)用這些模型會請求失敗。上面提到的這些模型都嚴格遵循2023.03.01發(fā)布的隱私和安全規(guī)定,用戶通過API發(fā)送的數(shù)據(jù)和API返回的數(shù)據(jù)不會用于OpenAI大模型的訓練。
場景:我們希望ChatGPT告訴現(xiàn)在Boston的天氣狀況。
如果只靠ChatGPT是無法實現(xiàn)這個功能的,因為ChatGPT的訓練數(shù)據(jù)只截止到2021年9月,無法知道現(xiàn)在的天氣。這也是GPT目前最大的一個問題,不能很好地支持信息的及時更新。
那應該怎么使用ChatGPT來實現(xiàn)這個功能呢?
我們可以自己定義一個函數(shù)來獲取當天某個城市的天氣狀況,ChatGPT只需要根據(jù)用戶的提問生成我們自定義的函數(shù)的參數(shù)值(也叫實參),那我們就可以調(diào)用自定義函數(shù)拿到我們想要的結果,然后把自定義函數(shù)生成的結果和對話記錄作為Prompt送給ChatGPT,由ChatGPT做一個匯總,最后把匯總的結論返回給用戶即可。
用戶提問 -> ChatGPT生成函數(shù)的實參 -> 開發(fā)者調(diào)用自定義函數(shù) -> 把函數(shù)執(zhí)行結果+上下文對話記錄發(fā)送給ChatGPT做匯總 -> 返回匯總結論給用戶
下面我們來看一個具體的實現(xiàn)案例:
What"s the weather like in Boston right now?curl https://api.openai.com/v1/chat/completions -u :$OPENAI_API_KEY -H "Content-Type: application/json" -d "{ "model": "gpt-3.5-turbo-0613", "messages": [ {"role": "user", "content": "What is the weather like in Boston?"} ], "functions": [ { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" }, "unit": { "type": "string", "enum": ["celsius", "fahrenheit"] } }, "required": ["location"] } } ] }"
拿到ChatGPT返回的結果,返回結果里content為null,function_call有值,表示需要調(diào)用自定義函數(shù)get_current_weather,并且返回了自定義函數(shù)的參數(shù)值。
{ "id": "chatcmpl-123", ... "choices": [{ "index": 0, "message": { "role": "assistant", "content": null, "function_call": { "name": "get_current_weather", "arguments": "{ \"location\": \"Boston, MA\"}" } }, "finish_reason": "function_call" }] }
curl https://weatherapi.com/...
拿到自定義函數(shù)返回結果
{ "temperature": 22, "unit": "celsius", "description": "Sunny" }
curl https://api.openai.com/v1/chat/completions -u :$OPENAI_API_KEY -H "Content-Type: application/json" -d "{ "model": "gpt-3.5-turbo-0613", "messages": [ {"role": "user", "content": "What is the weather like in Boston?"}, {"role": "assistant", "content": null, "function_call": {"name": "get_current_weather", "arguments": "{ \"location\": \"Boston, MA\"}"}}, {"role": "function", "name": "get_current_weather", "content": "{\"temperature\": "22", \"unit\": \"celsius\", \"description\": \"Sunny\"}"} ], "functions": [ { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" }, "unit": { "type": "string", "enum": ["celsius", "fahrenheit"] } }, "required": ["location"] } } ] }"
最后ChatGPT返回如下結果:
{ "id": "chatcmpl-123", ... "choices": [{ "index": 0, "message": { "role": "assistant", "content": "The weather in Boston is currently sunny with a temperature of 22 degrees Celsius.", }, "finish_reason": "stop" }] }
我們輸出結果:
The weather in Boston is currently sunny with a temperature of 22 degrees Celsius.
以上功能實現(xiàn)的核心要素是ChatGPT可以智能地根據(jù)用戶的輸入來判斷什么時候應該要調(diào)用開發(fā)者的自定義函數(shù),并且把自定義函數(shù)的參數(shù)值給返回。開發(fā)者就可以直接自己去調(diào)用自定義函數(shù)拿到想要的結果,最后再把對話記錄和自定義函數(shù)執(zhí)行結果發(fā)送給大模型去做匯總。
目前這個功能可以在 gpt-4-0613 和 gpt-3.5-turbo-0613這2個模型里使用。
等OpenAI在2023.06.27完成模型升級后,gpt-4、gpt-4-32k和gpt-3.5-turbo模型也可以使用這個功能。
新API的使用詳情可以參考:developer documentation。
gpt-4-0613 相對于gpt-4,新增了函數(shù)調(diào)用的支持。
gpt-4-32k-0613 相對于gpt-4-32k,同樣是新增了函數(shù)調(diào)用的支持。
在接下來的幾周里,OpenAI會把GPT-4 API waiting list上的申請都盡量審批通過,讓開發(fā)者可以享用到GPT-4的強大能力。還沒申請的趕緊去申請吧。
gpt-3.5-turbo-0613 相對于gpt-3.5-turbo,新增了函數(shù)調(diào)用的支持。
gpt-3.5-turbo-16k 支持的上下文長度擴容到了16K,是gpt-3.5-turbo的4倍,費用是gpt-3.5-turbo的2倍。具體費用是每1K input token需要0.003美金, 每1K output token需要0.004美金。
從2023.06.13開始,OpenAI會開始升級生產(chǎn)環(huán)境的gpt-4、gpt-4-32k和gpt-3.5-turbo模型到最新版本,預計2023.06.27開始就可以使用到升級后的模型了。
如果開發(fā)者不想升級,可以繼續(xù)使用舊版本的模型,不過需要在model參數(shù)里指定用 gpt-3.5-turbo-0301,gpt-4-0314 或 gpt-4-32k-0314 。
這些舊版本的模型在2023.09.13會下線,后續(xù)繼續(xù)調(diào)用會請求失敗。
text-embedding-ada-002目前是OpenAI所有embedding模型里最受歡迎的。
現(xiàn)在使用這個embedding模型的成本降低為0.0001美金/1K token,成本下降75%。
gpt-3.5-turbo 模型在收費的時候,既對用戶發(fā)送的問題(input token)收費,也對API返回的結果(output token)收費。
現(xiàn)在該模型的input token成本降低25%,每1K input token的費用為0.0015美金。
output token的費用保持不變,還是0.002美金/1K token。
gpt-3.5-turbo-16k 模型的input token收費是0.003美金/1K token,output token收費是0.004美金/1K token。
天下數(shù)據(jù)手機站 關于天下數(shù)據(jù) 聯(lián)系我們 誠聘英才 付款方式 幫助中心 網(wǎng)站備案 解決方案 域名注冊 網(wǎng)站地圖
天下數(shù)據(jù)18年專注海外香港服務器、美國服務器、海外云主機、海外vps主機租用托管以及服務器解決方案-做天下最好的IDC服務商
《中華人民共和國增值電信業(yè)務經(jīng)營許可證》 ISP證:粵ICP備07026347號
朗信天下發(fā)展有限公司(控股)深圳市朗玥科技有限公司(運營)聯(lián)合版權
深圳總部:中國.深圳市南山區(qū)深圳國際創(chuàng)新谷6棟B座10層 香港總部:香港上環(huán)蘇杭街49-51號建安商業(yè)大廈7樓
7×24小時服務熱線:4006388808香港服務電話:+852 67031102
本網(wǎng)站的域名注冊業(yè)務代理北京新網(wǎng)數(shù)碼信息技術有限公司的產(chǎn)品