The code for this example is in the package com.xkcd.ai.helloworld
.
In that package there is a Spring REST Controller named SimpleAiController
.
The SimpleAiController
accepts HTTP GET requests at http://localhost:8080/ai/simple
There is optional message
parameter whose default value is "Tell me a joke".
pl
The response to the request is from the Azure OpenAI Service.
Run the project from your IDE or use the Maven command line
./mvnw spring-boot:run
To get a response to the default request of "Tell me a joke" using the http
command line utility
http http://localhost:8080/ai/simple
or using curl
curl http://localhost:8080/ai/simple
A sample response is
Why don't scientists trust atoms?
Because they make up everything!
Now using the text
request parameter:
http GET localhost:8080/ai/simple message=='Tell me a joke about a cow.'
or using curl
curl --get --data-urlencode 'message=Tell me a joke about a cow.' http://localhost:8080/ai/simple
A sample response is
Why did the cow go to outer space? To see the moooon!