mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2026-03-22 07:29:35 +08:00
refactor: agent schema
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
import {z} from "zod";
|
import {z} from "zod";
|
||||||
import {ObjectGeneratorSafe} from "./safe-generator";
|
import {ObjectGeneratorSafe} from "./safe-generator";
|
||||||
import {EvaluationType} from "../types";
|
import {EvaluationType, PromptPair} from "../types";
|
||||||
|
|
||||||
export const MAX_URLS_PER_STEP = 2
|
export const MAX_URLS_PER_STEP = 2
|
||||||
export const MAX_QUERIES_PER_STEP = 5
|
export const MAX_QUERIES_PER_STEP = 5
|
||||||
export const MAX_REFLECT_PER_STEP = 3
|
export const MAX_REFLECT_PER_STEP = 3
|
||||||
|
|
||||||
function getLanguagePrompt(question: string) {
|
function getLanguagePrompt(question: string): PromptPair {
|
||||||
return `Identifies both the language used and the overall vibe of the question
|
return {system:`Identifies both the language used and the overall vibe of the question
|
||||||
|
|
||||||
<rules>
|
<rules>
|
||||||
Combine both language and emotional vibe in a descriptive phrase, considering:
|
Combine both language and emotional vibe in a descriptive phrase, considering:
|
||||||
@@ -53,10 +53,8 @@ Evaluation: {
|
|||||||
"langCode": "en",
|
"langCode": "en",
|
||||||
"languageStyle": "casual English"
|
"languageStyle": "casual English"
|
||||||
}
|
}
|
||||||
</examples>
|
</examples>`,
|
||||||
|
user: question};
|
||||||
Now evaluate this question:
|
|
||||||
${question}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Schemas {
|
export class Schemas {
|
||||||
@@ -66,11 +64,13 @@ export class Schemas {
|
|||||||
|
|
||||||
async setLanguage(query: string) {
|
async setLanguage(query: string) {
|
||||||
const generator = new ObjectGeneratorSafe();
|
const generator = new ObjectGeneratorSafe();
|
||||||
|
const prompt = getLanguagePrompt(query.slice(0, 100))
|
||||||
|
|
||||||
const result = await generator.generateObject({
|
const result = await generator.generateObject({
|
||||||
model: 'evaluator',
|
model: 'evaluator',
|
||||||
schema: this.getLanguageSchema(),
|
schema: this.getLanguageSchema(),
|
||||||
prompt: getLanguagePrompt(query.slice(0, 100)),
|
system: prompt.system,
|
||||||
|
prompt: prompt.user
|
||||||
});
|
});
|
||||||
|
|
||||||
this.languageCode = result.object.langCode;
|
this.languageCode = result.object.langCode;
|
||||||
|
|||||||
Reference in New Issue
Block a user