Giter Site home page Giter Site logo

ynews's Introduction

yNews

Breaking news by ai generated defi animals.

  • nice we used all the words
  • collects articles and events from various sources
  • summarizes what it finds using GPT

image

This project uses Next.js, Vercel, OpenAI, and QStash. QStash is used for http queueing, https://docs.upstash.com/qstash.

Getting started

To run this project locally you either need to be a memeber of the yNews vercel team or you can create your own vercel project and link to that. If you create your own vercel project, use the vercel dashboard to add a postgres database and add the following environment variables to all your deployments:

OPENAI_API_KEY=
QSTASH=
QSTASH_TOKEN=

Note, QStash vars are only needed if you want to automate the collectors in preview and production deployments.

Setup your local environment

yarn add vercel -g
vercel link
yarn
yarn pullenv
yarn dev

Initialize the database

CREATE TABLE articles (
  url VARCHAR(2048) NOT NULL PRIMARY KEY,
  source VARCHAR(32),
  persona VARCHAR(32),
  title VARCHAR(256),
  summary TEXT,
  tags VARCHAR(32)[],
  publish_date DATE,
  summarized BOOLEAN NOT NULL DEFAULT FALSE,
  rejected BOOLEAN NOT NULL DEFAULT FALSE,
  approved BOOLEAN NOT NULL DEFAULT FALSE,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  modified_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

Jest testing

yarn test

Endpoint testing

curl -v \
  -H "Content-type: application/json" \
  -H "key: ********" \
  -d '{ "source": "test" }' \
  'http://localhost:3000/api/collect'

curl -v \
  -H "Content-type: application/json" \
  -H "key: ********" \
  -d '{
        "source": "test",
        "articleUrl": "https://test.test.test/123"
      }' \
  'http://localhost:3000/api/summarize'

curl -v 'http://localhost:3000/api/feed'

Add new article source

  1. Implement a collector at this path app/api/collect/collectors/[source name].ts
  2. Implelment a summarizer at this path app/api/summarizer/summarizers/[source name].ts
  3. Schedule QStash to post the collector endpoint with this body:
{
  "source": "[source name]"
}

See the test collector and summarizer for reference.

Schedule a QStash collector job

curl -v \
  -H "Authorization: Bearer ********" \
  -H "Upstash-Forward-key: ********" \
  -H "Upstash-Cron: */30 * * * *" \
  -H "Content-type: application/json" \
  -d '{ "source": "test" }' \
  'https://qstash.upstash.io/v1/publish/https://ynews-greatsword.vercel.app/api/collect'

Mannually post an article summary

curl -v \
  -H "key: ********" \
  -H "Content-type: application/json" \
  -d '{ 
        "url": "https://test.test.test/123",
        "source": "test",
        "title": "Yearn Finance: The Ultimate Yield",
        "summary": "Yearn Finance helps peeps find the best yields in DeFi, automates yield farming, makes it easy for anyone!",
        "tags": ["hot", "defi"],
        "publish_date": "2023-05-27T00:00:00.000Z",
        "summarized": "true",
        "approved": "true"
      }' \
  'http://localhost:3000/api/article'

ynews's People

Contributors

murderteeth avatar

Stargazers

 avatar Marco Guaspari Worms avatar

Watchers

Marco Guaspari Worms avatar  avatar

Forkers

marcoworms

ynews's Issues

Add a way to run all collectors with one post

Currently each collector requires it's own POST to the /api/collect endpoint. This is good for testing, but in production we may also want to call /api/collect and have it iterate through all collectors.

For example, in addition to being able to call the collect endpoint like this:

curl -XPOST \
  -H "Content-type: application/json" \
  -d '{ "source": "test" }' \
  'http://localhost:3000/api/collect'

Lets also be able to call it like this:

curl -XPOST \
  -H "Content-type: application/json" \
  -d '{ "source": "all" }' \
  'http://localhost:3000/api/collect'

Where all as the source is a keyword that tells the endpoint to run all collectors.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.