├── .eslintrc.json ├── app ├── globals.css ├── favicon.ico ├── layout.js ├── api │ └── fetchCsvData │ │ └── route.js └── page.js ├── jsconfig.json ├── postcss.config.js ├── backend ├── requirements.txt ├── Dockerfile ├── .dockerignore ├── create_vector_db.py └── main.py ├── next.config.js ├── tailwind.config.js ├── .gitignore ├── components ├── Header.js ├── InputBar.js └── ChatMessages.js ├── package.json ├── README.md └── LICENSE /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /app/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; -------------------------------------------------------------------------------- /app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtenenholtz/chat-twitter/HEAD/app/favicon.ico -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "@/*": ["./*"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /backend/requirements.txt: -------------------------------------------------------------------------------- 1 | langchain==0.0.137 2 | openai 3 | tiktoken 4 | fastapi==0.95.0 5 | uvicorn[standard]==0.21.1 6 | pinecone-client[grpc]==2.2.1 7 | hypercorn 8 | gunicorn -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | experimental: { 4 | appDir: true, 5 | }, 6 | } 7 | 8 | module.exports = nextConfig 9 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | "./app/**/*.{js,ts,jsx,tsx}", 5 | "./components/**/*.{js,ts,jsx,tsx}" 6 | ], 7 | theme: { 8 | extend: {}, 9 | }, 10 | plugins: [], 11 | } 12 | 13 | -------------------------------------------------------------------------------- /app/layout.js: -------------------------------------------------------------------------------- 1 | import './globals.css' 2 | 3 | export const metadata = { 4 | title: 'Create Next App', 5 | description: 'Generated by create next app', 6 | } 7 | 8 | export default function RootLayout({ children }) { 9 | return ( 10 | 11 | {children} 12 | 13 | ) 14 | } 15 | -------------------------------------------------------------------------------- /app/api/fetchCsvData/route.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | import csv from 'csvtojson'; 4 | import { NextResponse } from 'next/server'; 5 | 6 | export async function GET() { 7 | const filePath = path.join(process.cwd(), 'backend/data/corpus_summary.csv'); 8 | const data = await csv().fromFile(filePath); 9 | return NextResponse.json(data); 10 | } -------------------------------------------------------------------------------- /backend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.9.16 2 | 3 | # Install some basic utilities. 4 | RUN apt-get update && apt-get install -y \ 5 | curl \ 6 | ca-certificates \ 7 | sudo \ 8 | git \ 9 | bzip2 \ 10 | libx11-6 \ 11 | build-essential \ 12 | libssl-dev \ 13 | && rm -rf /var/lib/apt/lists/* 14 | 15 | # Create a working directory. 16 | RUN mkdir /app 17 | WORKDIR /app 18 | 19 | COPY . /app/ 20 | RUN pip install -r requirements.txt 21 | 22 | CMD ["gunicorn", "main:app", "--bind", "[::]:8080", "-k", "uvicorn.workers.UvicornWorker"] -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | .pnpm-debug.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | __pycache__/ 35 | *.py[cod] 36 | *$py.class 37 | 38 | chroma_logs.log 39 | embeddings_exploration.ipynb 40 | fly.toml -------------------------------------------------------------------------------- /components/Header.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Header = () => { 4 | return ( 5 |
6 |

Chat With the Algorithm

7 |
8 | 13 | https://github.com/twitter/the-algorithm 14 | 15 |
16 |
17 | ); 18 | }; 19 | 20 | export default Header; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chat-twitter", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "csvtojson": "^2.0.10", 13 | "eslint": "8.37.0", 14 | "eslint-config-next": "13.2.4", 15 | "next": "13.2.4", 16 | "react": "18.2.0", 17 | "react-dom": "18.2.0", 18 | "react-syntax-highlighter": "^15.5.0" 19 | }, 20 | "devDependencies": { 21 | "autoprefixer": "^10.4.14", 22 | "postcss": "^8.4.21", 23 | "tailwindcss": "^3.3.1" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /backend/.dockerignore: -------------------------------------------------------------------------------- 1 | # flyctl launch added from .gitignore 2 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 3 | 4 | # dependencies 5 | node_modules 6 | .pnp 7 | **/.pnp.js 8 | 9 | # testing 10 | coverage 11 | 12 | # next.js 13 | .next 14 | out 15 | 16 | # production 17 | build 18 | 19 | # misc 20 | **/.DS_Store 21 | **/*.pem 22 | 23 | # debug 24 | **/npm-debug.log* 25 | **/yarn-debug.log* 26 | **/yarn-error.log* 27 | **/.pnpm-debug.log* 28 | 29 | # local env files 30 | **/.env*.local 31 | 32 | # vercel 33 | **/.vercel 34 | 35 | **/__pycache__ 36 | **/*.py[cod] 37 | **/*$py.class 38 | 39 | **/chroma_logs.log 40 | **/backend/data 41 | fly.toml 42 | embeddings_exploration.ipynb -------------------------------------------------------------------------------- /components/InputBar.js: -------------------------------------------------------------------------------- 1 | import React, { useRef, useEffect } from 'react' 2 | 3 | const InputBar = ({ input, setInput, handleKeyDown, handleSubmit }) => { 4 | const inputRef = useRef(null) 5 | 6 | useEffect(() => { 7 | if (inputRef.current) { 8 | inputRef.current.style.height = 'auto' 9 | inputRef.current.style.height = inputRef.current.scrollHeight + 'px' 10 | } 11 | }, [input]) 12 | 13 | return ( 14 |
15 |
16 |
17 |