Add baseURL and max Tokens config
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -56,6 +56,14 @@
|
|||||||
<label for="code" class="textLabel">Code:</label>
|
<label for="code" class="textLabel">Code:</label>
|
||||||
<input id="code" type="text" />
|
<input id="code" type="text" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="line center">
|
||||||
|
<label for="baseURL" class="textLabel">Base URL:</label>
|
||||||
|
<input id="baseURL" type="text" />
|
||||||
|
</div>
|
||||||
|
<div class="line center">
|
||||||
|
<label for="maxTokens" class="textLabel">Max Tokens:</label>
|
||||||
|
<input id="maxTokens" type="number" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- SWITCH SETTINGS MODE -->
|
<!-- SWITCH SETTINGS MODE -->
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -82,6 +82,7 @@ a {
|
|||||||
|
|
||||||
.line input[type='text'],
|
.line input[type='text'],
|
||||||
.line input[type='password'],
|
.line input[type='password'],
|
||||||
|
.line input[type='number'],
|
||||||
.line select {
|
.line select {
|
||||||
flex: 1 1;
|
flex: 1 1;
|
||||||
border: thin solid var(--color);
|
border: thin solid var(--color);
|
||||||
|
|||||||
Generated
+1295
-1685
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,7 @@ async function getChatGPTResponse(
|
|||||||
|
|
||||||
const client = new OpenAI({
|
const client = new OpenAI({
|
||||||
apiKey: config.apiKey,
|
apiKey: config.apiKey,
|
||||||
|
baseURL: config.baseURL,
|
||||||
dangerouslyAllowBrowser: true
|
dangerouslyAllowBrowser: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ async function getChatGPTResponse(
|
|||||||
temperature: 0.1, // Controls the randomness of the generated responses, with lower values producing more deterministic and predictable outputs. With set to 0.1 instead of 0 for more creativity.
|
temperature: 0.1, // Controls the randomness of the generated responses, with lower values producing more deterministic and predictable outputs. With set to 0.1 instead of 0 for more creativity.
|
||||||
top_p: 0.6, // Determines the diversity of the generated responses
|
top_p: 0.6, // Determines the diversity of the generated responses
|
||||||
presence_penalty: 0, // Encourages the model to introduce new concepts by penalizing words that have already appeared in the text.
|
presence_penalty: 0, // Encourages the model to introduce new concepts by penalizing words that have already appeared in the text.
|
||||||
max_tokens: 2000 // Maximum length of the response,
|
max_tokens: config.maxTokens || 2000 // Use maxTokens from config
|
||||||
}),
|
}),
|
||||||
{ signal: config.timeout ? controller.signal : null }
|
{ signal: config.timeout ? controller.signal : null }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ type Config = {
|
|||||||
history?: boolean;
|
history?: boolean;
|
||||||
includeImages?: boolean;
|
includeImages?: boolean;
|
||||||
mode?: 'autocomplete' | 'question-to-answer' | 'clipboard';
|
mode?: 'autocomplete' | 'question-to-answer' | 'clipboard';
|
||||||
|
baseURL?: string;
|
||||||
|
maxTokens?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Config;
|
export default Config;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const apiKeySelector: HTMLInputElement = document.querySelector('#apiKey')!;
|
|||||||
const inputModel: HTMLInputElement = document.querySelector('#model')!;
|
const inputModel: HTMLInputElement = document.querySelector('#model')!;
|
||||||
const modelsList: HTMLElement = document.querySelector('#models')!;
|
const modelsList: HTMLElement = document.querySelector('#models')!;
|
||||||
const imagesIntegrationLine: HTMLInputElement = document.querySelector('#includeImages-line')!;
|
const imagesIntegrationLine: HTMLInputElement = document.querySelector('#includeImages-line')!;
|
||||||
|
const baseURLSelector: HTMLInputElement = document.querySelector('#baseURL')!;
|
||||||
/**
|
/**
|
||||||
* Check if the gpt version is at least 4 to show the option 'Include images'
|
* Check if the gpt version is at least 4 to show the option 'Include images'
|
||||||
*/
|
*/
|
||||||
@@ -23,6 +23,7 @@ inputModel.addEventListener('input', checkCanIncludeImages);
|
|||||||
// We populate the datalist of the chatgpt model
|
// We populate the datalist of the chatgpt model
|
||||||
export async function populateDatalistWithGptVersions() {
|
export async function populateDatalistWithGptVersions() {
|
||||||
const apiKey = apiKeySelector.value?.trim();
|
const apiKey = apiKeySelector.value?.trim();
|
||||||
|
const baseURL = baseURLSelector.value?.trim();
|
||||||
|
|
||||||
if (!apiKey) return;
|
if (!apiKey) return;
|
||||||
|
|
||||||
@@ -31,6 +32,7 @@ export async function populateDatalistWithGptVersions() {
|
|||||||
try {
|
try {
|
||||||
const client = new OpenAI({
|
const client = new OpenAI({
|
||||||
apiKey,
|
apiKey,
|
||||||
|
baseURL,
|
||||||
dangerouslyAllowBrowser: true
|
dangerouslyAllowBrowser: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -61,9 +63,10 @@ inputModel.addEventListener('focus', populateDatalistWithGptVersions);
|
|||||||
export async function checkModel() {
|
export async function checkModel() {
|
||||||
const model = inputModel.value?.trim();
|
const model = inputModel.value?.trim();
|
||||||
const apiKey = apiKeySelector.value?.trim();
|
const apiKey = apiKeySelector.value?.trim();
|
||||||
|
const baseURL = baseURLSelector.value?.trim();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const client = new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
const client = new OpenAI({ apiKey, baseURL, dangerouslyAllowBrowser: true });
|
||||||
await client.chat.completions.create({
|
await client.chat.completions.create({
|
||||||
model,
|
model,
|
||||||
messages: [{ role: 'user', content: 'reply just pong' }]
|
messages: [{ role: 'user', content: 'reply just pong' }]
|
||||||
|
|||||||
+4
-2
@@ -9,11 +9,11 @@ import { showMessage } from './utils';
|
|||||||
const saveBtn = document.querySelector('.save')!;
|
const saveBtn = document.querySelector('.save')!;
|
||||||
|
|
||||||
// inputs id
|
// inputs id
|
||||||
const inputsText = ['apiKey', 'code', 'model'];
|
const inputsText = ['apiKey', 'code', 'model', 'baseURL', 'maxTokens'];
|
||||||
|
|
||||||
// Save the configuration
|
// Save the configuration
|
||||||
saveBtn.addEventListener('click', function () {
|
saveBtn.addEventListener('click', function () {
|
||||||
const [apiKey, code, model] = inputsText.map(selector =>
|
const [apiKey, code, model, baseURL, maxTokens] = inputsText.map(selector =>
|
||||||
(document.querySelector('#' + selector) as HTMLInputElement).value.trim()
|
(document.querySelector('#' + selector) as HTMLInputElement).value.trim()
|
||||||
);
|
);
|
||||||
const [logs, title, cursor, typing, mouseover, infinite, timeout, history, includeImages] =
|
const [logs, title, cursor, typing, mouseover, infinite, timeout, history, includeImages] =
|
||||||
@@ -40,6 +40,8 @@ saveBtn.addEventListener('click', function () {
|
|||||||
apiKey,
|
apiKey,
|
||||||
code,
|
code,
|
||||||
model,
|
model,
|
||||||
|
baseURL,
|
||||||
|
maxTokens: maxTokens ? parseInt(maxTokens) : undefined,
|
||||||
logs,
|
logs,
|
||||||
title,
|
title,
|
||||||
cursor,
|
cursor,
|
||||||
|
|||||||
Reference in New Issue
Block a user