Untitled

 avatar
unknown
plain_text
5 days ago
3.8 kB
2
Indexable
class Focusing {
  constructor(builder) {
    this.builder = builder;
  }

  async getTerms(jsonData) {
    let systemCmd = `
        You are an expert in book titled {%TITLE%}. This conversation aims to getting information.`;

    let context = `
Book information:

Subtitle: {%SUBTITLE%}
Summary to Expertise: {%SUMMARY%}
About the author: {%AUTHOR%}
`;

    let question = `
We have a book with the following details:

Title of the book: {%TITLE%}
Subtitle of the book: {%SUBTITLE%}
About the author: {%AUTHOR%}

First, list each of the products/services/packages offered by the book based on the provided information.
Give direct answer. No talk. Start with number 1.

Second, based on summary: {%SUMMARY%}, and the profile information provided, 
list specific terms (e.g., tools, frameworks, technical skills, expertise, or qualities) used in business/portfolio websites from the fields and similar to the provided profile information. 
Provide at least 20 terms. Provide answers only. No talk. Start with number 1.

Example: if the book provides informations about Fullstack Web Development services, include in the list: React, Microservices, Cloud.
Basically you have to list specific terms to reflect that the company is expert in the fields.
`;

    systemCmd = systemCmd.replaceAll("{%TITLE%}", jsonData.title);

    context = context.replaceAll("{%SUBTITLE%}", jsonData.subtitle);
    context = context.replaceAll("{%SUMMARY%}", jsonData.summary);
    context = context.replaceAll("{%AUTHOR%}", jsonData.author);

    question = question.replaceAll("{%TITLE%}", jsonData.title);
    question = question.replaceAll("{%SUBTITLE%}", jsonData.subtitle);
    question = question.replaceAll("{%AUTHOR%}", jsonData.author);
    question = question.replaceAll(
      "{%SUMMARY%}",
      jsonData.summary ? jsonData.summary : "-"
    );

    let response = await this.builder.send(
      "write",
      question,
      context,
      systemCmd,
      this.getFunctions(jsonData.summary)
    );
    let args = JSON.parse(response);
    let json = {
      products_or_services: args.products_or_services,
      common_terms: args.common_terms,
    };

    if (this.builder.consoleLog) console.log(json.common_terms);

    return json;
  }

  getFunctions(fields) {
    return [
      {
        name: "write_website_content",
        description:
          "Write content for website for 3 sections: Hero section, Products or Services section & About section.",
        parameters: {
          type: "object",
          properties: {
            products_or_services: {
              type: "string",
              description: `Give me a list of the products/services offered by the client based on the provided information. 
                            Give direct answer. No talk. Start with number 1.`,
            },
            common_terms: {
              type: "string",
              description: `Based on these summary: ${fields}, and the profile information provided, 
list specific technical terms (e.g., tools, frameworks) used in business/portfolio websites from the fields and similar to the provided profile information. 

Example: if the company provides Fullstack Web Development services, include in the list the latest tech: React, Microservices, Cloud.
Do not include the basic, such as: HTML, CSS, etc.
BE SPECIFIC & TECHNICAL, BE UPDATED WITH THE MODERN TRENDS.
Basically you have to list specific terms to reflect that the company is expert in the fields.

Provide at least 20 terms for each field. Provide answers only. No talk. Start with number 1.`,
            },
          },
          required: ["products_or_services", "common_terms"],
        },
      },
    ];
  }
}
export default Focusing;
Leave a Comment