-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from MakanMatch/joshua
MakanBot API, conversationHistory and enhanced approximate address calculation
- Loading branch information
Showing
4 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const express = require("express"); | ||
const router = express.Router(); | ||
const Logger = require("../../services/Logger") | ||
const OpenAIChat = require("../../services/OpenAIChat"); | ||
|
||
router.post("/queryMakanBotWithUserPrompt", async (req, res) => { | ||
const { messagePrompt, conversationHistory } = req.body; | ||
|
||
if (!OpenAIChat.checkPermission()) { | ||
return res.status(400).send("ERROR: OpenAIChat is not available at this time."); | ||
} | ||
|
||
const message = await OpenAIChat.prompt( | ||
messagePrompt, | ||
true, | ||
conversationHistory | ||
) | ||
|
||
if (typeof message === "string" && message.startsWith("ERROR:")) { | ||
Logger.log(`CHATBOT MAKANBOT QUERYMAKANBOTWITHUSERPROMPT ERROR: Failed to run prompt through OpenAIChat; response: ${message}`) | ||
return res.status(400).send("ERROR: Failed to run prompt. Try again later."); | ||
} else { | ||
return res.status(200).json({ message: message.content }); | ||
} | ||
}); | ||
|
||
module.exports = { router, at: '/makanBot' }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters