Skip to content

Commit

Permalink
fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Jan 17, 2024
1 parent 2f91e98 commit 881c8c0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 37 deletions.
37 changes: 17 additions & 20 deletions packages/backend/src/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { ModelResponse } from '@shared/src/models/IModelResponse';
import path from 'node:path';
import * as http from 'node:http';
import { getFreePort } from './utils/ports';
import { QueryState } from '@shared/models/IPlaygroundQueryState';
import type { QueryState } from '@shared/src/models/IPlaygroundQueryState';
import { MSG_NEW_PLAYGROUND_QUERIES_STATE } from '@shared/Messages';

const LOCALAI_IMAGE = 'quay.io/go-skynet/local-ai:v2.5.1';
Expand Down Expand Up @@ -115,13 +115,13 @@ export class PlayGroundManager {
prompt: prompt,
} as QueryState;

let post_data = JSON.stringify({
const post_data = JSON.stringify({
model: modelInfo.file,
prompt: prompt,
temperature: 0.7,
});

let post_options: http.RequestOptions = {
const post_options: http.RequestOptions = {
host: 'localhost',
port: '' + state.port,
path: '/v1/completions',
Expand All @@ -131,24 +131,21 @@ export class PlayGroundManager {
},
};

let post_req = http.request(post_options, res => {
const post_req = http.request(post_options, res => {
res.setEncoding('utf8');
const chunks = [];
res.on('data', data => chunks.push(data));
res.on('end', () => {
let resBody = chunks.join();
switch (res.headers['content-type']) {
case 'application/json':
const result = JSON.parse(resBody);
console.log('result', result);
const q = this.queries.get(query.id);
if (!q) {
throw new Error('query not found in state');
}
q.response = result as ModelResponse;
this.queries.set(query.id, q);
this.sendState();
break;
res.on('end', async () => {

Check failure on line 138 in packages/backend/src/playground.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / windows-2022

Promise returned in function argument where a void return was expected

Check failure on line 138 in packages/backend/src/playground.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / ubuntu-22.04

Promise returned in function argument where a void return was expected

Check failure on line 138 in packages/backend/src/playground.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / macos-12

Promise returned in function argument where a void return was expected
const resBody = chunks.join();
if (res.headers['content-type'] === 'application/json') {
const result = JSON.parse(resBody);
const q = this.queries.get(query.id);
if (!q) {
throw new Error('query not found in state');
}
q.response = result as ModelResponse;
this.queries.set(query.id, q);
await this.sendState();
}
});
});
Expand All @@ -157,7 +154,7 @@ export class PlayGroundManager {
post_req.end();

this.queries.set(query.id, query);
this.sendState();
await this.sendState();
return query.id;
}

Expand All @@ -167,7 +164,7 @@ export class PlayGroundManager {
getState(): QueryState[] {
return Array.from(this.queries.values());
}
sendState() {
async sendState() {
this.webview.postMessage({

Check failure on line 168 in packages/backend/src/playground.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / windows-2022

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check failure on line 168 in packages/backend/src/playground.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / ubuntu-22.04

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check failure on line 168 in packages/backend/src/playground.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / macos-12

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
id: MSG_NEW_PLAYGROUND_QUERIES_STATE,
body: this.getState(),
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/studio-api-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { Task } from '@shared/src/models/ITask';
import * as path from 'node:path';
import type { PlayGroundManager } from './playground';
import * as podmanDesktopApi from '@podman-desktop/api';
import { QueryState } from '@shared/models/IPlaygroundQueryState';
import type { QueryState } from '@shared/src/models/IPlaygroundQueryState';

export const RECENT_CATEGORY_ID = 'recent-category';

Expand Down
5 changes: 2 additions & 3 deletions packages/frontend/src/stores/playground-queries.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { Readable } from 'svelte/store';
import { readable } from 'svelte/store';
import type { QueryState } from '@shared/models/IPlaygroundQueryState';
import { rpcBrowser } from '../utils/client';
import type { QueryState } from '@shared/src/models/IPlaygroundQueryState';
import { MSG_NEW_PLAYGROUND_QUERIES_STATE } from '@shared/Messages';
import { studioClient } from '/@/utils/client';
import { rpcBrowser, studioClient } from '/@/utils/client';

export const playgroundQueries: Readable<QueryState[]> = readable<QueryState[]>([], set => {
const sub = rpcBrowser.subscribe(MSG_NEW_PLAYGROUND_QUERIES_STATE, msg => {
Expand Down
11 changes: 0 additions & 11 deletions packages/shared/models/IRecipe.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/shared/src/StudioAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Category } from './models/ICategory';
import type { RecipeStatus } from './models/IRecipeStatus';
import type { ModelInfo } from './models/IModelInfo';
import type { Task } from './models/ITask';
import { QueryState } from './models/IPlaygroundQueryState';
import type { QueryState } from './models/IPlaygroundQueryState';

export abstract class StudioAPI {
abstract ping(): Promise<string>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModelResponse } from "./IModelResponse";
import type { ModelResponse } from './IModelResponse';

export interface QueryState {
id: number;
Expand Down

0 comments on commit 881c8c0

Please sign in to comment.