-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swiches chatui to use the assistant instead of the openai api
- Loading branch information
Showing
3 changed files
with
33 additions
and
1 deletion.
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,30 @@ | ||
import { getAuth } from 'protonode' | ||
import { APIContext } from "protolib/bundles/apiContext" | ||
import { API, Protofy, getLogger } from "protobase"; | ||
import { Application } from 'express'; | ||
import fs from 'fs' | ||
import path from "path"; | ||
import { createChatbot } from "protolib/bundles/chatbots/createChatbot"; | ||
|
||
const root = path.join(process.cwd(), '..', '..') | ||
const logger = getLogger() | ||
|
||
Protofy("type", "chatGPT") | ||
|
||
export default Protofy("code", async (app:Application, context: typeof APIContext) => { | ||
createChatbot(app, 'assistant', async (req, res, chatbot) => { | ||
const {session, token} = getAuth(req) | ||
context.chatGPT.chatGPTPrompt({ | ||
...req.body, | ||
done: (response, message) => { | ||
chatbot.end() | ||
}, | ||
chunk: (chunk) => { | ||
chatbot.sendRaw(chunk) | ||
}, | ||
error: (error) => { | ||
chatbot.sendError(error) | ||
} | ||
}) | ||
}) | ||
}) |
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
2 changes: 1 addition & 1 deletion
2
packages/protolib/src/components/chatbot/services/chatService.ts
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