Uploading static sources as training data for your AI Agents is well and good, but what if your database is huge, structured, externally-hosted,
or updated in real-time? There is no way to dump the entire database into GPT Chatbot’s static knowledge library and still maintain a live link…This is where function-calling comes in. Through function-calling, you can serve data on-demand to your AI Agent in GPT Chatbot during a live
conversation session. To show you how, we walk you through an example of RAG enrichment using (abstracts of) academic papers sourced from a trusted
academic papers aggregator: Semantic Scholar API.
First, you’ll need an API key from your external data provider, whoever that may be, assuming they have a secure API. In our case, we requested one
from Semantic Scholar directly.Since we want to enrich our LLM query response with relevant information from academic research, we need to find the appropriate API endpoint to
conduct the search. Semantic Scholar offers nice documentation
in that regard.
So what does this API endpoint respond with?To inspect the output, we ran a script that makes a request to the API based on hardcoded input parameters. The source code of our script is included
below. You will need your own Semantic Scholar API key if you wish to run it yourself. For our example, we ran a search for relevant papers on the topic
of “Multifidelity Optimization” and “Gaussian Processes”.
import requestsimport jsonimport os# Set up the headers with the API keyheaders = { 'X-API-KEY': "YOUR OWN API KEY"}# Specify the fields you want to fetch for each recommended paperfields = "paperId,title,authors,abstract,url,referenceCount"# Define the limit for the number of recommendations to returnlimit = 20# Make the request to get paper recommendationsresponse = requests.get( 'https://api.semanticscholar.org/graph/v1/paper/search', headers=headers, # json=payload, params={'fields': fields, 'limit': limit, 'query':'multifidelity optimization, gaussian processes' })# Check if the request was successfulif response.status_code == 200: print(json.dumps(response.json(), indent=2))else: print(f"Error: {response.status_code}") # It's better to print response.text for non-200 responses, as they may not be in JSON format print(response.text)
The output we received looks like follows:
{ "total": 12096, "offset": 0, "next": 20, "data": [ { "paperId": "b108e6e11f4a96d5058945f3b582a032e8204ade", "url": "https://www.semanticscholar.org/paper/b108e6e11f4a96d5058945f3b582a032e8204ade", "title": "Multifidelity Gaussian processes for failure boundary andprobability estimation", "abstract": "Estimating probability of failure in aerospace systems is a critical requirement for flight certification and qualification. Failure probability estimation (FPE) involves resolving tails of probability distribution and Monte Carlo (MC) sampling methods are intractable when expensive high-fidelity simulations have to be queried. We propose a method to use models of multiple fidelities, which trade accuracy for computational efficiency. Specifically, we propose the use of multifidelity Gaussian process models to efficiently fuse models at multiple fidelity. Furthermore, we propose a novel acquisition function within a Bayesian optimization framework, which can sequentially select samples (or batches of samples for parallel evaluation) from appropriate fidelity models to make predictions about quantities of interest in the highest fidelity. We use our proposed approach within a multifidelity importance sampling (MFIS) setting, and demonstrate our method on the failure level set estimation on synthetic test functions as well as the transonic flow past an airfoil wing section.", "referenceCount": 49, "authors": [ { "authorId": "98543101", "name": "Ashwin Renganathan" }, { "authorId": "144321616", "name": "Vishwas Rao" }, { "authorId": "143672238", "name": "Ionel M. Navon" } ] }, { "paperId": "963a5c60ada159d27641a284008f57d6419b26f2", "url": "https://www.semanticscholar.org/paper/963a5c60ada159d27641a284008f57d6419b26f2", "title": "Generative Transfer Optimization for Aerodynamic Design", "abstract": "Transfer optimization, one type of optimization methods, which leverages knowledge of the completed tasks to accelerate the design progress of a new task, has been in widespread use in machine learning community. However, when applying transfer optimization to accelerate the progress of aerodynamic shape optimization (ASO), two challenges are encountered in sequence, that is, (1) how to build a shared design space among the related aerodynamic design tasks, and (2) how to exchange information between tasks most efficiently. To address the first challenge, a datadriven generative model is used to learn airfoil representations from the existing database, with the aim of synthesizing various airfoil shapes in a shared design space. To address the second challenge, both singleand multifidelity Gaussian processes (GPs) are employed to carry out optimization. On one hand, the multifidelity GP is used to leverage knowledge from the completed tasks. On the other hand, mutual learning is established between singleand multifidelity GP models by exchanging information between them in each optimization cycle. With the above, a generative transfer optimization (GTO) framework is proposed to shorten the design cycle of aerodynamic design. Through airfoil optimizations at different working conditions, the effectiveness of the proposed GTO framework is demonstrated.", "referenceCount": 16, "authors": [ { "authorId": "2149505113", "name": "Zhendong Guo" }, { "authorId": "2153199285", "name": "Wei Sun" }, { "authorId": "50258957", "name": "Liming Song" }, { "authorId": "46276037", "name": "Jun Yu Li" }, { "authorId": "73325644", "name": "Z. Feng" } ] },… (truncated due to length)
The Semantic Scholar function returned the top 20 matching results ranked by relevance based on our input parameter specification. As you see, the response
can get quite long, so we truncated the output for conciseness.Ideally, you want a structured JSON response from the function’s output like what we showed above.We ran our own analysis for this particular API endpoint (with the specific set of output fields we requested) and found that on average, each returned
result is between 400-500 tokens long. This means that depending on the token limit we reserved for the function output, we can only fit so many search results
in before running out of space. Keep this in mind as you prioritize the information you wish to supply to the LLM during RAG.Now we know what the LLM would see as additional context provided by the function call, we can start linking it to our GPT Chatbot Agent.
It is ALWAYS advisable to write your own script and test for the output of the API endpoint first. You want to know exactly what kind information
is being fed into your AI Agent.
In your chatbot inside GPT Chatbot, you must first create an appropriate AI Agent that you plan to give this function-calling capability to. In our example,
we created “The Professor”. We then defined an associated Agent description and base prompt.
We picked the GPT-4-0125-8k Model for this example. You can see our simple prompt in the screenshot below.
Next, we save the Agent and go to the “Knowledge” tab to disable static RAG from the chatbot’s own knowledge library. This is only necessary if you don’t want
to use any training data from the static sources list. In our example, we didn’t upload any training data anyways, but we do this as standard practice to keep
things clean.
Within your Agent, head over to the “Functions” tab. Change the “Response Context Limit” to the maximum allowed. Then click “Add function”.
This is where you tell the LLM exactly what the function does and how it works. The LLM will then decide on its own whether it needs the function when responding
to the user during a conversation, then call it with the appropriate parameters as needed.
The function name and description are particularly useful in helping the AI understand what the function does. Please make sure to be as explicit as possible in
your own definition. The function description must be less than 1024 characters, including spaces. In our case, we wrote the following:
Function name: paper_relevance_searchFunction description: This function searches Semantic Scholar, a scholarly literature database. The input parameters will be defined based on extracted information from conversation context. It will return search results containing academic paper metadata (with abstracts) in a JSON format.The returned fields are defined as follows:- title: paper title- abstract: paper abstract- paperId: paper uuid- authors: paper authors- year: paper publication year- url: paper link- referenceCount: number of references included in the paper- citationCount: number of citations of this paper
Next, define the API endpoint. The Semantic Scholar endpoint we are using is simple and straighforward:
After that, choose the HTTP method. We use “GET” for our example. The specific API endpoint you are using should have documentation about this distinction.
Static (Fixed) Parameters remain constant across all API requests. They are pre-defined and reflect settings or configurations that do not change with each
call. For example, parameters that specify the format of the response or that enable/disable certain features globally across all API interactions fall into
this category. The term “static” emphasizes their unchanging nature.Depending on your particular API endpoint, you may need to append some fixed parameters in the URL. The API we use above from Semantic Scholar does not require
fixed parameters. But if you are using a more complex endpoint like this:
https://app.outscraper.com/api-docs#tag/Businesses-and-POI/paths/~1maps~1search-v3/get, then your API endpoint may include fixed parameters and look something like:
Notice that at the end of “https://api.app.outscraper.com/maps/search-v3”, we get into fixed parameters. This is where you define parameters that will not change
when the function is called. Always define fixed parameters this way!
If your API is capable of returning a more concise response by configuring certain parameters (i.e., tell the API to leave out unnecessary metadata in the response),
then we highly suggest that you do so. It will reduce token waste and help AI understand the context better. In the above example, we set “fields=name,full_address,phone,site”
specifically to limit the response so that it contains only name, full_address, phone, and site information - and nothing else.
In general, secure public-facing APIs require authentication. Semantic Scholar is the same. In the Header, we provide our API key. The specific key field used
to supply your authentication token will differ based on the particular API you use, so please make sure to be informed on your API provider’s documentation.
For our example, the key field is named “x-api-key”:
Finally, we get to variable parameters.Variable (Dynamic) Parameters dynamically change based on user input or conversation context, unlike their static counterparts. In function calling, these parameters
adapt to the specifics of each request, being determined at runtime. This ensures that API calls made by the AI are tailored to the immediate needs of the conversation,
enabling a more personalized and relevant interaction. The AI extracts these parameters directly from the dialogue, determining when and how to call the function
based on the ongoing conversation.For our function, we define the following variable parameters:
{ "type": "object", "properties": { "query": { "type": "string", "description": "The keywords, author names or exact paper IDs to search for" }, "fields": { "type": "string", "description": "The information to be returned, default as 'title,abstract,paperId,authors,year,url,referenceCount,citationCount'" }, "limit": { "type": "string", "description": "The number of papers users want to get, default as 2. Use the default for all cases." } }, "required": [ "query" ]}
Notice that this is a structured JSON format. Under the key field “type” of the entire parameter-set, we put “object”. You should do the same for yours.Under properties, you define each parameter along with their type and description. Take “query” for example. It has type String, meaning its data type is free text.
Types can be “String”, “integer”, “boolean”, “array”, etc. The description is more open-ended, but also extremely important. This is where you must tell
the LLM what this parameter represents. To the best of your ability, provide default values and examples of actual parameter values when the function is called.Try to be as explicit as possible. Remember that if the AI has to guess whether a parameter named ‘language’ should take ‘en’ or ‘english’ as input, chances are
it will guess wrong, and you will see errors in your chatbot output.Depending on the function you are working with, input parameters can get pretty complex. Below is another example for supplying parameters to a function (NOT related
to our Semantic Scholar example) that uses an array:
{ "type": "object", "properties": { "tags": { "type": "array", "description": "labels that should be assigned to the user’s request", "items": { "type": "object", "properties": { "name": { "type": "string", "description": "The name of the label", }, "color": { "type": "string", "description": "The color of the label", }, }, "required": ["name", "color"], }, }, }, "required": ["tags"],}
The function can only be called once the “required” parameters have been collected. If necessary information is missing, the function cannot be invoked. You
must define which parameters are mandatory in order for the function to be called.For additional information on the supported JSON schema, please reference this guide: https://json-schema.org/understanding-json-schema/reference/type
Once everything is set up, save your function, then save the Agent. You can then test it out under “Preview” tab:
You can turn on the debug mode with the toggle on the top right corner of the screen. This will allow you to inspect the output of the function if it had been
called during the LLM response:
Just like that, you equipped your AI Agent with on-demand information from an external data provider. In the future, we will also write a guide that helps you
implement and host your own database search function that then gets integrated with GPT Chatbot.
{"docsConfig":{"$schema":"https://mintlify.com/docs.json","theme":"mint","name":"GPT Chatbot API","colors":{"primary":"#2E3F51","light":"#516F90","dark":"#0D001D"},"favicon":"https://mintcdn.com/gptchatbot/et1nlYck1QOJbxxd/logo/favicon.png?fit=max\u0026auto=format\u0026n=et1nlYck1QOJbxxd\u0026q=85\u0026s=6887bcfb8c0877734cb5c8e2ba023c6b","logo":{"light":"https://mintcdn.com/gptchatbot/RpxSGx9HJ26aMoIb/logo/light.svg?fit=max\u0026auto=format\u0026n=RpxSGx9HJ26aMoIb\u0026q=85\u0026s=7a58afc2a4b648ed6b3344690bbc012d","dark":"https://mintcdn.com/gptchatbot/et1nlYck1QOJbxxd/logo/dark.svg?fit=max\u0026auto=format\u0026n=et1nlYck1QOJbxxd\u0026q=85\u0026s=18c489c900d7070d713b4e7232227076"},"api":{"mdx":{"server":"https://app.gptchatbot.it/api","auth":{"method":"bearer","name":null}}},"background":{"decoration":null,"color":{"light":null,"dark":"#111827"}},"navbar":{"links":[{"label":"Support","href":"mailto:info@gptchatbot.it"}],"primary":null},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"gptchatbot","hasAudioNarration":false,"actualSubdomain":"gptchatbot","customDomains":["docs.gptchatbot.it"],"gitSource":{"type":"github","owner":"federicodecillia","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6a48af477c1f63e9b6f5a207","collectionId":"1d2bddc6-a57f-459a-bc5c-e13adf6914a7","schemaVersion":"v3"},"entitlements":{},"buildId":"6a48b0974fc0d1ab7935e1d6:success","clientVersion":"0.0.4044","searchFilterCounts":[{"language":"default","tag":"API References","count":39},{"language":"default","tag":"Documentation","count":15},{"language":"default","tag":"Guides","count":12},{"language":"default","tag":"Data Sources","count":9},{"language":"default","tag":"Chatbots","count":6},{"language":"default","tag":"Session Messages","count":6},{"language":"default","tag":"Agents","count":5},{"language":"default","tag":"Chatbot Sessions","count":5},{"language":"default","tag":"API Usage Guides","count":4},{"language":"default","tag":"Data Source Tags","count":4}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"rag-from-external-data-provider","slug":"/rag-from-external-data-provider","pageMetadata":{"title":"RAG from an External Data Provider","description":null,"href":"/rag-from-external-data-provider"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,Frame,Heading,Note,OptimizedImage}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Frame)_missingMdxReference(`Frame`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Uploading static sources as training data for your AI Agents is well and good, but what if your database is huge, structured, externally-hosted,\nor updated in real-time? There is no way to dump the entire database into GPT Chatbot’s static knowledge library and still maintain a live link…`}),`\n`,_jsx(_components.p,{children:`This is where function-calling comes in. Through function-calling, you can serve data on-demand to your AI Agent in GPT Chatbot during a live\nconversation session. To show you how, we walk you through an example of RAG enrichment using (abstracts of) academic papers sourced from a trusted\nacademic papers aggregator: Semantic Scholar API.`}),`\n`,_jsx(Heading,{level:`2`,id:`setting-up-and-testing-the-function`,children:`Setting up and testing the function`}),`\n`,_jsxs(_components.p,{children:[`First, you’ll need an API key from your external data provider, whoever that may be, assuming they have a secure API. In our case, we requested one\nfrom `,_jsx(_components.a,{href:`https://www.semanticscholar.org/`,children:`Semantic Scholar`}),` directly.`]}),`\n`,_jsxs(_components.p,{children:[`Since we want to enrich our LLM query response with relevant information from academic research, we need to find the appropriate API endpoint to\nconduct the search. Semantic Scholar offers nice `,_jsx(_components.a,{href:`https://api.semanticscholar.org/api-docs/graph#tag/Paper-Data/operation/get_graph_paper_relevance_search`,children:`documentation`}),`\nin that regard.`]}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-1.png?fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=b72a50dd5cdf85a5c33813645ab00edf`,\"data-og-width\":`1242`,width:`1242`,\"data-og-height\":`954`,height:`954`,\"data-path\":`images/fc-external-database-api-1.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-1.png?w=280\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=59d851322c8cca4bc56682ea574c2dda 280w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-1.png?w=560\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=92181e5b987148e912e1ddb1ca55c995 560w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-1.png?w=840\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=12bcc7ad33888ebda5816634a43f22f4 840w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-1.png?w=1100\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=89a30efe950727fd9321e4caf801c36f 1100w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-1.png?w=1650\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=c04956fc46055f70fd4200199903ad68 1650w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-1.png?w=2500\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=e3ab0bd3df6a3053689d05f93e33676f 2500w`})}),`\n`,_jsx(_components.p,{children:`So what does this API endpoint respond with?`}),`\n`,_jsx(_components.p,{children:`To inspect the output, we ran a script that makes a request to the API based on hardcoded input parameters. The source code of our script is included\nbelow. You will need your own Semantic Scholar API key if you wish to run it yourself. For our example, we ran a search for relevant papers on the topic\nof “Multifidelity Optimization” and “Gaussian Processes”.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`30`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`30`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` json`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` os`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Set up the headers with the API key`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`headers `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'X-API-KEY'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"YOUR OWN API KEY\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Specify the fields you want to fetch for each recommended paper`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`fields `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"paperId,title,authors,abstract,url,referenceCount\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Define the limit for the number of recommendations to return`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`limit `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 20`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Make the request to get paper recommendations`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests.get(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'https://api.semanticscholar.org/graph/v1/paper/search'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` headers`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`headers,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # json=payload,`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` params`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'fields'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: fields, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'limit'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: limit, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'query'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'multifidelity optimization, gaussian processes'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Check if the request was successful`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response.status_code `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 200`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(json.dumps(response.json(), `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`indent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`else`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Error: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response.status_code`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # It's better to print response.text for non-200 responses, as they may not be in JSON format`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(response.text)`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The output we received looks like follows:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`56`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`56`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"total\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`12096`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"offset\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"next\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`20`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"paperId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"b108e6e11f4a96d5058945f3b582a032e8204ade\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://www.semanticscholar.org/paper/b108e6e11f4a96d5058945f3b582a032e8204ade\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"title\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Multifidelity Gaussian processes for failure boundary andprobability estimation\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` \"abstract\": \"Estimating probability of failure in aerospace systems is a critical requirement for flight certification and qualification. Failure probability estimation (FPE) involves resolving tails of probability distribution and Monte Carlo (MC) sampling methods are intractable when expensive high-fidelity simulations have to be queried. We propose a method to use models of multiple fidelities, which trade accuracy for computational efficiency. Specifically, we propose the use of multifidelity Gaussian process models to efficiently fuse models at multiple fidelity. Furthermore, we propose a novel acquisition function within a Bayesian optimization framework, which can sequentially select samples (or batches of samples for parallel evaluation) from appropriate fidelity models to make predictions about quantities of interest in the highest fidelity. We use our proposed approach within a multifidelity importance sampling (MFIS) setting, and demonstrate our method on the failure level set estimation on synthetic test functions as well as the transonic flow past an airfoil wing section.\",`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"referenceCount\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`49`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"authors\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"authorId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"98543101\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Ashwin Renganathan\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"authorId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"144321616\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Vishwas Rao\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"authorId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"143672238\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Ionel M. Navon\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"paperId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"963a5c60ada159d27641a284008f57d6419b26f2\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://www.semanticscholar.org/paper/963a5c60ada159d27641a284008f57d6419b26f2\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"title\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Generative Transfer Optimization for Aerodynamic Design\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` \"abstract\": \"Transfer optimization, one type of optimization methods, which leverages knowledge of the completed tasks to accelerate the design progress of a new task, has been in widespread use in machine learning community. However, when applying transfer optimization to accelerate the progress of aerodynamic shape optimization (ASO), two challenges are encountered in sequence, that is, (1) how to build a shared design space among the related aerodynamic design tasks, and (2) how to exchange information between tasks most efficiently. To address the first challenge, a datadriven generative model is used to learn airfoil representations from the existing database, with the aim of synthesizing various airfoil shapes in a shared design space. To address the second challenge, both singleand multifidelity Gaussian processes (GPs) are employed to carry out optimization. On one hand, the multifidelity GP is used to leverage knowledge from the completed tasks. On the other hand, mutual learning is established between singleand multifidelity GP models by exchanging information between them in each optimization cycle. With the above, a generative transfer optimization (GTO) framework is proposed to shorten the design cycle of aerodynamic design. Through airfoil optimizations at different working conditions, the effectiveness of the proposed GTO framework is demonstrated.\",`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"referenceCount\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`16`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"authors\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"authorId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"2149505113\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Zhendong Guo\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"authorId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"2153199285\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Wei Sun\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"authorId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"50258957\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Liming Song\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"authorId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"46276037\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Jun Yu Li\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"authorId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"73325644\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Z. Feng\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:`…`}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:` (truncated`}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:` due`}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:` to`}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:` length)`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The Semantic Scholar function returned the top 20 matching results ranked by relevance based on our input parameter specification. As you see, the response\ncan get quite long, so we truncated the output for conciseness.`}),`\n`,_jsx(_components.p,{children:`Ideally, you want a structured JSON response from the function’s output like what we showed above.`}),`\n`,_jsx(_components.p,{children:`We ran our own analysis for this particular API endpoint (with the specific set of output fields we requested) and found that on average, each returned\nresult is between 400-500 tokens long. This means that depending on the token limit we reserved for the function output, we can only fit so many search results\nin before running out of space. Keep this in mind as you prioritize the information you wish to supply to the LLM during RAG.`}),`\n`,_jsx(_components.p,{children:`Now we know what the LLM would see as additional context provided by the function call, we can start linking it to our GPT Chatbot Agent.`}),`\n`,_jsx(Note,{children:_jsx(_components.p,{children:`It is ALWAYS advisable to write your own script and test for the output of the API endpoint first. You want to know exactly what kind information\nis being fed into your AI Agent.`})}),`\n`,_jsx(Heading,{level:`2`,id:`create-and-prepare-the-ai-agent`,children:`Create and prepare the AI Agent`}),`\n`,_jsx(_components.p,{children:`In your chatbot inside GPT Chatbot, you must first create an appropriate AI Agent that you plan to give this function-calling capability to. In our example,\nwe created “The Professor”. We then defined an associated Agent description and base prompt.`}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-2.png?fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=623d73f1b77783d6e0cca15372b75c96`,\"data-og-width\":`1096`,width:`1096`,\"data-og-height\":`895`,height:`895`,\"data-path\":`images/fc-external-database-api-2.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-2.png?w=280\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=237519e37a2e275a33d0a9946594b434 280w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-2.png?w=560\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=4dd8133a2a6fa3d601360569b27b3641 560w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-2.png?w=840\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=114e1564bf8dab302bc6561237f39522 840w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-2.png?w=1100\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=103fd6c717f21e395f62876c9b8dd508 1100w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-2.png?w=1650\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=c5ef12fbcd7d9330cb38c7246648fd10 1650w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-2.png?w=2500\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=8e79bee1398f1a9aea71d94d377ce276 2500w`})}),`\n`,_jsx(_components.p,{children:`We picked the GPT-4-0125-8k Model for this example. You can see our simple prompt in the screenshot below.`}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-3.png?fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=32f0b51db9b935e28566676d3d6ae79e`,\"data-og-width\":`1095`,width:`1095`,\"data-og-height\":`897`,height:`897`,\"data-path\":`images/fc-external-database-api-3.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-3.png?w=280\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=38b8922419b2fd019308e6f88e58f2e4 280w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-3.png?w=560\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=56f24713eef76b0c4013268dbf13b887 560w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-3.png?w=840\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=4160b81cc5fb5caf37be32f2c43cdea2 840w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-3.png?w=1100\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=c0468d6f6f2fc9b7647b2b4805057cd2 1100w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-3.png?w=1650\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=602ae263a3eaa0e2dabd6ace9330d34c 1650w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-3.png?w=2500\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=f3a1f81320c62a850a4bd0e4c3cafc05 2500w`})}),`\n`,_jsx(_components.p,{children:`Next, we save the Agent and go to the “Knowledge” tab to disable static RAG from the chatbot’s own knowledge library. This is only necessary if you don’t want\nto use any training data from the static sources list. In our example, we didn’t upload any training data anyways, but we do this as standard practice to keep\nthings clean.`}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-4.png?fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=86ec18aa52bcaabf6fefaa5440236ea8`,\"data-og-width\":`1096`,width:`1096`,\"data-og-height\":`792`,height:`792`,\"data-path\":`images/fc-external-database-api-4.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-4.png?w=280\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=3115d36f5fa039dd57833121cab348a8 280w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-4.png?w=560\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=f8b1229ea0fe7c6a7474386d3f8c34e1 560w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-4.png?w=840\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=bb656c6845795291ec23d0c6c721346d 840w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-4.png?w=1100\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=574eae640fa4611c3f9799fb054079cf 1100w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-4.png?w=1650\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=81e28c0d6e659c7f29573bf69a7a8893 1650w, https://mintcdn.com/gptchatbot/ZlbEpevGWLnPaK5b/images/fc-external-database-api-4.png?w=2500\u0026fit=max\u0026auto=format\u0026n=ZlbEpevGWLnPaK5b\u0026q=85\u0026s=0fe8e429021b8ea0e73d9d64de479138 2500w`})}),`\n`,_jsx(_components.p,{children:`Save the Agent.`}),`\n`,_jsx(Heading,{level:`2`,id:`function-setup`,children:`Function setup`}),`\n`,_jsx(_components.p,{children:`Within your Agent, head over to the “Functions” tab. Change the “Response Context Limit” to the maximum allowed. Then click “Add function”.`}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-5.png?fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=07406c9444c2f7a7fbb553509f245fb4`,\"data-og-width\":`1098`,width:`1098`,\"data-og-height\":`442`,height:`442`,\"data-path\":`images/fc-external-database-api-5.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-5.png?w=280\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=8c415c90fc6595996c378e85a195db67 280w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-5.png?w=560\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=e98e1188191bbb804b9273c9b1324496 560w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-5.png?w=840\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=04ad78d49121c84eebb28285a7c09923 840w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-5.png?w=1100\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=141c6374f2a41bf1046ee81ebad2cbf9 1100w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-5.png?w=1650\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=7e3df4a185faafae05bb04ae21b038f7 1650w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-5.png?w=2500\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=545a42330183b77c85f2c76d9a73d14f 2500w`})}),`\n`,_jsx(_components.p,{children:`This is where you tell the LLM exactly what the function does and how it works. The LLM will then decide on its own whether it needs the function when responding\nto the user during a conversation, then call it with the appropriate parameters as needed.`}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-6.png?fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=6066a42c8d5326cb4530fc21552e0b6a`,\"data-og-width\":`1099`,width:`1099`,\"data-og-height\":`891`,height:`891`,\"data-path\":`images/fc-external-database-api-6.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-6.png?w=280\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=21b6e92de41485f82d2128ee73f285e8 280w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-6.png?w=560\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=19e5290ca01644c4f2cabce176b481fc 560w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-6.png?w=840\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=904040a696d3d17271e95acf47d4ca40 840w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-6.png?w=1100\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=b11ba1a9b390ad8f2ce734cd9d8b4172 1100w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-6.png?w=1650\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=5aaaf08ce649553eaf68fb0925ce3fd6 1650w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-6.png?w=2500\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=18a9f896f34e790d3011c562b338e5d0 2500w`})}),`\n`,_jsx(_components.p,{children:`The function name and description are particularly useful in helping the AI understand what the function does. Please make sure to be as explicit as possible in\nyour own definition. The function description must be less than 1024 characters, including spaces. In our case, we wrote the following:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`14`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`14`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Function name: paper_relevance_search`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Function description: `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`This function searches Semantic Scholar, a scholarly literature database. The input parameters will be defined based on extracted information from conversation context. It will return search results containing academic paper metadata (with abstracts) in a JSON format.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`The returned fields are defined as follows:`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`- title: paper title`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`- abstract: paper abstract`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`- paperId: paper uuid`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`- authors: paper authors`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`- year: paper publication year`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`- url: paper link`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`- referenceCount: number of references included in the paper`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`- citationCount: number of citations of this paper`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Next, define the API endpoint. The Semantic Scholar endpoint we are using is simple and straighforward:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`https://api.semanticscholar.org/graph/v1/paper/search`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`After that, choose the HTTP method. We use “GET” for our example. The specific API endpoint you are using should have documentation about this distinction.`}),`\n`,_jsx(Heading,{level:`2`,id:`fixed-parameters`,children:`Fixed parameters`}),`\n`,_jsx(_components.p,{children:`Static (Fixed) Parameters remain constant across all API requests. They are pre-defined and reflect settings or configurations that do not change with each\ncall. For example, parameters that specify the format of the response or that enable/disable certain features globally across all API interactions fall into\nthis category. The term “static” emphasizes their unchanging nature.`}),`\n`,_jsxs(_components.p,{children:[`Depending on your particular API endpoint, you may need to append some fixed parameters in the URL. The API we use above from Semantic Scholar does not require\nfixed parameters. But if you are using a more complex endpoint like this:\n`,_jsx(_components.a,{href:`https://app.outscraper.com/api-docs#tag/Businesses-and-POI/paths/~1maps~1search-v3/get`,children:`https://app.outscraper.com/api-docs#tag/Businesses-and-POI/paths/~1maps~1search-v3/get`}),`, then your API endpoint may include fixed parameters and look something like:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`https://api.app.outscraper.com/maps/search-v3?async=false\u0026fields=name,full_address,phone,site`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`Notice that at the end of “`,_jsx(_components.a,{href:`https://api.app.outscraper.com/maps/search-v3`,children:`https://api.app.outscraper.com/maps/search-v3`}),`”, we get into fixed parameters. This is where you define parameters that will not change\nwhen the function is called. Always define fixed parameters this way!`]}),`\n`,_jsx(Note,{children:_jsx(_components.p,{children:`If your API is capable of returning a more concise response by configuring certain parameters (i.e., tell the API to leave out unnecessary metadata in the response),\nthen we highly suggest that you do so. It will reduce token waste and help AI understand the context better. In the above example, we set “fields=name,full_address,phone,site”\nspecifically to limit the response so that it contains only name, full_address, phone, and site information - and nothing else.`})}),`\n`,_jsx(Heading,{level:`2`,id:`headers-and-authentication`,children:`Headers and Authentication`}),`\n`,_jsx(_components.p,{children:`In general, secure public-facing APIs require authentication. Semantic Scholar is the same. In the Header, we provide our API key. The specific key field used\nto supply your authentication token will differ based on the particular API you use, so please make sure to be informed on your API provider’s documentation.\nFor our example, the key field is named “x-api-key”:`}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-7.png?fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=9b95f727857bed253a782be9d54e1974`,\"data-og-width\":`1099`,width:`1099`,\"data-og-height\":`946`,height:`946`,\"data-path\":`images/fc-external-database-api-7.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-7.png?w=280\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=9a9b0defb6224f681154fa953db4738d 280w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-7.png?w=560\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=be8265075fa7f8112fbb558c7562aa4c 560w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-7.png?w=840\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=d738bad69528cd50645023f77f78d220 840w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-7.png?w=1100\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=ee971940d44e7f71a99df4295be0867e 1100w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-7.png?w=1650\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=892ccd78a2615fe6f7b7a4b6ac16e8d0 1650w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-7.png?w=2500\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=a7783f28e4a4e8c2f49d03d259410e4f 2500w`})}),`\n`,_jsx(Heading,{level:`2`,id:`variable-parameters`,children:`Variable parameters`}),`\n`,_jsx(_components.p,{children:`Finally, we get to variable parameters.`}),`\n`,_jsx(_components.p,{children:`Variable (Dynamic) Parameters dynamically change based on user input or conversation context, unlike their static counterparts. In function calling, these parameters\nadapt to the specifics of each request, being determined at runtime. This ensures that API calls made by the AI are tailored to the immediate needs of the conversation,\nenabling a more personalized and relevant interaction. The AI extracts these parameters directly from the dialogue, determining when and how to call the function\nbased on the ongoing conversation.`}),`\n`,_jsx(_components.p,{children:`For our function, we define the following variable parameters:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`21`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`21`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"properties\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"query\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"description\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"The keywords, author names or exact paper IDs to search for\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"fields\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"description\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"The information to be returned, default as 'title,abstract,paperId,authors,year,url,referenceCount,citationCount'\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"limit\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"description\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"The number of papers users want to get, default as 2. Use the default for all cases.\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"required\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"query\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Notice that this is a structured JSON format. Under the key field “type” of the entire parameter-set, we put “object”. You should do the same for yours.`}),`\n`,_jsx(_components.p,{children:`Under properties, you define each parameter along with their type and description. Take “query” for example. It has type String, meaning its data type is free text.\nTypes can be “String”, “integer”, “boolean”, “array”, etc. The description is more open-ended, but also extremely important. This is where you must tell\nthe LLM what this parameter represents. To the best of your ability, provide default values and examples of actual parameter values when the function is called.`}),`\n`,_jsx(_components.p,{children:`Try to be as explicit as possible. Remember that if the AI has to guess whether a parameter named ‘language’ should take ‘en’ or ‘english’ as input, chances are\nit will guess wrong, and you will see errors in your chatbot output.`}),`\n`,_jsx(_components.p,{children:`Depending on the function you are working with, input parameters can get pretty complex. Below is another example for supplying parameters to a function (NOT related\nto our Semantic Scholar example) that uses an array:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`24`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`24`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"properties\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"tags\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"array\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"description\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"labels that should be assigned to the user’s request\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"items\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"properties\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"description\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"The name of the label\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"color\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"description\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"The color of the label\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"required\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"color\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"required\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"tags\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The function can only be called once the “required” parameters have been collected. If necessary information is missing, the function cannot be invoked. You\nmust define which parameters are mandatory in order for the function to be called.`}),`\n`,_jsxs(_components.p,{children:[`For additional information on the supported JSON schema, please reference this guide: `,_jsx(_components.a,{href:`https://json-schema.org/understanding-json-schema/reference/type`,children:`https://json-schema.org/understanding-json-schema/reference/type`})]}),`\n`,_jsx(Heading,{level:`2`,id:`testing-the-chatbot`,children:`Testing the chatbot`}),`\n`,_jsx(_components.p,{children:`Once everything is set up, save your function, then save the Agent. You can then test it out under “Preview” tab:`}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-8.png?fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=561a64c18955e673eebe55763829acdf`,\"data-og-width\":`657`,width:`657`,\"data-og-height\":`811`,height:`811`,\"data-path\":`images/fc-external-database-api-8.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-8.png?w=280\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=e77ed3bfb4a01670fe46a14ce29829da 280w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-8.png?w=560\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=50dc21465f4ce8b5b52472645475e982 560w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-8.png?w=840\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=41939996e6fbf7634815a68d45d368d3 840w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-8.png?w=1100\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=e0266b21eac75fd58437b34470e15069 1100w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-8.png?w=1650\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=a160b607a87c243789ab7e1edff70226 1650w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-8.png?w=2500\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=35431503a46486dcbb5e139cbde54cca 2500w`})}),`\n`,_jsx(_components.p,{children:`You can turn on the debug mode with the toggle on the top right corner of the screen. This will allow you to inspect the output of the function if it had been\ncalled during the LLM response:`}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-9.png?fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=56046659d1545bfb4bc425453f0d1601`,\"data-og-width\":`1209`,width:`1209`,\"data-og-height\":`669`,height:`669`,\"data-path\":`images/fc-external-database-api-9.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-9.png?w=280\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=8e9a8e889e8807d74be0112094c7ad8a 280w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-9.png?w=560\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=426c4dd20ddbb8878cc7b76646d4e537 560w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-9.png?w=840\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=37d1fc1fc0b179fd7f7b9c480f062c0f 840w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-9.png?w=1100\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=fdf3b469a9d99e90967ecbce0acda543 1100w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-9.png?w=1650\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=3a38cf92c759289cc2b19343a9844019 1650w, https://mintcdn.com/gptchatbot/i05P6ienN4sNHppQ/images/fc-external-database-api-9.png?w=2500\u0026fit=max\u0026auto=format\u0026n=i05P6ienN4sNHppQ\u0026q=85\u0026s=8cec0d64afdf22446d4001f867764d97 2500w`})}),`\n`,_jsx(_components.p,{children:`Just like that, you equipped your AI Agent with on-demand information from an external data provider. In the future, we will also write a guide that helps you\nimplement and host your own database search function that then gets integrated with GPT Chatbot.`})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"RAG from an External Data Provider","description":null,"href":"/rag-from-external-data-provider"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Setting up and testing the function","slug":"setting-up-and-testing-the-function","depth":2,"children":[]},{"title":"Create and prepare the AI Agent","slug":"create-and-prepare-the-ai-agent","depth":2,"children":[]},{"title":"Function setup","slug":"function-setup","depth":2,"children":[]},{"title":"Fixed parameters","slug":"fixed-parameters","depth":2,"children":[]},{"title":"Headers and Authentication","slug":"headers-and-authentication","depth":2,"children":[]},{"title":"Variable parameters","slug":"variable-parameters","depth":2,"children":[]},{"title":"Testing the chatbot","slug":"testing-the-chatbot","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"gptchatbot","siteName":"GPT Chatbot API","title":"RAG from an External Data Provider - GPT Chatbot API","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-07-04T06:59:33.129Z","originalFileLocation":"rag-from-external-data-provider.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"GPT Chatbot API\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/gptchatbot/IDKThlX0BZP96Vwt/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/gptchatbot/IDKThlX0BZP96Vwt/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/gptchatbot/IDKThlX0BZP96Vwt/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/gptchatbot/IDKThlX0BZP96Vwt/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/gptchatbot/IDKThlX0BZP96Vwt/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/gptchatbot/IDKThlX0BZP96Vwt/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/gptchatbot/IDKThlX0BZP96Vwt/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/gptchatbot/IDKThlX0BZP96Vwt/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/gptchatbot/IDKThlX0BZP96Vwt/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"RAG from an External Data Provider - GPT Chatbot API\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"GPT Chatbot API\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.gptchatbot.it/rag-from-external-data-provider\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://gptchatbot.mintlify.app/_mintlify/api/og/v2?division=Function+Calling\u0026amp;title=RAG+from+an+External+Data+Provider\u0026amp;theme=20e021f1004a9f9f06bad9ba\u0026amp;signature=7e1acfa0306db2f4e60d204abcb2f820e83d4cb9f7688aecdb956f7ce4876046\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"RAG from an External Data Provider - GPT Chatbot API\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://gptchatbot.mintlify.app/_mintlify/api/og/v2?division=Function+Calling\u0026amp;title=RAG+from+an+External+Data+Provider\u0026amp;theme=20e021f1004a9f9f06bad9ba\u0026amp;signature=7e1acfa0306db2f4e60d204abcb2f820e83d4cb9f7688aecdb956f7ce4876046\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/gptchatbot/IDKThlX0BZP96Vwt/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"GPT Chatbot API\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#2E3F51\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.gptchatbot.it/rag-from-external-data-provider\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/rag-from-external-data-provider.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.gptchatbot.it/#organization\",\"name\":\"GPT Chatbot API\",\"url\":\"https://docs.gptchatbot.it\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/gptchatbot/RpxSGx9HJ26aMoIb/logo/light.svg?fit=max\u0026auto=format\u0026n=RpxSGx9HJ26aMoIb\u0026q=85\u0026s=7a58afc2a4b648ed6b3344690bbc012d\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.gptchatbot.it#website\",\"name\":\"GPT Chatbot API\",\"url\":\"https://docs.gptchatbot.it\",\"publisher\":{\"@id\":\"https://docs.gptchatbot.it/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.gptchatbot.it/rag-from-external-data-provider#webpage\",\"url\":\"https://docs.gptchatbot.it/rag-from-external-data-provider\",\"name\":\"RAG from an External Data Provider\",\"dateModified\":\"2026-07-04T06:59:33.129Z\",\"isPartOf\":{\"@id\":\"https://docs.gptchatbot.it#website\"},\"breadcrumb\":{\"@id\":\"https://docs.gptchatbot.it/rag-from-external-data-provider#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.gptchatbot.it/rag-from-external-data-provider#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"GPT Chatbot API\",\"item\":\"https://docs.gptchatbot.it\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"RAG from an External Data Provider\",\"item\":\"https://docs.gptchatbot.it/rag-from-external-data-provider\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.gptchatbot.it/rag-from-external-data-provider#article\",\"headline\":\"RAG from an External Data Provider\",\"name\":\"RAG from an External Data Provider\",\"url\":\"https://docs.gptchatbot.it/rag-from-external-data-provider\",\"mainEntityOfPage\":{\"@id\":\"https://docs.gptchatbot.it/rag-from-external-data-provider#webpage\"},\"dateModified\":\"2026-07-04T06:59:33.129Z\",\"publisher\":{\"@id\":\"https://docs.gptchatbot.it/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.gptchatbot.it#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"GPT Chatbot API\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"GPT Chatbot API","nav":{"global":null,"anchors":[{"anchor":"Documentation","icon":"book-open","groups":[{"group":"Getting Started","pages":[{"title":"Introduction","href":"/introduction"}]},{"group":"Guides","pages":[{"title":"Create Your First Chatbot","href":"/creating-first-chatbot"},{"title":"Lead Collection","href":"/lead-collection"},{"title":"Human Support Escalation","href":"/human-support-escalation"},{"title":"Inbox Notifications","href":"/inbox-notifications"},{"title":"Conversation Labeling","href":"/conversation-labeling"},{"title":"Multi-Agents Chatbot","href":"/multi-agents-chatbot"},{"title":"Fine Tuning Agent Intents","href":"/fine-tuning-agent-intents"},{"title":"AI Supervisor Overrides","href":"/supervisor-overrides"},{"title":"Bring Your Own Key (BYOK) and Pricing","href":"/byok-pricing-guide"},{"title":"Working with Tables and CSV","href":"/working-with-tables"},{"title":"Best practices for preparing training data","href":"/best-practices"},{"title":"Why does my chatbot not answer correctly?","description":null,"href":"/help"}]},{"group":"Function Calling","pages":[{"title":"RAG from an External Data Provider","href":"/rag-from-external-data-provider"}]},{"group":"Authentication Webhook","pages":[{"title":"User Identity Verification","description":null,"href":"/user-identity"}]}]},{"anchor":"API References","icon":"code","pages":[{"title":"API References","href":"/api-reference/api-key-setup"}]},{"anchor":"Tools","icon":"gear","pages":[{"title":"Tools","href":"/tools/tools-intro"}]}]},"basePath":"","title":"RAG from an External Data Provider - GPT Chatbot API","buildId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","deploymentId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","dynamics":["07c022d89b","a74be98ba7"],"chunks":["Frame-DXXFP6nH.js","DynamicMarkdown-B54_zNBF.js","zoom-image-lightbox-BG6oD64b.js","lightbox-handle-r17bVUz3.js"]}