The aim of this project is assigning a specific job to GPT. And trying to understand user messages' intent whether is an appointment request with specific date/time or not, basically labelling
There are some rules assigned to GPT, you can see them as systemContent in /routes/appointment.ts
The tests are written in Turkish language but the system I tried to build is trying to support other languages that OpenAI supports (systemContent is written in English)
Its using gpt-3.5-turbo
Ps. The main part of this project is prompt engineering: https://help.openai.com/en/articles/6654000-best-practices-for-prompt-engineering-with-openai-api (this is the main part of this project)
- Its an API endpoint that extracts the user intent for a new appointment from a natural language message using GPT4.
- Handles both relative and absolute time and date. For example
today,tomorrow,this Friday,30 of July(or from other languages for example in Turkishbugün) - No "parsing" natural language - GPT4 is doing that for us.
- Given a message like
Are you free for tomorrow at 2pm?, the API endpoint output a JSON similar to the following (this example assumes the date is2023-07-29):{ intent: "new_appointment", datetimeStr: "2023-07-30T14:00" } - Included a suite of tests that call the API endpoint with a few different example inputs. Tests are asserting that the correct intent and datetime is extracted, also assert that intents other than new appointments are classified as "other."
- Clone this project
- Install dependencies using yarn (
yarn install) - Create an env file called
.env.localunder root folder - Add
PORTenv variable to.env.localfile - Create your own OpenAI API key and add it as env variable in
.env.local - So resulting
.env.localfile should look like
PORT=<example_port>
OPENAI_API_KEY=<your OpenAI API key>
- Run
yarn start:devfor development - Run
yarn testto run tests - Make a
GETrequest to /appointment-intent toextracts the user intent for a new appointment - Make a
GETrequest to /appointment-classify to start building your own classifier model (please readCLASSIFICATION_README) - Make a
GETrequest to /ask to chat with OpenAI API (please readASK_README)
In the project I tried to keep time zones into consideration but in some scenerios its working flaky. Based on the run time
For example if you are in Turkey and run this project at night there can be some +/- 1day.
You can observe this with running the tests (please check expected & received difference). So I advise you to run it at noon :D
Also since this project using GPT, we shouldnt expect 100% correctness.
- Sinan Talha KOSAR (sinantalhakosar@gmail.com)