前言
在這篇文章中,我將分享如何利用ChatGPT 4.0輔助論文寫作的技巧,并根據(jù)網(wǎng)上的資料和最新的研究補(bǔ)充更多好用的咒語技巧。
GPT4的官方售價是每月20美元,很多人并不是天天用GPT,只是偶爾用一下。
如果調(diào)用官方的GPT4接口,就可以按使用量付費(fèi),用多少付多少,而且沒有3個小時內(nèi)只能提問50條的使用限制。
但是對很多人來說調(diào)用接口是比較麻煩的。如果開發(fā)一個網(wǎng)站,后臺調(diào)用GPT4的接口,大家一起用,
分?jǐn)傄幌路?wù)器的成本,就比較劃算了。見文末【參考鏈接】
{
"openapi": "3.1.0",
"info": {
"title": "獲取城市的天氣數(shù)據(jù)",
"description": "獲取指定地區(qū)的當(dāng)前天氣情況",
"version": "v1.0.0"
},
"servers": [
{
"url": "https://chat.xutongbao.top"
}
],
"paths": {
"/api/light/chat/getWeather": {
"get": {
"description": "獲取指定地區(qū)的當(dāng)前天氣情況",
"operationId": "GetCurrentWeather",
"parameters": [
{
"name": "city",
"in": "query",
"description": "城市,例如:深圳,城市的值必須是中文",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "extensions",
"in": "query",
"description": "extensions可選值:base/all base:返回實況天氣 all:返回預(yù)報天氣",
"required": true,
"enum": ['base', 'all'],
"schema": {
"type": "string"
}
}
],
"deprecated": false
}
}
},
"components": {
"schemas": {}
}
}
nodejs后臺代碼:
let baseApiKeyOnServer = 'Basic xxx'
const chatGetWeather = async (req, res) => {
let { city = '北京', extensions = 'all' } = req.query
let headers = req.headers
let authorization = req.headers?.authorization
console.log('天氣', city, headers, req.query)
if (authorization === baseApiKeyOnServer) {
let resultCity = cityList.find((item) => item.name.includes(city))
let cityCode = '110000'
if (resultCity && resultCity.adcode) {
cityCode = resultCity.adcode
}
console.log('高德天氣查詢', city, cityCode, extensions)
// extensions可選值:base/all base:返回實況天氣 all:返回預(yù)報天氣
let result = await axios.get(
`https://restapi.amap.com/v3/weather/weatherInfo?key=${weatherApiKey}&city=${cityCode}&extensions=${extensions}`
)
const searchResult = result.data
let functionResponse
if (searchResult && Array.isArray(searchResult.lives)) {
functionResponse = `${JSON.stringify(searchResult.lives)}`
} else if (searchResult && Array.isArray(searchResult.forecasts)) {
functionResponse = `${JSON.stringify(searchResult.forecasts)}`
} else {
functionResponse = `${JSON.stringify(searchResult)}`
}
res.send({
code: 200,
data: {
city,
headers,
result: functionResponse,
},
message: '成功',
})
} else {
res.send({
code: 400,
message: '失敗:參數(shù)headers.authorization',
})
}
}
測試:
?
參考鏈接:文章來源:http://www.zghlxwxcb.cn/news/detail-809886.html
https://chat.xutongbao.top文章來源地址http://www.zghlxwxcb.cn/news/detail-809886.html
到了這里,關(guān)于給自己創(chuàng)建的GPTs添加Action(查天氣)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!