-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2308918
commit b14085a
Showing
13 changed files
with
377 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { | ||
OpenAIService, | ||
OpenAIProviderService, | ||
AIJobMatcherService, | ||
} from './services'; | ||
|
||
@Module({ | ||
providers: [OpenAIProviderService, OpenAIService, AIJobMatcherService], | ||
exports: [AIJobMatcherService], | ||
}) | ||
export class AIModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './ai.interface'; | ||
export * from './ai.interface'; |
47 changes: 47 additions & 0 deletions
47
apps/backend/src/modules/ai/services/ai-boolean-outcome.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
import { AssociativeObject, BooleanOutcome, GPTResult } from '../interfaces'; | ||
import { AIService } from './ai.service'; | ||
|
||
@Injectable() | ||
export abstract class GPTBooleanOutcomeService extends AIService { | ||
async handle(input: AssociativeObject): Promise<BooleanOutcome> { | ||
const result = await this.getResult(input); | ||
|
||
return this.getOutcomeFromResult(result); | ||
} | ||
|
||
protected getOutcomeFromResult( | ||
result: GPTResult | Error | null, | ||
): BooleanOutcome { | ||
if (result instanceof Error) { | ||
return { | ||
outcome: false, | ||
metadata: { comment: result.message }, | ||
}; | ||
} | ||
|
||
if (!result) { | ||
return { | ||
outcome: false, | ||
metadata: { comment: 'No data in response' }, | ||
}; | ||
} | ||
|
||
const { data, notes } = result; | ||
const comment = (data.comment as string) ?? ''; | ||
|
||
return { | ||
metadata: { data, comment, notes }, | ||
...this.getBooleanOutcomeFromResult(result), | ||
}; | ||
} | ||
|
||
protected defaultOutcome(): boolean { | ||
return false; | ||
} | ||
|
||
protected abstract getBooleanOutcomeFromResult( | ||
result: GPTResult, | ||
): Pick<BooleanOutcome, 'outcome'> & Partial<BooleanOutcome>; | ||
} |
47 changes: 47 additions & 0 deletions
47
apps/backend/src/modules/ai/services/ai-data-outcome.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
import { AssociativeObject, DataOutcome, GPTResult } from '../interfaces'; | ||
import { AIService } from './ai.service'; | ||
|
||
@Injectable() | ||
export abstract class AIDataOutcomeService extends AIService { | ||
async handle(input: AssociativeObject): Promise<DataOutcome> { | ||
const result = await this.getResult(input); | ||
|
||
return this.getOutcomeFromResult(result); | ||
} | ||
|
||
protected getOutcomeFromResult( | ||
result: GPTResult | Error | null, | ||
): DataOutcome { | ||
if (result instanceof Error) { | ||
return { | ||
data: this.defaultData(), | ||
metadata: { comment: result.message }, | ||
}; | ||
} | ||
|
||
if (!result) { | ||
return { | ||
data: this.defaultData(), | ||
metadata: { comment: 'No data in response' }, | ||
}; | ||
} | ||
|
||
const { data, notes } = result; | ||
const comment = (data.comment as string) ?? ''; | ||
|
||
return { | ||
metadata: { data, comment, notes }, | ||
...this.getDataOutcomeFromResult(result), | ||
}; | ||
} | ||
|
||
protected defaultData(): unknown { | ||
return null; | ||
} | ||
|
||
protected abstract getDataOutcomeFromResult( | ||
result: GPTResult, | ||
): Pick<DataOutcome, 'data'> & Partial<DataOutcome>; | ||
} |
Oops, something went wrong.