ai-matcher v0.0.1
ai-matcher
Microservice that matches query strings to a large database of questions/answers, with context
Setup
Clone the repo. npm install. Copy conf.json.example to conf.json.
Run mongod locally in another process.
npm test to run test suite. npm test -- -w to watch for file updates.
npm test -- test/route-query.js to run tests on a particular file.
npm start to spin up the server, then call make requests with
curl 'localhost:3002/api/query?question=how+are+you' -H 'Authorization: Bearer test'Design
Endpoints
All inputs and outputs are JSON. Query parameters should be sent like so:
- Dates in Query Strings should be in ISO_8601 format
- Arrays in Query Strings should be any format understood by
qs(a[]=b&a[]=cworks fine) - Bools in Query Strings should be
0or1 PUTmethods merged onto the existing objects using_.assigncreatedandupdatedare set automatically and cannot be modified
GET /query- Run a question through the system. Creates aLogentry.- Query Parameters
question : String- User's questionmessagingService : String- filters the Understandings based upon the college we are concerned aboutcontexts : [String]- allows access to Understandings that haveinputContextsspecifieduserId : String- For logging purposes
- Returns
success : Booleantopic : String-topicfor the matchedUnderstandinganswer : String- answer to send the useroutputContexts : [String]- contexts that should be sent with the next requestlogId : String-idof the generatedLogentry.
- Query Parameters
GET /logs- Return a list of all logs, optionally filtered. Please filter, or there will be too many results- Query Parameters
createdBefore, createdAfter, updatedBefore, updatedAfter : DateneedsReview, handled : BooleanmessagingService : String
- Query Parameters
PUT /logs/:id- Update a log. SetshandledDateandreviewedDateautomaticallyGET /understandings- Get a list of all understandings, optionally filtered- Query Parameters
createdBefore, createdAfter, updatedBefore, updatedAfter : Date
- Query Parameters
PUT /understandings/:id- Update an understandingPOST /understandings/- Create a new understandingGET /entities- Get a list of all entities, optionally filtered- Query Parameters
createdBefore, createdAfter, updatedBefore, updatedAfter : Date
- Query Parameters
PUT /entities/:id- Update an entityPOST /entities- Create a new entity
Collections
Understandingscreated : Dateupdated : Datetopic : Stringkeywords : [String]outputContexts : [String]questionGroups : [Object]inputContexts : [String]fuzzyQuestions [String]exactQuestions [String]
answerGroups : [Object]messagingService : Stringanswers : [String]media : [String]
Entitiescreated : Dateupdated : Datename : StringsynonymGroups : [Object]messagingService : Stringsynonyms : [String]
Logscreated : Dateupdated : DateuserId : String- Oli User IDquestion : StringinputContexts : [String]outputContexts : [String]topic : StringmessagingService : Stringanswer : StringsentToHuman : Stringhandled : BooleanhandledBy : String- Oli User IDhandledDate : Date- Set automatically withPUT /logsif{handled : true}handledAction : [String]humanResponse : Stringreviewed : BooleanreviewedBy : String- Oli User IDreviewedDate : Date- Set automatically withPUT /logsif{needsReview : true -> false}reviewedAction : Stringerror : String
10 years ago