mirror of
https://github.com/ittuann/obsidian-gpt-liteinquirer-plugin.git
synced 2026-07-22 07:40:27 +00:00
update CI
This commit is contained in:
parent
6f54158a31
commit
d42b0db42e
6 changed files with 101 additions and 33 deletions
37
.github/workflows/CI.yml
vendored
Normal file
37
.github/workflows/CI.yml
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["master"]
|
||||
pull_request:
|
||||
branches: ["master"]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js 14.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 14.x
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
40
.github/workflows/CodeQL.yml
vendored
Normal file
40
.github/workflows/CodeQL.yml
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
code-scanning:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
security-events: write
|
||||
actions: read
|
||||
contents: read
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: typescript
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
||||
- name: Microsoft Inclusiveness Analyzer
|
||||
uses: microsoft/InclusivenessAnalyzer@main
|
||||
with:
|
||||
excludeFiles: "**/package-lock.json"
|
||||
|
||||
20
.github/workflows/build.yml
vendored
20
.github/workflows/build.yml
vendored
|
|
@ -1,20 +0,0 @@
|
|||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["master"]
|
||||
pull_request:
|
||||
branches: ["master"]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 14
|
||||
- run: npm install
|
||||
- run: npm run lint
|
||||
- run: npm run build
|
||||
7
CHANGELOG.md
Normal file
7
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Change Log
|
||||
|
||||
All notable changes to the plugin will be documented in this file.
|
||||
|
||||
## [1.0.0]
|
||||
|
||||
- Initial release
|
||||
15
main.js
15
main.js
|
|
@ -53,7 +53,7 @@ var LightweightChatGPTPlugin = class extends import_obsidian.Plugin {
|
|||
name: "Open Lightweight Window",
|
||||
callback: () => {
|
||||
try {
|
||||
new LightweightChatGPTWindow(this.app, this.settings.apiKey, this.settings.temperature, this.settings.maxTokens, this.settings.insertionMode).open();
|
||||
new LightweightChatGPTWindow(this.app, this.settings.apiKey, this.settings.temperature, this.settings.maxTokens, this.settings.chatGPTModel, this.settings.insertionMode).open();
|
||||
} catch (error) {
|
||||
console.error("Error opening Lightweight ChatGPT Plugin Window:", error);
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ var LightweightChatGPTPlugin = class extends import_obsidian.Plugin {
|
|||
try {
|
||||
this.ribbonIconEl = this.addRibbonIcon("feather", "GPT-LiteInquirer", (evt) => {
|
||||
try {
|
||||
new LightweightChatGPTWindow(this.app, this.settings.apiKey, this.settings.temperature, this.settings.maxTokens, this.settings.insertionMode).open();
|
||||
new LightweightChatGPTWindow(this.app, this.settings.apiKey, this.settings.temperature, this.settings.maxTokens, this.settings.chatGPTModel, this.settings.insertionMode).open();
|
||||
} catch (error) {
|
||||
console.error("Error opening Lightweight ChatGPT Plugin Window:", error);
|
||||
}
|
||||
|
|
@ -83,7 +83,6 @@ var LightweightChatGPTPlugin = class extends import_obsidian.Plugin {
|
|||
} catch (error) {
|
||||
console.error("Error adding sidebar icon:", error);
|
||||
}
|
||||
this.ribbonIconEl.addClass("lightweight-chatgpt-ribbon-class");
|
||||
}
|
||||
removeSidebarIcon() {
|
||||
if (this.ribbonIconEl) {
|
||||
|
|
@ -104,11 +103,12 @@ var LightweightChatGPTPlugin = class extends import_obsidian.Plugin {
|
|||
}
|
||||
};
|
||||
var LightweightChatGPTWindow = class extends import_obsidian.Modal {
|
||||
constructor(app, apiKey, temperature, maxTokens, insertionMode) {
|
||||
constructor(app, apiKey, temperature, maxTokens, chatGPTModel, insertionMode) {
|
||||
super(app);
|
||||
this.apiKey = apiKey;
|
||||
this.temperature = temperature;
|
||||
this.maxTokens = maxTokens;
|
||||
this.chatGPTModel = chatGPTModel;
|
||||
this.insertionMode = insertionMode;
|
||||
}
|
||||
onOpen() {
|
||||
|
|
@ -218,18 +218,19 @@ var LightweightChatGPTWindow = class extends import_obsidian.Modal {
|
|||
}
|
||||
this.outputContainer.empty();
|
||||
new import_obsidian.Notice("Sending...");
|
||||
const apiUrl = "https://api.openai.com/v1/chat/completions";
|
||||
const apiUrl = "https://api.openai.com";
|
||||
const apiUrlPatch = "/v1/chat/completions";
|
||||
const maxTokens = parseInt(this.maxTokensInput.value);
|
||||
try {
|
||||
const response = await (0, import_obsidian.request)({
|
||||
url: apiUrl,
|
||||
url: apiUrl + apiUrlPatch,
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${this.apiKey}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: "gpt-3.5-turbo",
|
||||
model: this.chatGPTModel,
|
||||
max_tokens: maxTokens,
|
||||
temperature: this.temperature,
|
||||
messages: [
|
||||
|
|
|
|||
15
main.ts
15
main.ts
|
|
@ -52,7 +52,7 @@ export default class LightweightChatGPTPlugin extends Plugin {
|
|||
name: 'Open Lightweight Window',
|
||||
callback: () => {
|
||||
try {
|
||||
new LightweightChatGPTWindow(this.app, this.settings.apiKey, this.settings.temperature, this.settings.maxTokens, this.settings.insertionMode).open();
|
||||
new LightweightChatGPTWindow(this.app, this.settings.apiKey, this.settings.temperature, this.settings.maxTokens, this.settings.chatGPTModel, this.settings.insertionMode).open();
|
||||
} catch (error) {
|
||||
console.error('Error opening Lightweight ChatGPT Plugin Window:', error);
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ export default class LightweightChatGPTPlugin extends Plugin {
|
|||
try {
|
||||
this.ribbonIconEl = this.addRibbonIcon('feather', 'GPT-LiteInquirer', (evt: MouseEvent) => {
|
||||
try {
|
||||
new LightweightChatGPTWindow(this.app, this.settings.apiKey, this.settings.temperature, this.settings.maxTokens, this.settings.insertionMode).open();
|
||||
new LightweightChatGPTWindow(this.app, this.settings.apiKey, this.settings.temperature, this.settings.maxTokens, this.settings.chatGPTModel, this.settings.insertionMode).open();
|
||||
} catch (error) {
|
||||
console.error('Error opening Lightweight ChatGPT Plugin Window:', error);
|
||||
}
|
||||
|
|
@ -131,12 +131,14 @@ class LightweightChatGPTWindow extends Modal {
|
|||
private maxTokens: number;
|
||||
private responseAPIText: string;
|
||||
private insertionMode: string;
|
||||
private chatGPTModel: string;
|
||||
|
||||
constructor(app: App, apiKey: string, temperature: number, maxTokens: number, insertionMode: string) {
|
||||
constructor(app: App, apiKey: string, temperature: number, maxTokens: number, chatGPTModel: string, insertionMode: string) {
|
||||
super(app);
|
||||
this.apiKey = apiKey;
|
||||
this.temperature = temperature;
|
||||
this.maxTokens = maxTokens;
|
||||
this.chatGPTModel = chatGPTModel;
|
||||
this.insertionMode = insertionMode;
|
||||
}
|
||||
|
||||
|
|
@ -273,18 +275,19 @@ class LightweightChatGPTWindow extends Modal {
|
|||
this.outputContainer.empty();
|
||||
|
||||
new Notice('Sending...');
|
||||
const apiUrl = 'https://api.openai.com/v1/chat/completions';
|
||||
const apiUrl = 'https://api.openai.com';
|
||||
const apiUrlPatch = '/v1/chat/completions'
|
||||
const maxTokens = parseInt(this.maxTokensInput.value);
|
||||
try {
|
||||
const response = await request({
|
||||
url: apiUrl,
|
||||
url: apiUrl + apiUrlPatch,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${this.apiKey}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: 'gpt-3.5-turbo',
|
||||
model: this.chatGPTModel,
|
||||
max_tokens: maxTokens,
|
||||
temperature: this.temperature,
|
||||
messages: [
|
||||
|
|
|
|||
Loading…
Reference in a new issue