Skip to content

feat(gql): introduce LLM-based generator for queries#665

Merged
tk-o merged 16 commits intomainfrom
feat/gql-query-llm-generator
Apr 24, 2025
Merged

feat(gql): introduce LLM-based generator for queries#665
tk-o merged 16 commits intomainfrom
feat/gql-query-llm-generator

Conversation

@tk-o
Copy link
Contributor

@tk-o tk-o commented Apr 23, 2025

In order to test this new feature:

  1. Include ANTHROPIC_API_KEY in apps/ensadmin/.env.local file if you have it (but it's optional)
  2. Start ENSAdmin service (i.e. pnpm -F ensadmin dev)
  3. Go to https://adminensnodeio-git-feat-gql-query-llm-generator-namehash.vercel.app/gql/api?gqlApiUrl=https://api.alpha.ensnode.io/ponder&prompt=latest%20domain%20names%20ending%20with%20.eth
  4. Observe response:
{
  "generateQueryDto": {
    "prompt": "latest domain names ending with .eth",
    "gqlApiUrl": "https://api.alpha.ensnode.io/ponder"
  },
  "generatedQuery": {
    "query": "query ($limit: Int, $orderBy: String, $orderDirection: String, $where: domainFilter) {\n  domains(\n    limit: $limit\n    orderBy: $orderBy\n    orderDirection: $orderDirection\n    where: $where\n  ) {\n    items {\n      createdAt\n      id\n      labelName\n      name\n      owner {\n        id\n      }\n      registration {\n        expiryDate\n        registrationDate\n      }\n    }\n    pageInfo {\n      endCursor\n      hasNextPage\n    }\n    totalCount\n  }\n}",
    "variables": {
      "limit": 10,
      "orderBy": "createdAt",
      "orderDirection": "desc",
      "where": {
        "name_ends_with": ".eth"
      }
    }
  }
}

@changeset-bot
Copy link

changeset-bot bot commented Apr 23, 2025

🦋 Changeset detected

Latest commit: 8446b68

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
ensadmin Minor
ensindexer Minor
ensrainbow Minor
@ensnode/ens-deployments Minor
@ensnode/utils Minor
@ensnode/ensrainbow-sdk Minor
@ensnode/ponder-metadata Minor
@ensnode/ponder-schema Minor
@ensnode/ponder-subgraph Minor
@ensnode/shared-configs Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Contributor

vercel bot commented Apr 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
admin.ensnode.io ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2025 1:10pm
ensnode.io ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2025 1:10pm
ensrainbow.io ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2025 1:10pm


try {
// ensure the client is connected
await client.connect();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. This seems to suggest to me that this package assumes it is always used by a stateful backend and not in a stateless / serverless backend like we are in ENSAdmin.


You will generate a GraphQL query and variables that will be used to test the GQL API.

Always respond with the GraphQL query and variables in JSON format.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we should give an example below this of the expected JSON format?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djstrong what do you think about it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example is in the lib prompt:

Provide your response in the following JSON format:
{
  "query": "The generated GraphQL query",
  "variables": { "key": "value" }
}

Example:
{
  "query": "query($id: ID!) { user(id: $id) { id name email } }",
  "variables": { "id": "123" }
}

Do not include any additional text or formatting outside of this JSON object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lib prompts most of this, but extra can't hurt 🫡

Co-authored-by: lightwalker.eth <126201998+lightwalker-eth@users.noreply.github.com>
@tk-o tk-o merged commit 8b5f360 into main Apr 24, 2025
7 checks passed
@tk-o tk-o deleted the feat/gql-query-llm-generator branch April 24, 2025 13:32
@github-actions github-actions bot mentioned this pull request Apr 24, 2025
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"gqlpt": "0.0.0-alpha.31",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @tk-o

Thanks for the integration, it looks like the lib fit in nicely. We do have the alpha tag, your feedback and usage can really help us get to a stable position for the community. Feel free to open issues on gqlpt and or reach out directly ✌️

*
* Based on https://github.com/rocket-connect/gqlpt/blob/18af9c9/packages/adapter-anthropic/src/index.ts
*/
class AdapterAnthropic extends Adapter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our anthropic Adapter is not passing through the options and hardcoded on a specific model - sorry about that, I made something on our end to track that:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants