aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis/gpt/GPT.ts
diff options
context:
space:
mode:
authorsrichman333 <sarah_n_richman@brown.edu>2024-02-28 19:24:22 -0500
committersrichman333 <sarah_n_richman@brown.edu>2024-02-28 19:24:22 -0500
commit54c597bb865aba15f16e0692c2f2119109d119aa (patch)
tree97fc0723e5792a805128bfa9161e8ddc0f530030 /src/client/apis/gpt/GPT.ts
parentf77249408f89187a179f656e9027446b46a858c0 (diff)
chat with ai
Diffstat (limited to 'src/client/apis/gpt/GPT.ts')
-rw-r--r--src/client/apis/gpt/GPT.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/client/apis/gpt/GPT.ts b/src/client/apis/gpt/GPT.ts
index 82436c42b..97a332294 100644
--- a/src/client/apis/gpt/GPT.ts
+++ b/src/client/apis/gpt/GPT.ts
@@ -33,7 +33,7 @@ const callTypeMap: { [type: string]: GPTCallOpts } = {
* @param inputText Text to process
* @returns AI Output
*/
-const gptAPICall = async (inputText: string, callType: GPTCallType) => {
+const gptAPICall = async (inputText: string, callType: GPTCallType, prompt?: any) => {
if (callType === GPTCallType.SUMMARY) inputText += '.';
const opts: GPTCallOpts = callTypeMap[callType];
try {
@@ -43,8 +43,9 @@ const gptAPICall = async (inputText: string, callType: GPTCallType) => {
};
const openai = new OpenAI(configuration);
+ let usePrompt = prompt? prompt: opts.prompt;
let messages: ChatCompletionMessageParam[] = [
- { role: 'system', content: opts.prompt },
+ { role: 'system', content: usePrompt },
{ role: 'user', content: inputText },
];