aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis/gpt/Summarization.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/apis/gpt/Summarization.ts')
-rw-r--r--src/client/apis/gpt/Summarization.ts48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/client/apis/gpt/Summarization.ts b/src/client/apis/gpt/Summarization.ts
deleted file mode 100644
index 0d9b5dfcd..000000000
--- a/src/client/apis/gpt/Summarization.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import { Configuration, OpenAIApi } from 'openai';
-
-enum GPTCallType {
- SUMMARY = 'summary',
- COMPLETION = 'completion',
-}
-
-type GPTCallOpts = {
- model: string;
- maxTokens: number;
- temp: number;
- prompt: string;
-};
-
-const callTypeMap: { [type: string]: GPTCallOpts } = {
- summary: { model: 'text-davinci-003', maxTokens: 100, temp: 0.5, prompt: 'Summarize this text: ' },
- completion: { model: 'text-davinci-003', maxTokens: 256, temp: 0.5, prompt: '' },
-};
-
-/**
- * Calls the OpenAI API.
- *
- * @param inputText Text to process
- * @returns AI Output
- */
-const gptAPICall = async (inputText: string, callType: GPTCallType) => {
- if (callType === GPTCallType.SUMMARY) inputText += '.';
- const opts: GPTCallOpts = callTypeMap[callType];
- try {
- const configuration = new Configuration({
- apiKey: process.env.OPENAI_KEY,
- });
- const openai = new OpenAIApi(configuration);
- const response = await openai.createCompletion({
- model: opts.model,
- max_tokens: opts.maxTokens,
- temperature: opts.temp,
- prompt: `${opts.prompt}${inputText}`,
- });
- return response.data.choices[0].text;
- } catch (err) {
- console.log(err);
- return 'Error connecting with API.';
- }
-};
-
-
-export { gptAPICall, GPTCallType};