Giter Site home page Giter Site logo

chriscarrollsmith / chat-twitter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mtenenholtz/chat-twitter

0.0 0.0 0.0 164 KB

Home Page: https://chat-twitter.vercel.app

License: Apache License 2.0

JavaScript 52.46% Python 45.19% CSS 0.27% Dockerfile 2.08%

chat-twitter's Introduction

Chat With the Algorithm

Ask questions about the open-sourced Twitter algorithm.

The app is publicly hosted here: https://chat-twitter.vercel.app/. Instructions for hosting it yourself are below.

Basic architecture

The app is a NextJS/Tailwind CSS frontend with a FastAPI backend. The frontend is hosted on Vercel and the backend is hosted on a small node on fly.io. The backend uses a Pinecone vector DB on the free tier. There is a Dockerfile provided.

Right now, I'm footing the OpenAI bill on the public instance. But I may require users to bring their own key in the future.

Running locally

  1. Set up environment variables
OPENAI_API_KEY=...
OPENAI_ORG_ID=... # organization id, found in Manage account > settings
PINECONE_API_KEY=...
  1. Clone the repo
git clone https://github.com/mtenenholtz/chat-twitter.git
cd chat-twitter
  1. Install Node dependencies
npm i
  1. Run the Node server
npm run dev
  1. In another terminal, install the Python dependencies
# in the backend/ directory
pip install -r requirements.txt
  1. Embed the Twitter codebase
# in the backend/ directory
python create_vector_db.py
  1. Set up a Pinecone index. Give it a vector dimension of 1536 and name it pinecone-index. You can change this in backend/main.py if you want.

  2. Run the backend server

uvicorn main:app --reload
  1. The URL for the backend is currently hard coded to the live server URL. You will have to change this to localhost or your other server name.

Potential improvements

I will continue development on this project as demand exists. But, if I abandon it, here are some ideas:

  • The dependency on Pinecone could be removed and replaced with a simple NumPy array. I just wanted to try Pinecone.
  • Replace the chat_stream endpoint with a websocket implementation.
  • Ask the model not to generatively reference its sources. Instead, simply copy the code snippet directly.
  • The splitter could be improved. Right now, it's a character splitter that favors newlines, but OpenAI has implemented a similar one that splits on tokens instead.
  • The embeddings and retrieval mechanisms could account for the hierarchy of the Algorithm's code structure, like Replit's Ghostwriter does.
  • The UI could be improved a lot. I suck at JS.

chat-twitter's People

Contributors

mtenenholtz avatar

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.