Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 17aa8b49e0 | |||
| a2849da20c | |||
| 54c9373e33 | |||
| e793cbd0b2 | |||
| fffc0d55d6 | |||
| e561227b78 | |||
| 677e870635 | |||
| 6e69830a2e | |||
| f01785256c | |||
| f2e1ec8ed6 | |||
| 98f22e9056 | |||
| 79a75fee89 | |||
| 476559188f |
@@ -1,21 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['@typescript-eslint'],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/eslint-recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'prettier'
|
||||
],
|
||||
ignorePatterns: ['node_modules/'],
|
||||
overrides: [
|
||||
{
|
||||
files: ['extension/popup/*.js', 'src/**/*.ts'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'no-constant-condition': 'off'
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
buy_me_a_coffee: yoannchbpro
|
||||
@@ -1,5 +1,16 @@
|
||||
# CHANGELOG
|
||||
|
||||
## v1.1.4
|
||||
|
||||
- Support for all `o` models
|
||||
- Removed `Clear my choice` in the api call
|
||||
- Code dependencies update
|
||||
|
||||
## v1.1.3
|
||||
|
||||
- Added `base url` and `max token` in config (by dmunozv04)
|
||||
- Code dependencies update
|
||||
|
||||
## v1.1.2
|
||||
|
||||
- Advanced settings
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
href="https://www.flaticon.com/free-icons/mortarboard" target="_blank" rel="noopener noreferrer"
|
||||
title="Mortarboard icons created by itim2101 - Flaticon" ><img src="./extension/icon.png" alt="Mortarboard icons created by itim2101 - Flaticon" width="150" style="display:block; margin:auto;"></a></p>
|
||||
|
||||
# MoodleGPT 1.1.2
|
||||
# MoodleGPT 1.1.4
|
||||
|
||||
This extension allows you to hide CHAT-GPT in a Moodle quiz. You just need to click on the question you want to solve, and CHAT-GPT will automatically provide the answer. However, one needs to be careful because as we know, CHAT-GPT can make errors especially in calculations.
|
||||
|
||||
@@ -12,15 +12,17 @@ Find the extension on the Chrome Webstore right [here](https://chrome.google.com
|
||||
|
||||
## Summary
|
||||
|
||||
- [MoodleGPT 1.1.2](#moodlegpt-112)
|
||||
- [MoodleGPT 1.1.4](#moodlegpt-114)
|
||||
- [Chrome Webstore](#chrome-webstore)
|
||||
- [Summary](#summary)
|
||||
- [Disclaimer !](#disclaimer-)
|
||||
- [Donate](#donate)
|
||||
- [Update](#update)
|
||||
- [Set up](#set-up)
|
||||
- [Mode](#mode)
|
||||
- [Settings](#settings)
|
||||
- [Advanced Settings](#advanced-settings)
|
||||
- [Mode](#mode)
|
||||
- [Options](#options)
|
||||
- [Internal other features](#internal-other-features)
|
||||
- [Support table](#support-table)
|
||||
- [Supported questions type](#supported-questions-type)
|
||||
@@ -61,6 +63,17 @@ See the [changelog](./CHANGELOG.md) to see every updates !
|
||||
|
||||
Go to <b>"Manage my extensions"</b> on your browser, then click on <b>"Load unpacked extension"</b> and select the <b>"extension"</b> folder. Afterwards, click on the extension icon and enter the ApiKey obtained from [openai api](https://platform.openai.com/api-keys). Finally, select a [gpt model](https://platform.openai.com/docs/models) (ensure it work with completion api).
|
||||
|
||||
## Settings
|
||||
|
||||
- <b>API KEY\*</b>: Your openai [API KEY](https://platform.openai.com/api-keys)
|
||||
- <b>GPT MODEL\*</b>: The [gpt model](https://platform.openai.com/docs/models) (you can click on the play button to ensure the model work with the extension)
|
||||
|
||||
## Advanced Settings
|
||||
|
||||
- <b>CODE</b>: A code you will need to type on your keyboard to inject/remove the extension code from the moodle page. It allow you to be more discret and control the injection so it's recommended.
|
||||
- <b>BASE URL</b>: The API endpoint if you need to use your own llm.
|
||||
- <b>MAX TOKENS</b>: The max tokens length you want the api to respond with.
|
||||
|
||||
## Mode
|
||||
|
||||
<p align="center">
|
||||
@@ -72,7 +85,7 @@ Go to <b>"Manage my extensions"</b> on your browser, then click on <b>"Load unpa
|
||||
- <b>Question to answer:</b> The question is converted to the answer and you can click on it to show back the question (or show back the answer).
|
||||
<br/><img src="./assets/question-to-answer.gif" alt="Question to Answer">
|
||||
|
||||
## Settings
|
||||
## Options
|
||||
|
||||
<p align="center">
|
||||
<img src="./assets/settings.png" alt="Popup" width="300">
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
const js = require('@eslint/js');
|
||||
const tsParser = require('@typescript-eslint/parser');
|
||||
const tsPlugin = require('@typescript-eslint/eslint-plugin');
|
||||
const prettierConfig = require('eslint-config-prettier');
|
||||
const tseslint = require('typescript-eslint');
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
ignores: ['**/node_modules/*', '**/dist/*', '**/*.js']
|
||||
},
|
||||
|
||||
js.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
|
||||
{
|
||||
files: ['**/*.ts'],
|
||||
languageOptions: {
|
||||
parser: tsParser,
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module'
|
||||
},
|
||||
plugins: {
|
||||
'@typescript-eslint': tsPlugin
|
||||
},
|
||||
rules: {
|
||||
...tsPlugin.configs['eslint-recommended'].rules,
|
||||
...tsPlugin.configs.recommended.rules,
|
||||
...prettierConfig.rules,
|
||||
'@typescript-eslint/no-explicit-any': 'off'
|
||||
}
|
||||
}
|
||||
];
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "MoodleGPT",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.4",
|
||||
"description": "Hidden chat-gpt for your moodle quiz",
|
||||
"permissions": ["storage"],
|
||||
"action": {
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
Generated
+1382
-1925
File diff suppressed because it is too large
Load Diff
+15
-12
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "moodlegpt",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.4",
|
||||
"description": "This extension allows you to hide CHAT-GPT in a Moodle quiz.",
|
||||
"scripts": {
|
||||
"build": "npm run prettier && npm run lint && npm run fastBuild",
|
||||
@@ -26,19 +26,22 @@
|
||||
},
|
||||
"homepage": "https://github.com/yoannchb-pro/MoodleGPT#readme",
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^28.0.2",
|
||||
"@eslint/js": "^9.32.0",
|
||||
"@rollup/plugin-commonjs": "^28.0.6",
|
||||
"@rollup/plugin-node-resolve": "^16.0.0",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"@rollup/plugin-typescript": "^12.1.2",
|
||||
"@types/chrome": "^0.0.294",
|
||||
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
||||
"@typescript-eslint/parser": "^7.2.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"openai": "^4.78.1",
|
||||
"prettier": "^3.2.5",
|
||||
"rollup": "^4.13.0",
|
||||
"@rollup/plugin-typescript": "^12.1.4",
|
||||
"@types/chrome": "^0.1.1",
|
||||
"@types/node": "^24.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
||||
"@typescript-eslint/parser": "^8.38.0",
|
||||
"eslint": "^9.32.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"openai": "^5.11.0",
|
||||
"prettier": "^3.6.2",
|
||||
"rollup": "^4.46.2",
|
||||
"rollup-plugin-ts": "^3.2.0",
|
||||
"typescript": "^5.4.2"
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.38.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ function createAndNormalizeQuestion(questionContainer: HTMLElement) {
|
||||
if (attoText) {
|
||||
question = question.replace((attoText as HTMLElement).innerText, '');
|
||||
}
|
||||
const clearMyChoice = questionContainer.querySelector('[role="button"]');
|
||||
if (clearMyChoice) question = question.replace((clearMyChoice as HTMLElement).innerText, '');
|
||||
|
||||
// Make tables more readable for chat-gpt
|
||||
const tables: NodeListOf<HTMLTableElement> = questionContainer.querySelectorAll('.qtext table');
|
||||
|
||||
@@ -3,7 +3,7 @@ import type GPTAnswer from '../types/gpt-answer';
|
||||
import normalizeText from 'background/utils/normalize-text';
|
||||
import getContentWithHistory from './get-content-with-history';
|
||||
import OpenAI from 'openai';
|
||||
import { fixeO1 } from '../utils/fixe-o1';
|
||||
import { fixeO } from '../utils/fixe-o';
|
||||
|
||||
/**
|
||||
* Get the response from chatGPT api
|
||||
@@ -25,18 +25,19 @@ async function getChatGPTResponse(
|
||||
|
||||
const client = new OpenAI({
|
||||
apiKey: config.apiKey,
|
||||
baseURL: config.baseURL,
|
||||
dangerouslyAllowBrowser: true
|
||||
});
|
||||
|
||||
const req = await client.chat.completions.create(
|
||||
fixeO1(config.model, {
|
||||
fixeO(config.model, {
|
||||
model: config.model,
|
||||
messages: contentHandler.messages,
|
||||
|
||||
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 // Maximum length of the response,
|
||||
}),
|
||||
{ signal: config.timeout ? controller.signal : null }
|
||||
);
|
||||
|
||||
@@ -12,6 +12,8 @@ type Config = {
|
||||
history?: boolean;
|
||||
includeImages?: boolean;
|
||||
mode?: 'autocomplete' | 'question-to-answer' | 'clipboard';
|
||||
baseURL?: string;
|
||||
maxTokens?: number;
|
||||
};
|
||||
|
||||
export default Config;
|
||||
|
||||
@@ -6,8 +6,8 @@ import { ChatCompletionCreateParamsNonStreaming } from 'openai/resources/chat/co
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
export function fixeO1(model: string, data: ChatCompletionCreateParamsNonStreaming) {
|
||||
if (!model.startsWith('o1')) return data;
|
||||
export function fixeO(model: string, data: ChatCompletionCreateParamsNonStreaming) {
|
||||
if (model.search(/^o\d+/gi) === -1) return data;
|
||||
|
||||
if (data.max_tokens) {
|
||||
data.max_completion_tokens = data.max_tokens;
|
||||
@@ -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
|
||||
});
|
||||
|
||||
@@ -38,7 +40,9 @@ export async function populateDatalistWithGptVersions() {
|
||||
|
||||
const models = rep.data.filter(
|
||||
model =>
|
||||
model.id.startsWith('gpt') || model.id.startsWith('o1') || model.id.startsWith('chatgpt')
|
||||
model.id.startsWith('gpt') ||
|
||||
model.id.search(/^o\d+/gi) !== -1 ||
|
||||
model.id.startsWith('chatgpt')
|
||||
);
|
||||
models.sort((a, b) => b.id.localeCompare(a.id)); // we sort the model to get the best chatgpt version first
|
||||
|
||||
@@ -61,9 +65,11 @@ 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 });
|
||||
showMessage({ msg: 'Checking GPT version...', isInfinite: true, isError: false });
|
||||
const client = new OpenAI({ apiKey, baseURL, dangerouslyAllowBrowser: true });
|
||||
await client.chat.completions.create({
|
||||
model,
|
||||
messages: [{ role: 'user', content: 'reply just pong' }]
|
||||
|
||||
+4
-2
@@ -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,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const CURRENT_VERSION = '1.1.2';
|
||||
const CURRENT_VERSION = '1.1.4';
|
||||
const versionDisplay = document.querySelector('#version')!;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user