Skip to content

Commit

Permalink
Pull and Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelUnkey committed Nov 12, 2024
1 parent 8e238d2 commit 6d390a4
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 70 deletions.
4 changes: 2 additions & 2 deletions apps/billing/src/lib/db-marketing/schemas/entries.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { index, int, mysqlTable, text, timestamp, varchar } from "drizzle-orm/mysql-core";
import { searchQueries } from "./searchQuery";
import { relations } from "drizzle-orm";
import { index, int, mysqlTable, text, timestamp, varchar } from "drizzle-orm/mysql-core";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import type { z } from "zod";
import { searchQueries } from "./searchQuery";
import { sections } from "./sections";

export const entries = mysqlTable(
Expand Down
4 changes: 2 additions & 2 deletions apps/billing/src/lib/db-marketing/schemas/evals.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { mysqlTable, int, timestamp, mysqlEnum, text, index } from "drizzle-orm/mysql-core";
import { relations } from "drizzle-orm";
import { index, int, mysqlEnum, mysqlTable, text, timestamp } from "drizzle-orm/mysql-core";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import { z } from "zod";
import { entries } from "./entries";
import { relations } from "drizzle-orm";

export const evalTypes = ["technical", "seo", "editorial"] as const;
export type EvalType = (typeof evalTypes)[number];
Expand Down
6 changes: 3 additions & 3 deletions apps/billing/src/lib/db-marketing/schemas/firecrawl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { relations, sql } from "drizzle-orm";
import { relations } from "drizzle-orm";
import {
boolean,
index,
Expand All @@ -9,10 +9,10 @@ import {
unique,
varchar,
} from "drizzle-orm/mysql-core";
import { serperOrganicResults } from "./serper";
import { searchQueries } from "./searchQuery";
import { createInsertSchema } from "drizzle-zod";
import type { z } from "zod";
import { searchQueries } from "./searchQuery";
import { serperOrganicResults } from "./serper";

export const firecrawlResponses = mysqlTable(
"firecrawl_responses",
Expand Down
4 changes: 2 additions & 2 deletions apps/billing/src/lib/db-marketing/schemas/keywords.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { relations } from "drizzle-orm";
import { index, int, mysqlTable, timestamp, unique, varchar } from "drizzle-orm/mysql-core";
import { searchQueries } from "./searchQuery";
import { serperOrganicResults } from "./serper";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import type { z } from "zod";
import { searchQueries } from "./searchQuery";
import { sectionsToKeywords } from "./sections";
import { serperOrganicResults } from "./serper";

export const keywords = mysqlTable(
"keywords",
Expand Down
4 changes: 2 additions & 2 deletions apps/billing/src/lib/db-marketing/schemas/searchQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
} from "drizzle-orm/mysql-core";
import { createInsertSchema } from "drizzle-zod";
import type { z } from "zod";
import { serperSearchResponses } from "./serper";
import { firecrawlResponses } from "./firecrawl";
import { entries } from "./entries";
import { firecrawlResponses } from "./firecrawl";
import { serperSearchResponses } from "./serper";

export const searchQueries = mysqlTable(
"search_queries",
Expand Down
14 changes: 6 additions & 8 deletions apps/billing/src/lib/db-marketing/schemas/sections.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { relations } from "drizzle-orm";
import {
int,
mysqlEnum,
mysqlTable,
varchar,
primaryKey,
text,
timestamp,
int,
primaryKey,
mysqlEnum,
index,
unique,
varchar,
} from "drizzle-orm/mysql-core";
import { relations } from "drizzle-orm";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import { keywords } from "./keywords";
import type { z } from "zod";
import { entries } from "./entries";
import { keywords } from "./keywords";

export const sections = mysqlTable("sections", {
id: int("id").primaryKey().autoincrement(),
Expand Down
2 changes: 1 addition & 1 deletion apps/billing/src/lib/db-marketing/schemas/serper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { relations } from "drizzle-orm";
import { index, int, json, mysqlTable, text, timestamp, varchar } from "drizzle-orm/mysql-core";
import { createSelectSchema } from "drizzle-zod";
import type { z } from "zod";
import { searchQueries } from "./searchQuery";
import { firecrawlResponses } from "./firecrawl";
import { searchQueries } from "./searchQuery";

// Main SearchResponse table
export const serperSearchResponses = mysqlTable(
Expand Down
24 changes: 8 additions & 16 deletions apps/billing/src/lib/firecrawl.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import { db } from "@/lib/db-marketing/client";
import {
firecrawlResponses,
firecrawlResponses,
keywords,
serperOrganicResults,
serperSearchResponses,
} from "@/lib/db-marketing/schemas";
import { THREE } from "@/trigger/glossary/keyword-research";
import FirecrawlApp from "@mendable/firecrawl-js";
import { and, desc, eq, inArray, isNotNull, lte, sql } from "drizzle-orm";
import { getOrCreateSearchResponse } from "./serper";
import { generateObject, generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { z } from "zod";
import { keywordResearchSystemPrompt } from "./keywords";
import { firecrawlResponses, serperOrganicResults } from "@/lib/db-marketing/schemas";
import type { CacheStrategy } from "@/trigger/glossary/_generate-glossary-entry";
import { openai } from "@ai-sdk/openai";
import FirecrawlApp from "@mendable/firecrawl-js";
import { generateText } from "ai";
import { eq } from "drizzle-orm";

const firecrawl = new FirecrawlApp({
apiKey: process.env.FIRECRAWL_API_KEY!,
Expand Down Expand Up @@ -170,7 +160,9 @@ Accurately and concisely summarize the content from the page that ranks #${
- Mention the types of content included, such as images, tables, code snippets, etc.
- Cite the term the content is ranking for and its position in the SERP.`;

const prompt = `Summarize the following content for the term "${connectTo.term}" that's ranking #${serperResult?.position ?? "unknown"}:
const prompt = `Summarize the following content for the term "${
connectTo.term
}" that's ranking #${serperResult?.position ?? "unknown"}:
=======
${firecrawlResponse.markdown}
=======`;
Expand Down
6 changes: 3 additions & 3 deletions apps/billing/src/lib/keywords.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { openai } from "@ai-sdk/openai";
import { generateObject } from "ai";
import { sql } from "drizzle-orm";
import { and } from "drizzle-orm";
import { inArray } from "drizzle-orm";
import { eq } from "drizzle-orm";
import { z } from "zod";
import { db } from "./db-marketing/client";
import { firecrawlResponses, keywords, serperSearchResponses } from "./db-marketing/schemas";
import { z } from "zod";
import { openai } from "@ai-sdk/openai";
import { generateObject } from "ai";

export const keywordResearchSystemPrompt = `
You are an SEO Expert & Content Writer specializing in creating technical content for Developer Tools that are highly SEO optimized.
Expand Down
2 changes: 1 addition & 1 deletion apps/billing/src/lib/search-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { openai } from "@ai-sdk/openai";
import { generateObject } from "ai";
import { eq, sql } from "drizzle-orm";

import { insertSearchQuerySchema, searchQueries, entries } from "@/lib/db-marketing/schemas";
import { entries, insertSearchQuerySchema, searchQueries } from "@/lib/db-marketing/schemas";

export async function getOrCreateSearchQuery(args: { term: string }) {
const { term } = args;
Expand Down
14 changes: 7 additions & 7 deletions apps/billing/src/trigger/glossary/_generate-glossary-entry.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { db } from "@/lib/db-marketing/client";
import { entries } from "@/lib/db-marketing/schemas";
import { task } from "@trigger.dev/sdk/v3";
import { keywordResearchTask } from "./keyword-research";
import { generateOutlineTask } from "./generate-outline";
import { draftSectionsTask } from "./draft-sections";
import { seoMetaTagsTask } from "./seo-meta-tags";
import { createPrTask } from "./create-pr";
import { AbortTaskRunError } from "@trigger.dev/sdk/v3";
import { db } from "@/lib/db-marketing/client";
import { eq } from "drizzle-orm";
import { entries } from "@/lib/db-marketing/schemas";
import { createPrTask } from "./create-pr";
import { draftSectionsTask } from "./draft-sections";
import { generateOutlineTask } from "./generate-outline";
import { keywordResearchTask } from "./keyword-research";
import { seoMetaTagsTask } from "./seo-meta-tags";

export type CacheStrategy = "revalidate" | "stale";
/**
Expand Down
4 changes: 2 additions & 2 deletions apps/billing/src/trigger/glossary/create-pr.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AbortTaskRunError, task } from "@trigger.dev/sdk/v3";
import { Octokit } from "@octokit/rest";
import { db } from "@/lib/db-marketing/client";
import { entries } from "@/lib/db-marketing/schemas";
import { Octokit } from "@octokit/rest";
import { AbortTaskRunError, task } from "@trigger.dev/sdk/v3";
import { eq } from "drizzle-orm";
import type { CacheStrategy } from "./_generate-glossary-entry";

Expand Down
4 changes: 2 additions & 2 deletions apps/billing/src/trigger/glossary/draft-sections.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { db } from "@/lib/db-marketing/client";
import {
type sectionContentTypes,
type SelectEntry,
entries,
firecrawlResponses,
type keywords,
type sectionContentTypes,
type sections,
type sectionsToKeywords,
type SelectEntry,
} from "@/lib/db-marketing/schemas";
import { openai } from "@ai-sdk/openai";
import { AbortTaskRunError, task } from "@trigger.dev/sdk/v3";
Expand Down
9 changes: 3 additions & 6 deletions apps/billing/src/trigger/glossary/evals.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { db } from "@/lib/db-marketing/client";
import { entries } from "@/lib/db-marketing/schemas";
import {
evals,
evalTypes,
type EvalType,
evals,
ratingsSchema,
recommendationsSchema,
type Recommendations,
} from "@/lib/db-marketing/schemas/evals";
import { entries } from "@/lib/db-marketing/schemas";
import { openai } from "@ai-sdk/openai";
import { generateObject } from "ai";
import { z } from "zod";
import { AbortTaskRunError, task } from "@trigger.dev/sdk/v3";
import { generateObject } from "ai";
import { eq } from "drizzle-orm";
import type { CacheStrategy } from "./_generate-glossary-entry";

Expand Down
9 changes: 4 additions & 5 deletions apps/billing/src/trigger/glossary/generate-outline.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { db } from "@/lib/db-marketing/client";
import {
type SelectKeywords,
entries,
type FirecrawlResponse,
firecrawlResponses,
insertSectionContentTypeSchema,
insertSectionSchema,
Expand All @@ -10,18 +10,17 @@ import {
sectionContentTypes,
sections,
sectionsToKeywords,
type SelectKeywords,
selectKeywordsSchema,
} from "@/lib/db-marketing/schemas";
import type { Keyword } from "@/lib/db-marketing/schemas/keywords";
import { getOrCreateSummary } from "@/lib/firecrawl";
import { openai } from "@ai-sdk/openai";
import { AbortTaskRunError, task } from "@trigger.dev/sdk/v3";
import { generateObject } from "ai";
import { and, eq, or } from "drizzle-orm";
import { z } from "zod";
import type { CacheStrategy } from "./_generate-glossary-entry";
import { getOrCreateSummary } from "@/lib/firecrawl";
import type { Keyword } from "@/lib/db-marketing/schemas/keywords";
import { performTechnicalEvalTask, performSEOEvalTask, performEditorialEvalTask } from "./evals";
import { performEditorialEvalTask, performSEOEvalTask, performTechnicalEvalTask } from "./evals";

// TODO: this task is a bit flake-y still
// - split up into smaller tasks, and/or
Expand Down
4 changes: 2 additions & 2 deletions apps/billing/src/trigger/glossary/keyword-research.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { db } from "@/lib/db-marketing/client";
import { keywords } from "@/lib/db-marketing/schemas";
import { getOrCreateFirecrawlResponse } from "@/lib/firecrawl";
import { AbortTaskRunError, task } from "@trigger.dev/sdk/v3";
import { sql } from "drizzle-orm";
import { inArray } from "drizzle-orm";
import { and, eq } from "drizzle-orm";
import { getOrCreateKeywordsFromHeaders, getOrCreateKeywordsFromTitles } from "../../lib/keywords";
import { getOrCreateSearchQuery } from "../../lib/search-query";
import { getOrCreateSearchResponse } from "../../lib/serper";
import { getOrCreateKeywordsFromHeaders, getOrCreateKeywordsFromTitles } from "../../lib/keywords";
import { getOrCreateFirecrawlResponse } from "@/lib/firecrawl";
import type { CacheStrategy } from "./_generate-glossary-entry";

export const THREE = 3;
Expand Down
11 changes: 5 additions & 6 deletions apps/billing/src/trigger/glossary/seo-meta-tags.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Trigger } from "@trigger.dev/sdk";
import { z } from "zod";
import { eq, and, or } from "drizzle-orm";
import { keywords, firecrawlResponses, entries } from "../../lib/db-marketing/schemas";
import { task } from "@trigger.dev/sdk/v3";
import { db } from "@/lib/db-marketing/client";
import { generateObject, generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { task } from "@trigger.dev/sdk/v3";
import { generateObject } from "ai";
import { and, eq, or } from "drizzle-orm";
import { z } from "zod";
import { entries, firecrawlResponses, keywords } from "../../lib/db-marketing/schemas";
import type { CacheStrategy } from "./_generate-glossary-entry";

// Define the job
Expand Down

0 comments on commit 6d390a4

Please sign in to comment.