Skip to content

[EPIC] - GraphQL Agent #29

@amirhouieh

Description

@amirhouieh

Train a Language Model for Converting Human Queries to GraphQL for Unbody GraphQL Content API

Objective

Train a language model to accurately translate natural language queries into GraphQL queries, in line with our data schemas and syntax used in the Unbody GraphQL endpoint built on Weaviate.

Tasks

  • Create a Training Dataset @amirhouieh: Develop a dataset with examples of natural language and corresponding GraphQL queries.
  • Model Training @amirhouieh: Train the model for translating human language to GraphQL format.
  • Integration @jeangovil: Integrate the trained model with our GraphQL content API.
  • Deployment @jeangovil: Deploy the model for operational use.

How It Should Work

  1. Receive a query in natural language.
  2. Language model agent generates a GraphQL query.

GraphQL Level Implementation

Implement a new Agent method alongside GET and AGGREGATE methods to translate natural language inputs to structured GraphQL queries.

Examples

Find our financial reports for the last two years

{
  Get {
    PdfFile(
      nearText: {
        concepts: ["financial report"]
      },
      filter: {
        operator: GreaterThan,
        path: ["metadata.creationDate"],
        valueDate: "2020-01-01"
      }
    ) {
      title
      metadata {
        creationDate
      }
    }
  }
}

Who is working on the LPE project

{
  Get {
    NameEntities(
      where: {
        operator: And
        operands: [
          { path: ["type"], operator: Equal, valueString: "person" },
          { path: ["type"], operator: Equal, valueString: "email" },
          { path: ["document.title"], operator: Like, valueString: "LPE project" }
        ]
      }
    ) {
      crossReference {
        ... on GoogleDoc {
          title
        }
        ... on PdfFile {
          title
        }
        ... on Markdownfile {
          title
        }
      }
    }

    TextBlocks(
      where: {
        path: ["mentions"],
        operator: Like,
        valueString: "LPE project"
      }
    ) {
      mentions
      document {
        ... on GoogleDoc {
          title
        }
        ... on PdfFile {
          title
        }
        ... on Markdownfile {
          title
        }
      }
    }
  }
}

Summarize my recent emails with Nicole

{
  Get {
    GmailThread(
      nearText: {
        concepts: ["emails with Nicole"]
      },
      filter: {
        operator: GreaterThan,
        path: ["metadata.creationDate"],
        valueDate: "recent_date"
      }
    ) {
      content
      _additional {
        generate(
          singleResult: {
            prompt: """
            Summarize the conversation:
            {content}
            """
          }
        ) {
          singleResult
        }
      }
    }
  }
}

When are we going to launch city hall portal

{
  Get {
    GoogleCalendarEvent(
      nearText: {
        concepts: ["city hall portal"],
        properties: ["title", "description", "attachments"]
      }
    ) {
      title
      startDate
      endDate
      _additional {
        generate(
          singleResult: {
            prompt: """
            Analyze the event details: {title}, {startDate}, {endDate}.
            Answer the question: When are we going to launch the city hall portal?
            """
          }
        ) {
          singleResult
        }
      }
    }
  }
}

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions