Merge branch 'add_config' of https://github.com/itbm/chatpad into config-pull

This commit is contained in:
Robin Collins 2023-10-11 11:37:25 +10:30
commit b51155dfea
4 changed files with 11 additions and 43 deletions

View file

@ -18,7 +18,6 @@
"@types/react-dom": "^18.0.11",
"buffer": "^5.7.1",
"parcel": "^2.8.3",
"path-browserify": "^1.0.1",
"parcel-reporter-static-files-copy": "^1.5.0",
"process": "^0.11.10"
},

View file

@ -20,10 +20,7 @@ import { MessageItem } from "../components/MessageItem";
import { db } from "../db";
import { useChatId } from "../hooks/useChatId";
import { config } from "../utils/config";
import {
createChatCompletion,
createStreamChatCompletion,
} from "../utils/openai";
import { createChatCompletion } from "../utils/openai";
export function ChatRoute() {
const chatId = useChatId();

View file

@ -10,45 +10,25 @@
"value": "gpt-3.5-turbo",
"label": "GPT-3.5-TURBO (Default ChatGPT)"
},
{
"value": "gpt-3.5-turbo-0613",
"label": "GPT-3.5-TURBO-0613"
},
{
"value": "gpt-3.5-turbo-0301",
"label": "GPT-3.5-TURBO-0301 (Legacy)"
},
{
"value": "gpt-3.5-turbo-16k",
"label": "GPT-3.5-TURBO-16K"
},
{
"value": "gpt-3.5-turbo-16k-0613",
"label": "GPT-3.5-TURBO-16K-0613"
"label": "GPT-3.5-TURBO-0301"
},
{
"value": "gpt-4",
"label": "GPT-4 (Limited Beta)"
},
{
"value": "gpt-4-0613",
"label": "GPT-4-0613 (Limited Beta)"
},
{
"value": "gpt-4-0314",
"label": "GPT-4-0314 (Limited Beta, Legacy)"
"label": "GPT-4-0314 (Limited Beta)"
},
{
"value": "gpt-4-32k",
"label": "GPT-4-32K (Limited Beta)"
},
{
"value": "gpt-4-32k-0613",
"label": "GPT-4-32K-0613 (Limited Beta)"
},
{
"value": "gpt-4-32k-0314",
"label": "GPT-4-32K-0314 (Limited Beta, Legacy)"
"label": "GPT-4-32K-0314 (Limited Beta)"
}
],
"writingCharacters": [

View file

@ -4,19 +4,11 @@ import { OpenAIExt } from "openai-ext";
import { db } from "../db";
import { config } from "./config";
function getClient(
apiKey: string,
apiType: string,
apiAuth: string,
basePath: string
) {
function getClient(apiKey: string, apiType: string, apiAuth:string, basePath: string) {
const configuration = new Configuration({
...((apiType === "openai" ||
(apiType === "custom" && apiAuth === "bearer-token")) && {
apiKey: apiKey,
}),
...(apiType === "custom" && { basePath: basePath }),
});
...((apiType === 'openai' || (apiType === 'custom' && apiAuth === 'bearer-token')) && { apiKey: apiKey }),
...(apiType === 'custom' && { basePath: basePath }),
});
return new OpenAIApi(configuration);
}
@ -88,15 +80,15 @@ export async function createChatCompletion(
{
model,
stream: false,
messages,
messages
},
{
headers: {
"Content-Type": "application/json",
...(type === "custom" && auth === "api-key" && { "api-key": apiKey }),
...((type === 'custom' && auth === 'api-key') && { "api-key": apiKey }),
},
params: {
...(type === "custom" && { "api-version": version }),
...((type === 'custom') && {"api-version": version}),
},
}
);