├── .eslintignore ├── public ├── favicon.ico ├── demo-screenshot.png ├── github-mark-white.png └── axilla-logo-text-white.png ├── postcss.config.js ├── types ├── nav.ts └── store.ts ├── lib ├── types.ts ├── fonts.ts ├── utils.ts ├── axgen-utils.ts ├── ingest.ts └── query.ts ├── .prettierignore ├── .vscode └── settings.json ├── next.config.mjs ├── .editorconfig ├── next-env.d.ts ├── prisma └── schema.prisma ├── .github └── lint.yml ├── components ├── theme-provider.tsx ├── tailwind-indicator.tsx ├── theme-toggle.tsx ├── ui │ ├── label.tsx │ ├── textarea.tsx │ ├── separator.tsx │ ├── input.tsx │ ├── toaster.tsx │ ├── slider.tsx │ ├── badge.tsx │ ├── switch.tsx │ ├── button.tsx │ ├── tabs.tsx │ ├── card.tsx │ ├── table.tsx │ ├── dialog.tsx │ ├── use-toast.ts │ ├── select.tsx │ ├── form.tsx │ └── toast.tsx ├── main-nav.tsx ├── site-header.tsx ├── code-editor.tsx ├── cell.tsx ├── icons.tsx └── monaco-theme.ts ├── components.json ├── config └── site.ts ├── .gitignore ├── .env.example ├── app ├── api │ ├── ingest │ │ ├── wikipedia │ │ │ └── route.ts │ │ └── upload │ │ │ └── route.ts │ └── query │ │ ├── route.ts │ │ └── stream │ │ └── route.ts ├── components │ ├── embedding-model.tsx │ ├── sidebar.tsx │ ├── document-card.tsx │ ├── config-context.tsx │ ├── ingest-wikipedia.tsx │ ├── ingest-upload.tsx │ ├── store-config.tsx │ ├── query.tsx │ └── query-config.tsx ├── page.tsx └── layout.tsx ├── tsconfig.json ├── .eslintrc.json ├── prettier.config.js ├── README.md ├── styles └── globals.css ├── package.json ├── tailwind.config.js └── tsconfig.tsbuildinfo /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/* 2 | .cache 3 | public 4 | node_modules 5 | *.esm.js 6 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/axflow/original-demo-ui/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/demo-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/axflow/original-demo-ui/HEAD/public/demo-screenshot.png -------------------------------------------------------------------------------- /public/github-mark-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/axflow/original-demo-ui/HEAD/public/github-mark-white.png -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /public/axilla-logo-text-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/axflow/original-demo-ui/HEAD/public/axilla-logo-text-white.png -------------------------------------------------------------------------------- /types/nav.ts: -------------------------------------------------------------------------------- 1 | export interface NavItem { 2 | title: string 3 | href?: string 4 | disabled?: boolean 5 | external?: boolean 6 | } 7 | -------------------------------------------------------------------------------- /lib/types.ts: -------------------------------------------------------------------------------- 1 | export type ContextDocument = { 2 | id: string; 3 | chunk: { 4 | text: string; 5 | url: string; 6 | }; 7 | similarity?: number; 8 | }; 9 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | cache 2 | .cache 3 | package.json 4 | package-lock.json 5 | public 6 | CHANGELOG.md 7 | .yarn 8 | dist 9 | node_modules 10 | .next 11 | build 12 | .contentlayer -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "../../node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib", 3 | "typescript.enablePromptUseWorkspaceTsdk": true 4 | } 5 | -------------------------------------------------------------------------------- /next.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | reactStrictMode: true, 4 | experimental: { 5 | appDir: true, 6 | }, 7 | } 8 | 9 | export default nextConfig 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | -------------------------------------------------------------------------------- /next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | // NOTE: This file should not be edited 5 | // see https://nextjs.org/docs/basic-features/typescript for more information. 6 | -------------------------------------------------------------------------------- /prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | // This is your Prisma schema file, 2 | // learn more about it in the docs: https://pris.ly/d/prisma-schema 3 | 4 | generator client { 5 | provider = "prisma-client-js" 6 | } 7 | 8 | datasource db { 9 | provider = "postgresql" 10 | url = env("DATABASE_URL") 11 | } 12 | -------------------------------------------------------------------------------- /lib/fonts.ts: -------------------------------------------------------------------------------- 1 | import { JetBrains_Mono as FontMono, Inter as FontSans } from 'next/font/google'; 2 | 3 | export const fontSans = FontSans({ 4 | subsets: ['latin'], 5 | variable: '--font-sans', 6 | }); 7 | 8 | export const fontMono = FontMono({ 9 | subsets: ['latin'], 10 | variable: '--font-mono', 11 | }); 12 | -------------------------------------------------------------------------------- /.github/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | on: [pull_request] 3 | jobs: 4 | pr_lint: 5 | runs-on: ubuntu-22.04 6 | steps: 7 | - uses: actions/checkout@v3 8 | - name: setup node 9 | uses: actions/setup-node@v3 10 | with: 11 | node-version: 18 12 | - name: Run linter 13 | - run: npm run lint 14 | -------------------------------------------------------------------------------- /types/store.ts: -------------------------------------------------------------------------------- 1 | export type PineconeStore = { 2 | name: 'pinecone'; 3 | indexName: string; 4 | indexDimensions: number; 5 | environment: string; 6 | namespace: string; 7 | }; 8 | 9 | export type PgVectorStore = { 10 | name: 'pgvector'; 11 | tableName: string; 12 | dsn: string; 13 | }; 14 | 15 | export type SupportedStore = PineconeStore | PgVectorStore; 16 | -------------------------------------------------------------------------------- /components/theme-provider.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import * as React from 'react'; 4 | import { ThemeProvider as NextThemesProvider } from 'next-themes'; 5 | import { ThemeProviderProps } from 'next-themes/dist/types'; 6 | 7 | export function ThemeProvider({ children, ...props }: ThemeProviderProps) { 8 | return {children}; 9 | } 10 | -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "default", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.js", 8 | "css": "styles/globals.css", 9 | "baseColor": "slate", 10 | "cssVariables": true 11 | }, 12 | "aliases": { 13 | "components": "@/components", 14 | "utils": "@/lib/utils" 15 | } 16 | } -------------------------------------------------------------------------------- /config/site.ts: -------------------------------------------------------------------------------- 1 | export type SiteConfig = typeof siteConfig; 2 | 3 | export const siteConfig = { 4 | name: 'axgen demo', 5 | description: 'Ingestion, query & retrieval playground for the Axilla SDK.', 6 | mainNav: [ 7 | { 8 | title: 'Home', 9 | href: '/', 10 | }, 11 | ], 12 | links: { 13 | twitter: 'https://twitter.com/axilla_io', 14 | github: 'https://github.com/axilla-io/axgen', 15 | docs: 'https://docs.axilla.io', 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /lib/utils.ts: -------------------------------------------------------------------------------- 1 | import { type ClassValue, clsx } from 'clsx'; 2 | import { twMerge } from 'tailwind-merge'; 3 | 4 | export function cn(...inputs: ClassValue[]) { 5 | return twMerge(clsx(inputs)); 6 | } 7 | 8 | export function getEnv(key: string) { 9 | return process.env[key]; 10 | } 11 | 12 | export function getEnvOrThrow(key: string) { 13 | const value = getEnv(key); 14 | 15 | if (!value) { 16 | throw new Error(`Expected "${key}" to be set in the process environment`); 17 | } 18 | 19 | return value; 20 | } 21 | -------------------------------------------------------------------------------- /.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 | build 15 | 16 | # misc 17 | .DS_Store 18 | *.pem 19 | 20 | # debug 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | .pnpm-debug.log* 25 | 26 | # local env files 27 | .env.local 28 | .env.development.local 29 | .env.test.local 30 | .env.production.local 31 | 32 | # turbo 33 | .turbo 34 | 35 | .contentlayer 36 | .env -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | ## Pinecone settings 2 | # Pinecone secret API key, e.g.: (not a real key) 3 | PINECONE_API_KEY= 4 | # Pinecone environment 5 | PINECONE_ENVIRONMENT=northamerica-northeast1-gcp 6 | # Pinecone index name, can be whatever you want. 7 | PINECONE_INDEX= 8 | # Pinecone vector dimensions. This will be coupled to the embedding model you use. 9 | # For example, OpenAI's text-embedding-ada-002 is 1536 dimensions. 10 | PINECONE_INDEX_DIMENSION=1536 11 | # Pinecone namespace, "default" by default. 12 | PINECONE_NAMESPACE=default 13 | 14 | ## OpenAI settings 15 | OPENAI_API_KEY=sk-fake 16 | -------------------------------------------------------------------------------- /app/api/ingest/wikipedia/route.ts: -------------------------------------------------------------------------------- 1 | import { NextRequest, NextResponse } from 'next/server'; 2 | import { ingestWikipedia } from '@/lib/ingest'; 3 | 4 | export async function POST(request: NextRequest) { 5 | const { term, store } = await request.json(); 6 | try { 7 | await ingestWikipedia(term, store); 8 | } catch (error: unknown) { 9 | let message = 'Unknown Error'; 10 | if (error instanceof Error) message = error.message; 11 | 12 | return NextResponse.json({ error: message }, { status: 500 }); 13 | } 14 | 15 | return NextResponse.json({ term }, { status: 200 }); 16 | } 17 | -------------------------------------------------------------------------------- /components/tailwind-indicator.tsx: -------------------------------------------------------------------------------- 1 | export function TailwindIndicator() { 2 | if (process.env.NODE_ENV === 'production') return null; 3 | 4 | return ( 5 |
6 |
xs
7 |
sm
8 |
md
9 |
lg
10 |
xl
11 |
2xl
12 |
13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /lib/axgen-utils.ts: -------------------------------------------------------------------------------- 1 | import { Pinecone, PgVector } from 'axgen'; 2 | import { getEnvOrThrow } from './utils'; 3 | 4 | export const getPineconeStore = () => { 5 | return new Pinecone({ 6 | index: getEnvOrThrow('PINECONE_INDEX'), 7 | namespace: getEnvOrThrow('PINECONE_NAMESPACE'), 8 | apiKey: getEnvOrThrow('PINECONE_API_KEY'), 9 | environment: getEnvOrThrow('PINECONE_ENVIRONMENT'), 10 | }); 11 | }; 12 | 13 | export const getPgVectorStore = () => { 14 | return new PgVector({ 15 | dsn: 'postgresql://localhost/axilla-demo', 16 | tableName: 'vectors', 17 | }); 18 | }; 19 | 20 | export const getOpenAiKey = () => { 21 | return getEnvOrThrow('OPENAI_API_KEY'); 22 | }; 23 | -------------------------------------------------------------------------------- /components/theme-toggle.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import * as React from 'react'; 4 | import { useTheme } from 'next-themes'; 5 | 6 | import { Button } from '@/components/ui/button'; 7 | import { Icons } from '@/components/icons'; 8 | 9 | export function ThemeToggle() { 10 | const { setTheme, theme } = useTheme(); 11 | 12 | return ( 13 | 22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["dom", "dom.iterable", "esnext"], 4 | "allowJs": true, 5 | "skipLibCheck": true, 6 | "target": "esnext", 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "incremental": true, 11 | "esModuleInterop": true, 12 | "module": "esnext", 13 | "moduleResolution": "node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "jsx": "preserve", 17 | "baseUrl": ".", 18 | "paths": { 19 | "@/*": ["./*"] 20 | }, 21 | "plugins": [ 22 | { 23 | "name": "next" 24 | } 25 | ], 26 | "strictNullChecks": true 27 | }, 28 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 29 | "exclude": ["node_modules"] 30 | } 31 | -------------------------------------------------------------------------------- /components/ui/label.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as React from "react" 4 | import * as LabelPrimitive from "@radix-ui/react-label" 5 | import { cva, type VariantProps } from "class-variance-authority" 6 | 7 | import { cn } from "@/lib/utils" 8 | 9 | const labelVariants = cva( 10 | "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" 11 | ) 12 | 13 | const Label = React.forwardRef< 14 | React.ElementRef, 15 | React.ComponentPropsWithoutRef & 16 | VariantProps 17 | >(({ className, ...props }, ref) => ( 18 | 23 | )) 24 | Label.displayName = LabelPrimitive.Root.displayName 25 | 26 | export { Label } 27 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/eslintrc", 3 | "root": true, 4 | "extends": [ 5 | "next/core-web-vitals", 6 | "plugin:@typescript-eslint/recommended", 7 | "prettier", 8 | "plugin:tailwindcss/recommended" 9 | ], 10 | "plugins": ["tailwindcss", "@typescript-eslint"], 11 | "rules": { 12 | "@next/next/no-html-link-for-pages": "off", 13 | "react/jsx-key": "off", 14 | "tailwindcss/no-custom-classname": "off", 15 | "@typescript-eslint/ban-ts-comment": "off" 16 | }, 17 | "settings": { 18 | "tailwindcss": { 19 | "callees": ["cn"], 20 | "config": "tailwind.config.js" 21 | }, 22 | "next": { 23 | "rootDir": ["./"] 24 | } 25 | }, 26 | "overrides": [ 27 | { 28 | "files": ["*.ts", "*.tsx"], 29 | "parser": "@typescript-eslint/parser" 30 | } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /components/ui/textarea.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | import { cn } from '@/lib/utils'; 4 | 5 | // @ts-ignore 6 | export type TextareaProps = React.TextareaHTMLAttributes; 7 | 8 | const Textarea = React.forwardRef( 9 | ({ className, ...props }, ref) => { 10 | return ( 11 |