Skip to content

Commit

Permalink
chore: reformat and add types
Browse files Browse the repository at this point in the history
  • Loading branch information
hiro-v committed Jan 23, 2024
1 parent fe1baed commit 17479e7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions extensions/inference-nitro-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,17 @@ export default class JanInferenceNitroExtension extends InferenceExtension {
this.onMessageRequest(data)
);

events.on(ModelEvent.OnModelInit, (model: Model) => this.onModelInit(model));
events.on(ModelEvent.OnModelInit, (model: Model) =>
this.onModelInit(model)
);

events.on(ModelEvent.OnModelStop, (model: Model) => this.onModelStop(model));
events.on(ModelEvent.OnModelStop, (model: Model) =>
this.onModelStop(model)
);

events.on(InferenceEvent.OnInferenceStopped, () => this.onInferenceStopped());
events.on(InferenceEvent.OnInferenceStopped, () =>
this.onInferenceStopped()
);

// Attempt to fetch nvidia info
await executeOnMain(NODE, "updateNvidiaInfo", {});
Expand Down Expand Up @@ -200,11 +206,11 @@ export default class JanInferenceNitroExtension extends InferenceExtension {
if (!this._currentModel) return Promise.reject("No model loaded");

requestInference(data.messages ?? [], this._currentModel).subscribe({
next: (_content) => {},
next: (_content: any) => {},
complete: async () => {
resolve(message);
},
error: async (err) => {
error: async (err: any) => {
reject(err);
},
});
Expand Down Expand Up @@ -245,7 +251,7 @@ export default class JanInferenceNitroExtension extends InferenceExtension {
...(data.model || {}),
};
requestInference(data.messages ?? [], model, this.controller).subscribe({
next: (content) => {
next: (content: any) => {
const messageContent: ThreadContent = {
type: ContentType.Text,
text: {
Expand All @@ -262,7 +268,7 @@ export default class JanInferenceNitroExtension extends InferenceExtension {
: MessageStatus.Error;
events.emit(MessageEvent.OnMessageUpdate, message);
},
error: async (err) => {
error: async (err: any) => {
if (this.isCancelled || message.content.length) {
message.status = MessageStatus.Stopped;
events.emit(MessageEvent.OnMessageUpdate, message);
Expand Down

0 comments on commit 17479e7

Please sign in to comment.