Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ ts-gen
out/
end-to-end/dist
.yarn/install-state.gz
tsconfig.tsbuildinfo
9 changes: 9 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"trailingComma": "all",
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"sortPackageJson": false,
"ignorePatterns": ["*.md", "*.yml", "*.yaml"]
}
10 changes: 10 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["eslint", "typescript", "unicorn", "oxc", "import"],
"categories": {
"correctness": "warn"
},
"options": {
"typeAware": true
}
}
3 changes: 0 additions & 3 deletions .prettierrc.json

This file was deleted.

15 changes: 5 additions & 10 deletions __tests__/language-model.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { describe, it, expect, vi } from 'vitest';
import { LanguageModel } from '../src/language-model.js';
import {
LanguageModelPromptRole,
LanguageModelPromptType,
} from '../src/interfaces.js';
import { LanguageModelPromptRole, LanguageModelPromptType } from '../src/interfaces.js';

vi.mock('node-llama-cpp', () => {
return {
getLlama: async () => {
return {
loadModel: async ({ modelPath }: { modelPath: string }) => {
loadModel: async ({ modelPath: _modelPath }: { modelPath: string }) => {
return {
createContext: async () => {
return {
Expand All @@ -25,7 +22,7 @@ vi.mock('node-llama-cpp', () => {
constructor({ contextSequence }: { contextSequence: string }) {
this.contextSequence = contextSequence;
}
async prompt(input: string, options?: any): Promise<string> {
async prompt(input: string, _options?: any): Promise<string> {
return `Mocked response to: ${input}`;
}
},
Expand Down Expand Up @@ -66,7 +63,7 @@ describe('LanguageModel with mocks', () => {
};

// mock streaming behaviour
model.promptStreaming = (payload, options) => {
model.promptStreaming = (_payload, _options) => {
return new ReadableStream({
start(controller) {
controller.enqueue('chunk1 ');
Expand Down Expand Up @@ -100,8 +97,6 @@ describe('LanguageModel with mocks', () => {
content: 'This should fail.',
};

await expect(model.prompt(promptPayload)).rejects.toThrow(
'NotSupportedError',
);
await expect(model.prompt(promptPayload)).rejects.toThrow('NotSupportedError');
});
});
4 changes: 1 addition & 3 deletions __tests__/preload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ describe('Preload Interface', () => {

it('destroy should invoke with correct ipcMessage', async () => {
await (globalThis as any).electronAi.destroy();
expect(ipcRenderer.invoke).toHaveBeenCalledWith(
IpcRendererMessage.ELECTRON_LLM_DESTROY,
);
expect(ipcRenderer.invoke).toHaveBeenCalledWith(IpcRendererMessage.ELECTRON_LLM_DESTROY);
});

it('prompt should invoke with correct params', async () => {
Expand Down
Loading