Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enchanced prompts and other minor changes #39

Merged
merged 1 commit into from
Sep 11, 2024
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
12 changes: 8 additions & 4 deletions src/docFillerCore/engines/fillerEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,12 @@ export class FillerEngine {
return true;
}

private fillDuration(fieldValue: ExtractedValue, value: string): boolean {
const [hours, minutes, seconds] = value.split('-');
private fillDuration(fieldValue: ExtractedValue, value: Date): boolean {
if (!(value instanceof Date)) return false;
const hours = value.getUTCHours().toString();
const minutes = value.getUTCMinutes().toString();
const seconds = value.getUTCSeconds().toString();

const inputEvent = new Event('input', { bubbles: true });

if (fieldValue.hour) {
Expand Down Expand Up @@ -535,7 +539,7 @@ export class FillerEngine {
}
}
// For Other option
else if (option.isOther && option.otherOptionValue) {
if (option.isOther && option.otherOptionValue) {
if (fieldValue.other?.dom?.getAttribute('aria-checked') !== 'true') {
fieldValue.other?.dom?.dispatchEvent(
new Event('click', { bubbles: true })
Expand Down Expand Up @@ -592,7 +596,7 @@ export class FillerEngine {

private async fillLinearScale(
fieldValue: ExtractedValue,
value: GenericLLMResponse
value: LinearScaleResponse
): Promise<boolean> {
await sleep(SLEEP_DURATION);
for (const index in fieldValue.options) {
Expand Down
16 changes: 11 additions & 5 deletions src/docFillerCore/engines/gptEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,25 @@ export class LLMEngine {
case QType.DATE:
case QType.TIME:
case QType.DATE_AND_TIME:
case QType.DURATION:
case QType.DATE_TIME_WITHOUT_YEAR:
case QType.DATE_TIME_WITH_MERIDIEM:
case QType.DATE_TIME_WITH_MERIDIEM_WITHOUT_YEAR:
case QType.DATE_WITHOUT_YEAR:
case QType.TIME_WITH_MERIDIEM:
case QType.DURATION:
return new DatetimeOutputParser();

case QType.LINEAR_SCALE:
return StructuredOutputParser.fromNamesAndDescriptions({
answer:
"The integer answer to the user's question as the key corresponding to the calculated answer",
});
return StructuredOutputParser.fromZodSchema(
z.object({
answer: z
.number()
.describe(
"The integer answer to the user's question as the key corresponding to the calculated answer"
),
})
);

case QType.DROPDOWN:
return StructuredOutputParser.fromNamesAndDescriptions({
answer: "answer to the user's question",
Expand Down
Loading