Merge pull request #46 from dmunozv04/main

Add baseURL and max Tokens config
This commit is contained in:
yoannchb-pro
2025-03-19 08:53:03 -04:00
committed by GitHub
11 changed files with 1327 additions and 1700 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+8
View File
@@ -56,6 +56,14 @@
<label for="code" class="textLabel">Code:</label>
<input id="code" type="text" />
</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>
<!-- 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
+1
View File
@@ -82,6 +82,7 @@ a {
.line input[type='text'],
.line input[type='password'],
.line input[type='number'],
.line select {
flex: 1 1;
border: thin solid var(--color);
+1301 -1691
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -25,6 +25,7 @@ async function getChatGPTResponse(
const client = new OpenAI({
apiKey: config.apiKey,
baseURL: config.baseURL,
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.
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.
max_tokens: 2000 // Maximum length of the response,
max_tokens: config.maxTokens || 2000 // Use maxTokens from config
}),
{ signal: config.timeout ? controller.signal : null }
);
+2
View File
@@ -12,6 +12,8 @@ type Config = {
history?: boolean;
includeImages?: boolean;
mode?: 'autocomplete' | 'question-to-answer' | 'clipboard';
baseURL?: string;
maxTokens?: number;
};
export default Config;
+5 -2
View File
@@ -5,7 +5,7 @@ const apiKeySelector: HTMLInputElement = document.querySelector('#apiKey')!;
const inputModel: HTMLInputElement = document.querySelector('#model')!;
const modelsList: HTMLElement = document.querySelector('#models')!;
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'
*/
@@ -23,6 +23,7 @@ inputModel.addEventListener('input', checkCanIncludeImages);
// We populate the datalist of the chatgpt model
export async function populateDatalistWithGptVersions() {
const apiKey = apiKeySelector.value?.trim();
const baseURL = baseURLSelector.value?.trim();
if (!apiKey) return;
@@ -31,6 +32,7 @@ export async function populateDatalistWithGptVersions() {
try {
const client = new OpenAI({
apiKey,
baseURL,
dangerouslyAllowBrowser: true
});
@@ -61,9 +63,10 @@ inputModel.addEventListener('focus', populateDatalistWithGptVersions);
export async function checkModel() {
const model = inputModel.value?.trim();
const apiKey = apiKeySelector.value?.trim();
const baseURL = baseURLSelector.value?.trim();
try {
const client = new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
const client = new OpenAI({ apiKey, baseURL, dangerouslyAllowBrowser: true });
await client.chat.completions.create({
model,
messages: [{ role: 'user', content: 'reply just pong' }]
+4 -2
View File
@@ -9,11 +9,11 @@ import { showMessage } from './utils';
const saveBtn = document.querySelector('.save')!;
// inputs id
const inputsText = ['apiKey', 'code', 'model'];
const inputsText = ['apiKey', 'code', 'model', 'baseURL', 'maxTokens'];
// Save the configuration
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()
);
const [logs, title, cursor, typing, mouseover, infinite, timeout, history, includeImages] =
@@ -40,6 +40,8 @@ saveBtn.addEventListener('click', function () {
apiKey,
code,
model,
baseURL,
maxTokens: maxTokens ? parseInt(maxTokens) : undefined,
logs,
title,
cursor,