Open Drew-Macgibbon opened 1 year ago
@Drew-Macgibbon the DB structure will have 4 tables and each with their own attributes.
Articles
...
Categories
...
Tags
...
ArticleTags
...
Should we start creating them in the Supabase or initially work with a static JSON format until we develop a basic prototype?
@Drew-Macgibbon @JapneetRajput below is the explanation of my understanding with the working files in server/utils/openai
directory. Review it and correct if I miss out something or if there's invalid point.
server/utils/openai
/openaiClient.ts
/callOpenAI.ts
callOpenAI()
function, which is responsible for making asynchronous calls to the OpenAI API./generateSummary.ts
callOpenAI
function.zod
library for data validation, defining a validation schema for the expected output.generateSummary()
function takes an input string, constructs a prompt for the OpenAI API, and calls the callOpenAI
function.@Drew-Macgibbon the DB structure will have 4 tables and each with their own attributes.
Articles
...Categories
...Tags
...ArticleTags
...Should we start creating them in the Supabase or initially work with a static JSON format until we develop a basic prototype?
@aayu5hgit I would do JSON first, focus first on getting each step working the proceeds storing in the DB.
@aayu5hgit in regards to openai stuff, yes that's accurate. They have significantly improved the ability to respond with JSON, so check the docs and make the appropriate changes to the summary function.
@Drew-Macgibbon @aayu5hgit
Some changes that we might have to make to incorporate the articles data.
We're getting the data in the format :
Articles Table
Here is the previous schema for reference :
id: Bigint, Primary Key
created_at: Timestamp
updated_at: Timestamp
title: Text
link: Text, URL
category_id: Integer, Foreign Key to Categories table
original: JSONB (to store the 'original' object with title and body)
summary: JSONB (to store summaries with 'beginner', 'intermediate', 'expert' levels)
author: JSONB (to store author details as a JSON object)
Proposed changes :
Adding a key for images/media. Format is below ⬇️ Array of objects : { src: Text, URL alt: Text caption: Text }
Adding a key for published date. published: timestampz
This is based on the data we're scraping from space.com
@JapneetRajput sure, we will probably have to download and store the images in supabase to stop our website from getting blacklisted from the post origin sites for hitting their cache too often.
Scrape all images as JSON, we will just download/store the featured images.
As I said this needs to be something super simple to start, we can expand it later.
Working Files
server/utils/news
server/utils/openai/callOpenAi.ts
,server/utils/openai/generateSummary.ts
andserver/utils/openai/openaiClient.ts
server/api/admin/generate-summary.ts
,server/api/admin/scrape-blogs.ts
, andserver/api/admin/get-blogs.ts
pages/astrotribe/news
High-Level Overview
Essential Data
Scraped Data:
title / author name / author url / published date / updated date / original url / post bodyAutomated Data:
beginner / intermediate / expert summariesManual Data:
post category / tagsTasks To Consider
Define Functionality
DB Structure:
Articles Table
Categories Table
server\utils\openai\categories.json
Tags Table
server\utils\openai\tags.json
ArticleTags Table (many-to-many relationship between Articles and Tags)