Skip to content

Commit 728613c

Browse files
committed
chore: lint files
1 parent de2f5fa commit 728613c

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed

langchain-core/src/prompt_values.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,13 @@ export class GenericObjectPromptValue extends BasePromptValue {
199199
/** @ignore */
200200
value: string;
201201

202-
203202
constructor(fields: GenericObjectPromptValueFields) {
204203
super(fields);
205204
this.data = fields.data;
206205
}
207206

208207
toString() {
209-
return JSON.stringify(this.data, null, 2)
208+
return JSON.stringify(this.data, null, 2);
210209
}
211210

212211
toChatMessages() {
@@ -221,4 +220,4 @@ export class GenericObjectPromptValue extends BasePromptValue {
221220
}),
222221
];
223222
}
224-
}
223+
}

langchain-core/src/prompts/chat.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ interface _ImageTemplateParam {
347347

348348
interface _GenericObjectTemplateParam {
349349
// eslint-disable-next-line @typescript-eslint/no-explicit-any
350-
data: Record<string, any>;
350+
data: Record<string, any>;
351351
}
352352

353353
type MessageClass =
@@ -465,14 +465,23 @@ class _StringImageMessagePromptTemplate<
465465
}
466466

467467
static fromTemplate(
468-
template: string | Array<string | _TextTemplateParam | _ImageTemplateParam | _GenericObjectTemplateParam>,
468+
template:
469+
| string
470+
| Array<
471+
| string
472+
| _TextTemplateParam
473+
| _ImageTemplateParam
474+
| _GenericObjectTemplateParam
475+
>,
469476
additionalOptions?: Record<string, unknown>
470477
) {
471478
if (typeof template === "string") {
472479
return new this(PromptTemplate.fromTemplate(template));
473480
}
474481
const prompt: Array<
475-
PromptTemplate<InputValues> | ImagePromptTemplate<InputValues> | GenericObjectPromptTemplate<InputValues>
482+
| PromptTemplate<InputValues>
483+
| ImagePromptTemplate<InputValues>
484+
| GenericObjectPromptTemplate<InputValues>
476485
> = [];
477486
for (const item of template) {
478487
if (
@@ -531,7 +540,12 @@ class _StringImageMessagePromptTemplate<
531540
prompt.push(imgTemplateObject);
532541
} else if (typeof item === "object" && "data" in item) {
533542
const genericTemplate = item.data;
534-
prompt.push(new GenericObjectPromptTemplate<InputValues>({ template: genericTemplate, inputVariables: [] }));
543+
prompt.push(
544+
new GenericObjectPromptTemplate<InputValues>({
545+
template: genericTemplate,
546+
inputVariables: [],
547+
})
548+
);
535549
}
536550
}
537551
return new this({ prompt, additionalOptions });
@@ -577,7 +591,7 @@ class _StringImageMessagePromptTemplate<
577591
const formatted = await prompt.format(
578592
inputs as TypedPromptInputValues<RunInput>
579593
);
580-
console.log("formatted", formatted)
594+
console.log("formatted", formatted);
581595
content.push({ type: "generic", data: formatted });
582596
}
583597
}
@@ -726,7 +740,12 @@ function _coerceMessagePromptTemplateLike(
726740
const message = coerceMessageLikeToMessage(messagePromptTemplateLike);
727741
let templateData:
728742
| string
729-
| (string | _TextTemplateParam | _ImageTemplateParam | _GenericObjectTemplateParam)[];
743+
| (
744+
| string
745+
| _TextTemplateParam
746+
| _ImageTemplateParam
747+
| _GenericObjectTemplateParam
748+
)[];
730749

731750
if (typeof message.content === "string") {
732751
templateData = message.content;
@@ -740,9 +759,7 @@ function _coerceMessagePromptTemplateLike(
740759
} else if ("data" in item) {
741760
return { data: item.data };
742761
} else {
743-
throw new Error(
744-
"Invalid message content"
745-
);
762+
throw new Error("Invalid message content");
746763
}
747764
});
748765
}

langchain-core/src/prompts/generic_object.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ export class GenericObjectPromptTemplate<
6262

6363
validateTemplate = true;
6464

65-
constructor(input: GenericObjectPromptTemplateInput<RunInput, PartialVariableName>) {
65+
constructor(
66+
input: GenericObjectPromptTemplateInput<RunInput, PartialVariableName>
67+
) {
6668
super(input);
6769
this.template = input.template;
6870
this.templateFormat = input.templateFormat ?? this.templateFormat;
@@ -76,9 +78,7 @@ export class GenericObjectPromptTemplate<
7678
);
7779
}
7880
checkValidTemplate(
79-
[
80-
{ type: "generic", data: this.template },
81-
] as unknown as MessageContent,
81+
[{ type: "generic", data: this.template }] as unknown as MessageContent,
8282
this.templateFormat,
8383
totalInputVariables
8484
);

langchain-core/src/prompts/tests/chat.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ test("Multi-modal, multi part chat prompt works with instances of BaseMessage",
570570
});
571571

572572
test.only("Gemini can understand audio", async () => {
573-
const audioBase64 = `fs.readFileSync(audioPath, "base64");`
573+
const audioBase64 = `fs.readFileSync(audioPath, "base64");`;
574574

575575
const prompt = ChatPromptTemplate.fromMessages([
576576
[
@@ -591,5 +591,5 @@ test.only("Gemini can understand audio", async () => {
591591
]);
592592

593593
const pInvoke = await prompt.invoke({});
594-
console.log(JSON.stringify(pInvoke, null, 2))
595-
});
594+
console.log(JSON.stringify(pInvoke, null, 2));
595+
});

libs/langchain-google-common/src/utils/gemini.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function messageContentToAudio(
8787
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8888
content: Record<string, any>
8989
): GeminiPartInlineData | GeminiPartFileData {
90-
const {url} = content.data;
90+
const { url } = content.data;
9191

9292
if (!url) {
9393
throw new Error("Missing Audio URL");

0 commit comments

Comments
 (0)