Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions apps/ensadmin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
"test": "vitest"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.39.0",
"@ensnode/ens-deployments": "workspace:*",
"@ensnode/ponder-metadata": "workspace:*",
"@ensnode/ponder-schema": "workspace:*",
"@ensnode/utils": "workspace:*",
"@gqlpt/adapter-base": "0.0.0-alpha.31",
"@gqlpt/adapter-anthropic": "0.0.0-alpha.33",
"@graphiql/plugin-explorer": "^4.0.2",
"@graphiql/react": "^0.28.2",
"@graphiql/toolkit": "^0.11.1",
Expand All @@ -48,7 +47,7 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"gqlpt": "0.0.0-alpha.31",
"gqlpt": "0.0.0-alpha.33",
"graphiql": "^3.8.3",
"lucide-react": "^0.476.0",
"next": "15.2.4",
Expand Down
139 changes: 5 additions & 134 deletions apps/ensadmin/src/app/gql/api/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Anthropic, { type ClientOptions } from "@anthropic-ai/sdk";
import { Adapter, type AdapterResponse } from "@gqlpt/adapter-base";
import { AdapterAnthropic } from "@gqlpt/adapter-anthropic";
import { GQLPTClient } from "gqlpt";
import { type NextRequest } from "next/server";
import { ensSubgraphSchemaGql } from "./ens-subgraph-gql-schema";

export async function GET(request: NextRequest) {
const requestUrl = new URL(request.url);
const maybePrompt = requestUrl.searchParams.get("prompt");
Expand Down Expand Up @@ -123,6 +123,9 @@ async function getQueryGeneratorClient(
systemPrompt: `${SYSTEM_PROMPT}\n\n${ensSubgraphSchemaGql}`,
maxTokensPerMessage: MAX_TOKENS_PER_MESSAGE,
temperature: TEMPERATURE,
cacheControl: {
type: "ephemeral",
}
}),
});

Expand Down Expand Up @@ -196,139 +199,7 @@ class GenerateQueryDto {
}
}

interface AdapterAnthropicOptions extends ClientOptions {
/** The Anthropic model to use */
model: Model;

/** The system prompt to use */
systemPrompt: string;

/** The max tokens to use per message */
maxTokensPerMessage: number;

/** The temperature to use */
temperature: number;
}

enum Model {
Claude35Sonnet = "claude-3-5-sonnet-20241022",
Claude37Sonnet = "claude-3-7-sonnet-20250219",
}

/**
* Adapter for Anthropic with selectable model and system prompt.
*
* Based on https://github.com/rocket-connect/gqlpt/blob/18af9c9/packages/adapter-anthropic/src/index.ts
*/
class AdapterAnthropic extends Adapter {
/** Anthropic client */
private anthropic: Anthropic;

/** The Anthropic model to use */
private model: Model;

/** The system prompt to use */
private systemPrompt: string;

/** The max tokens to use per message */
private maxTokensPerMessage: number;

/** The temperature to use */
private temperature: number;

private messageHistory: Map<string, Array<Anthropic.MessageParam>> = new Map();

constructor(options: AdapterAnthropicOptions) {
super();
this.anthropic = new Anthropic(options);
this.model = options.model;
this.systemPrompt = options.systemPrompt;
this.maxTokensPerMessage = options.maxTokensPerMessage;
this.temperature = options.temperature;
}

/**
* Connect to Anthropic
*
* Based on https://github.com/rocket-connect/gqlpt/blob/18af9c9/packages/adapter-anthropic/src/index.ts#L18-L30
*/
async connect() {
const response = await this.anthropic.messages.create({
system:
"You are to test the connection to the Anthropic API. Respond with 'Pong' when you see 'Ping'.",
messages: [{ role: "user", content: "Ping" }],
model: this.model,
max_tokens: this.maxTokensPerMessage,
});

if ((response.content[0] as any).text !== "Pong") {
throw new Error("Cannot connect to Anthropic");
}
}

/**
* Send a text message to Anthropic
*
* Based on https://github.com/rocket-connect/gqlpt/blob/18af9c9/packages/adapter-anthropic/src/index.ts#L32-L61
*/
async sendText(text: string, conversationId?: string): Promise<AdapterResponse> {
let beforeText: string | undefined;
const splitPhrase = "And this plain text query:";

let messages: Array<Anthropic.MessageParam>;

if (text.includes(splitPhrase)) {
const splitIndex = text.indexOf(splitPhrase);
beforeText = text.substring(0, splitIndex);
text = text.substring(splitIndex);

messages = [
{
role: "user",
content: [
{
type: "text",
text: beforeText,
cache_control: { type: "ephemeral" },
},
{
type: "text",
text: text,
},
],
},
];
} else {
messages = [{ role: "user", content: text }];
}

if (conversationId && this.messageHistory.has(conversationId)) {
messages = [...this.messageHistory.get(conversationId)!, ...messages];
}

const response = await this.anthropic.messages.create({
// add system prompt if it was provided
system: this.systemPrompt,
messages,
// use the selected model
model: this.model,
// set a default max tokens
max_tokens: 1024,
temperature: this.temperature,
});

const content = (response.content[0] as any).text;
const newId = response.id;

this.messageHistory.set(newId, [
...(conversationId ? this.messageHistory.get(conversationId) || [] : []),
{ role: "user" as const, content: text },
{ role: "assistant" as const, content },
]);

return {
content,
conversationId: newId,
};
}
}
12 changes: 3 additions & 9 deletions docs/ensnode.io/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import react from "@astrojs/react";
import tailwind from "@astrojs/tailwind";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "astro/config";

import { sitemap } from "./config/integrations/sitemap";
import { starlight } from "./config/integrations/starlight";

export default defineConfig({
site: "https://ensnode.io",
integrations: [
starlight(),
sitemap(),
react(),
tailwind({
applyBaseStyles: false,
}),
],
integrations: [starlight(), sitemap(), react()],
vite: {
ssr: {
noExternal: ["@namehash/namekit-react"],
},
plugins: [tailwindcss()],
},
redirects: {
"/ensnode": "/docs",
Expand Down
11 changes: 6 additions & 5 deletions docs/ensnode.io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
},
"dependencies": {
"@astrojs/react": "catalog:",
"@astrojs/sitemap": "^3.2.1",
"@astrojs/starlight": "^0.32.1",
"@astrojs/starlight-tailwind": "^3.0.1",
"@astrojs/sitemap": "^3.3.1",
"@astrojs/starlight": "^0.34.2",
"@astrojs/starlight-tailwind": "^4.0.1",
"@astrojs/tailwind": "catalog:",
"@fontsource/inter": "^5.2.5",
"@headlessui/react": "^2.2.0",
"@namehash/namekit-react": "catalog:",
"@tailwindcss/vite": "^4.1.5",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"astro": "^5.2.3",
"astro": "^5.7.11",
"astro-font": "catalog:",
"astro-seo": "catalog:",
"classcat": "5.0.5",
Expand All @@ -33,6 +34,6 @@
"sharp": "^0.33.5",
"starlight-llms-txt": "^0.5.0",
"starlight-sidebar-topics": "^0.4.1",
"tailwindcss": "3.4.13"
"tailwindcss": "4.1.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import MobileTelegramBanner from "../../assets/telegram_mobile_image.svg";

export default function JoinTelegram() {
return (
<div className="bg-telegram_bg max-w-[1216px] w-full h-fit flex flex-col min-[930px]:flex-row justify-center items-center flex-nowrap gap-10 min-[930px]:gap-5 min-[930px]:pl-20 min-[930px]:pr-5 pt-10 min-[930px]:pt-0 rounded-[20px] overflow-hidden">
<div className="bg-[linear-gradient(90deg,_#F9FAFB_0%,_#F3F5F7_100%)] max-w-[1216px] w-full h-fit flex flex-col min-[930px]:flex-row justify-center items-center flex-nowrap gap-10 min-[930px]:gap-5 min-[930px]:pl-20 min-[930px]:pr-5 pt-10 min-[930px]:pt-0 rounded-[20px] overflow-hidden">
<div className="w-4/5 h-fit flex flex-col flex-nowrap items-center min-[930px]:items-start justify-center gap-5 min-[930px]:py-5">
<Balancer
as="h2"
Expand Down
4 changes: 2 additions & 2 deletions docs/ensnode.io/src/components/overrides/Hero.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import skies_image from "../../assets/hero_skies_image.png";
import { ENSAdminLogoLight } from "../atoms/logos/ENSAdminLogoLight";
---
<section class="bg-gradient-to-b from-[#4182B8] to-[#FEE7B7] w-full h-screen flex flex-col flex-nowrap justify-center items-center bg-cover bg-center bg-no-repeat">
<Image src={skies_image} alt="background skies" class="absolute w-full h-screen z-0 object-center object-cover" quality={100}/>
<Image src={skies_image} alt="background skies" class="absolute w-full h-screen z-0 object-center object-cover select-none" quality={100}/>
<div class="relative z-10 not-content antialiased flex flex-col flex-nowrap gap-8 justify-center items-center text-center px-5 sm:px-0">
<div class="flex flex-col flex-nowrap justify-center items-start gap-4">
<h1 class="max-w-[600px] w-full font-bold leading-10 sm:leading-[68px] text-4xl sm:text-6xl text-white">The new multichain indexer
Expand Down Expand Up @@ -36,4 +36,4 @@ import { ENSAdminLogoLight } from "../atoms/logos/ENSAdminLogoLight";
</a>
</div>
</div>
</section>
</section>
3 changes: 1 addition & 2 deletions docs/ensnode.io/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { SEO } from "astro-seo";
import Footer from "../components/organisms/Footer.tsx";
import Header from "../components/organisms/Header.astro";
import "../styles/globals.css";
import "@namehash/namekit-react/styles.css";
import heroImage from "../assets/hero_skies_image.png";
---
<!doctype html>
Expand Down Expand Up @@ -72,4 +71,4 @@ import heroImage from "../assets/hero_skies_image.png";
width: 100%;
height: 100%;
}
</style>
</style>
28 changes: 19 additions & 9 deletions docs/ensnode.io/src/styles/globals.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@import "tailwindcss";
@layer base, starlight, theme, components, utilities;

:root,
:root[data-theme="light"] {
@import "@astrojs/starlight-tailwind";
@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/utilities.css" layer(utilities);
@import "@namehash/namekit-react/styles.css" layer(utilities);

:root {
--sl-font: "Inter", sans-serif;

--sl-color-accent-low: #cee1e8;
Expand Down Expand Up @@ -41,17 +44,24 @@
--sl-shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

.header {
header.header {
background-color: var(--sl-color-black);
border-color: var(--sl-color-gray-6);
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 100%;
}

/*header elements max width*/
.header.sl-flex > div.sl-flex {
header.header > div.header {
width: 100%;
max-width: 1440px;
margin: 0 auto;
}

header.header div.sl-flex {
width: fit-content;
}

Expand All @@ -71,9 +81,10 @@
visibility: hidden;
}

.header.sl-flex {
div.header {
width: 100%;
max-width: 1440px;
margin: 0 auto;
display: flex;
flex-direction: row;
justify-content: space-between;
Expand Down Expand Up @@ -147,7 +158,6 @@ a[rel="prev"]:hover {
padding-top: 0;
}

h1,
.sl-markdown-content h1,
.sl-markdown-content h2,
.sl-markdown-content h3,
Expand Down
17 changes: 0 additions & 17 deletions docs/ensnode.io/tailwind.config.mjs

This file was deleted.

Loading