LearnhowtobuildapluginthatallowsChatGPTtointelligentlycallyourAPI.了解如何构建允许ChatGPT智能调用API的插件。
在现代的软件开发环境中,使用第三方插件已成为非常常见的做法。对于ChatGPT这样的大型语言模型而言,OpenAI公司深知在不断满足客户需求、提供更丰富的功能和缩短开发周期之间的平衡是多么重要。OpenAI公司充分支持用户使用OpenAI认证的各种第三方插件,这使得ChatGPT可以充分利用已有的功能来快速推出复杂多变的产品,并大幅提高大型语言模型应用的场景。
然而,OpenAI公司也清楚意识到选择合适的第三方插件以确保系统的可靠性和安全性非常重要。所以OpenAI公司也采取了一系列措施,并对每个想要整合进ChatGPT的第三方插件都进行了细致的评估和审核,只有符合其标准和要求的插件才有可以被集成到ChatGPT语言模型中。
OpenAIpluginsconnectChatGPTtothird-partyapplications.ThesepluginsenableChatGPTtointeractwithAPIsdefinedbydevelopers,enhancingChatGPT’scapabilitiesandallowingittoperformawiderangeofactions.OpenAI插件将ChatGPT连接到第三方应用程序。这些插件使ChatGPT能够与开发人员定义的API进行交互,增强ChatGPT的功能并允许其执行广泛的操作。
PluginscanallowChatGPTtodothingslike:插件可以允许ChatGPT执行以下操作:
Retrievereal-timeinformation;e.g.,sportsscores,stockprices,thelatestnews,etc.检索实时信息;例如,体育比分、股票价格、最新消息等。Retrieveknowledge-baseinformation;e.g.,companydocs,personalnotes,etc.检索知识库信息;例如,公司文档、个人笔记等。Performactionsonbehalfoftheuser;e.g.,bookingaflight,orderingfood,etc.代表用户执行操作;例如,预订航班、订购食物等。
Pluginsareinalimitedalphaandmaynotyetbeaccessibletoyou.Pleasejointhewaitlisttogetaccess.Duringthealpha,wewillbeworkingcloselywithusersanddeveloperstoiterateonthepluginsystem,whichmayevolvesignificantly.插件是在一个限制的alpha版本,可能还没有访问到你。请加入等待列表以获得访问权限。在alpha期间,我们将与用户和开发人员密切合作,迭代插件系统,这可能会发生重大变化。
PlugindevelopersexposeoneormoreAPIendpoints,accompaniedbyastandardizedmanifestfileandanOpenAPIspecification.Thesedefinetheplugin’sfunctionality,allowingChatGPTtoconsumethefilesandmakecallstothedeveloper-definedAPIs.插件开发人员公开一个或多个API端点,并附带一个标准化的清单文件和OpenAPI规范。这些定义了插件的功能,允许ChatGPT使用文件并调用开发人员定义的API。
TheAImodelactsasanintelligentAPIcaller.GivenanAPIspecandanatural-languagedescriptionofwhentousetheAPI,themodelproactivelycallstheAPItoperformactions.Forinstance,ifauserasks,“WhereshouldIstayinParisforacouplenights?”,themodelmaychoosetocallahotelreservationpluginAPI,receivetheAPIresponse,andgenerateauser-facinganswercombiningtheAPIdataanditsnaturallanguagecapabilities.AI模型充当智能API调用者。给定API规范和何时使用API的自然语言描述,模型会主动调用API来执行操作。例如,如果用户问,“我应该在巴黎的哪里住几晚?””,模型可以选择调用酒店预订插件API,接收API响应,并且生成组合API数据及其自然语言能力的面向用户的回答。
Overtime,weanticipatethesystemwillevolvetoaccommodatemoreadvancedusecases.随着时间的推移,我们预计系统将发展以适应更高级的用例。
Pluginflow插件流
Tobuildaplugin,itisimportanttounderstandtheend-to-endflow.要构建一个插件,理解端到端的流程是很重要的。
Createamanifestfileandhostitatyourdomain.com/.well-known/ai-plugin.json创建清单文件并将其托管在yourdomain.com/.well-known/ai-plugin.json
Thefileincludesmetadataaboutyourplugin,detailsaboutauthenticationrequired,andanOpenAPIspecfortheendpointsyouwanttoexpose.该文件包括有关插件的元数据,关于所需身份验证的详细信息,以及要公开的端点的OpenAPI规范。ThemodelwillseetheOpenAPIdescriptionfields,whichcanbeusedtoprovideanaturallanguagedescriptionforthedifferentfields.模型将看到OpenAPI描述字段,这些字段可用于为不同字段提供自然语言描述。Wesuggestexposingonly1-2endpointsinthebeginningwithaminimumnumberofparameterstominimizethelengthofthetext.Theplugindescription,APIrequests,andAPIresponsesareallinsertedintotheconversationwithChatGPT.Thiscountsagainstthecontextlimitofthemodel.我们建议在开始时只暴露1-2个端点,并使用最少数量的参数来最小化文本的长度。插件描述、API请求和API响应都被插入到与ChatGPT的对话中。这会影响模型的上下文限制。
Selectthepluginmodelfromthetopdropdown,thenselect“Plugins”,“PluginStore”,andfinally“Installanunverifiedplugin”or“Developyourownplugin”.从顶部下拉菜单中选择插件模型,然后选择“插件”,“插件商店”,最后选择“安装未验证的插件”或“开发自己的插件”。Ifauthenticationisrequired,provideanOAuth2client_idandclient_secretoranAPIkey如果需要身份验证,请提供OAuth2client_id和client_secret或API密钥
Usersactivateyourplugin用户激活您的插件
Usersbeginaconversation用户开始对话
OpenAIwillinjectacompactdescriptionofyourplugininamessagetoChatGPT,invisibletoendusers.Thiswillincludetheplugindescription,endpoints,andexamples.OpenAI将在ChatGPT的消息中注入插件的紧凑描述,最终用户不可见。这将包括插件描述、端点和示例。Whenauserasksarelevantquestion,themodelmaychoosetoinvokeanAPIcallfromyourpluginifitseemsrelevant;forPOSTrequests,werequirethatdevelopersbuildauserconfirmationflow.当用户问一个相关的问题时,模型可能会选择从你的插件调用一个API调用,如果它看起来相关的话;对于POST请求,我们要求开发人员构建用户确认流。ThemodelwillincorporatetheAPIresultsintoitsresponsetotheuser.模型将把API结果合并到对用户的响应中。ThemodelmightincludelinksreturnedfromAPIcallsinitsresponse.Thesewillbedisplayedasrichpreviews"模型可能在其响应中包含从API调用返回的链接。这些将显示为丰富的预览
Currently,wewillbesendingtheuser’scountryandstateinthePluginconversationheader(ifyouareinCaliforniaforexample,itwouldlooklike{"openai-subpision-1-iso-code":"US-CA"}.Forfurtherdatasources,userswillhavetooptinviaaconsentscreen.Thisisusefulforshopping,restaurants,weather,andmore.Youcanreadmoreinourdevelopertermsofuse.目前,我们将在插件对话标题中发送用户的国家和州(例如,如果您在加利福尼亚州,它将看起来像{"openai-subpision-1-iso-code":"US-CA"}。对于其他数据源,用户必须通过同意屏幕选择加入。这对购物、餐馆、天气等都很有用。您可以在我们的开发人员使用条款中阅读更多内容。
其它资料下载
文章为作者独立观点,不代表股票配资公司观点