Fetching ISO Country Codes with Backengine
In this post I will detail the straightforward process of creating a Backengine endpoint that returns an ISO country code given a wide range of inputs (of varying quality!).
Follow along in the playground!
First, head to the dashboard and select ‘Add New Endpoint’.
Give your endpoint a name and, if you like, a brief description. Click ‘Create Endpoint’.
For now, we’ll be working on the ‘Configure’ form.
There are only a few fields to complete:
- The prompt: this is the prompt that the LLM will receive, combined with the input you send to your endpoint.
- The LLM model you want your endpoint to use.
- Request template: the format of the incoming request to be combined with the prompt.
- Response template: the format of the response that the endpoint will return.
The prompt simply asks the endpoint to return an ISO code given the input. We also want it to try to be tolerant of typos and spelling mistakes.
Let’s choose ChatGPT 3.5. It’ll likely be faster for this simple task.
The request template and the return template tell our endpoint how the incoming request and outgoing response should look, as well as defining types. You can think of it a bit like providing an example. In this case, we’ll receive and return a string.
Click ‘Save & Deploy’ to save your endpoint. That’s it!
Testing
Let’s test it out by turning our attention to the ‘Test’ panel on the same page.
Here, we can define an input that we may pass from our own application, to see if the endpoint works as expected. Depending on what we find, we may have to do some prompt engineering to get the LLM to respond as we would like.
Seems to be working as expected! Entering UK gets us the ISO code for Great Britain. Let’s try something a little more challenging.
Even with a pretty awful misspelling our endpoint still manages to do what we want.
It’ll also handle other languages or even descriptions of countries!
Deployment
Your endpoint should already be deployed. You’ll see the URL and an example curl request.
And that’s it! You can integrate this endpoint anywhere you like.
Sign up for free to have a go yourself.