Showing preview only (1,001K chars total). Download the full file or copy to clipboard to get everything.
Repository: mayooear/ai-pdf-chatbot-langchain
Branch: main
Commit: 4bb98092472d
Files: 111
Total size: 958.7 KB
Directory structure:
gitextract_1jzaved4/
├── .dockerignore
├── .eslintrc.cjs
├── .github/
│ └── workflows/
│ └── ci.yml
├── .gitignore
├── .prettierrc
├── LICENSE
├── README.md
├── backend/
│ ├── .gitignore
│ ├── __tests__/
│ │ ├── ingestion_graph/
│ │ │ └── state.test.ts
│ │ └── retrieval_graph/
│ │ ├── integration.test.ts
│ │ └── promptTemplate.test.ts
│ ├── demo.ts
│ ├── ingest-demo.ipynb
│ ├── jest.config.js
│ ├── langgraph.json
│ ├── package.json
│ ├── src/
│ │ ├── ingestion_graph/
│ │ │ ├── configuration.ts
│ │ │ ├── graph.ts
│ │ │ └── state.ts
│ │ ├── retrieval_graph/
│ │ │ ├── configuration.ts
│ │ │ ├── graph.ts
│ │ │ ├── prompts.ts
│ │ │ ├── state.ts
│ │ │ └── utils.ts
│ │ ├── sample_docs.json
│ │ └── shared/
│ │ ├── configuration.ts
│ │ ├── retrieval.ts
│ │ ├── state.ts
│ │ └── utils.ts
│ └── tsconfig.json
├── frontend/
│ ├── .gitignore
│ ├── __tests__/
│ │ └── api/
│ │ └── ingest/
│ │ └── route.integration.test.ts
│ ├── app/
│ │ ├── api/
│ │ │ ├── chat/
│ │ │ │ └── route.ts
│ │ │ └── ingest/
│ │ │ └── route.ts
│ │ ├── globals.css
│ │ ├── layout.tsx
│ │ └── page.tsx
│ ├── components/
│ │ ├── chat-message.tsx
│ │ ├── example-prompts.tsx
│ │ ├── file-preview.tsx
│ │ ├── theme-provider.tsx
│ │ └── ui/
│ │ ├── accordion.tsx
│ │ ├── alert-dialog.tsx
│ │ ├── alert.tsx
│ │ ├── aspect-ratio.tsx
│ │ ├── avatar.tsx
│ │ ├── badge.tsx
│ │ ├── breadcrumb.tsx
│ │ ├── button.tsx
│ │ ├── calendar.tsx
│ │ ├── card.tsx
│ │ ├── carousel.tsx
│ │ ├── chart.tsx
│ │ ├── checkbox.tsx
│ │ ├── collapsible.tsx
│ │ ├── command.tsx
│ │ ├── context-menu.tsx
│ │ ├── dialog.tsx
│ │ ├── drawer.tsx
│ │ ├── dropdown-menu.tsx
│ │ ├── form.tsx
│ │ ├── hover-card.tsx
│ │ ├── input-otp.tsx
│ │ ├── input.tsx
│ │ ├── label.tsx
│ │ ├── menubar.tsx
│ │ ├── navigation-menu.tsx
│ │ ├── pagination.tsx
│ │ ├── popover.tsx
│ │ ├── progress.tsx
│ │ ├── radio-group.tsx
│ │ ├── resizable.tsx
│ │ ├── scroll-area.tsx
│ │ ├── select.tsx
│ │ ├── separator.tsx
│ │ ├── sheet.tsx
│ │ ├── sidebar.tsx
│ │ ├── skeleton.tsx
│ │ ├── slider.tsx
│ │ ├── sonner.tsx
│ │ ├── switch.tsx
│ │ ├── table.tsx
│ │ ├── tabs.tsx
│ │ ├── textarea.tsx
│ │ ├── toast.tsx
│ │ ├── toaster.tsx
│ │ ├── toggle-group.tsx
│ │ ├── toggle.tsx
│ │ ├── tooltip.tsx
│ │ └── use-mobile.tsx
│ ├── components.json
│ ├── constants/
│ │ └── graphConfigs.ts
│ ├── hooks/
│ │ ├── use-mobile.tsx
│ │ └── use-toast.ts
│ ├── jest.config.js
│ ├── jest.setup.js
│ ├── lib/
│ │ ├── langgraph-base.ts
│ │ ├── langgraph-client.ts
│ │ ├── langgraph-server.ts
│ │ ├── pdf.ts
│ │ └── utils.ts
│ ├── next.config.mjs
│ ├── package.json
│ ├── postcss.config.mjs
│ ├── styles/
│ │ └── globals.css
│ ├── tailwind.config.ts
│ ├── tsconfig.json
│ └── types/
│ └── graphTypes.ts
├── package.json
├── scripts/
│ └── checkLanggraphPaths.js
└── turbo.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .dockerignore
================================================
node_modules
dist
================================================
FILE: .eslintrc.cjs
================================================
/* .eslintrc.cjs */
module.exports = {
root: true, // Ensures ESLint doesn't look beyond this folder for configuration
parser: '@typescript-eslint/parser', // Tells ESLint to parse TypeScript
parserOptions: {
ecmaVersion: 'latest', // Enables modern JavaScript features
sourceType: 'module', // Allows import/export statements,
project: './tsconfig.json', // Tells ESLint to use the tsconfig.json file
},
extends: [
'eslint:recommended', // Basic ESLint rules
'plugin:@typescript-eslint/recommended', // Adds TypeScript-specific rules
'prettier', // Disables rules conflicting with Prettier
],
ignorePatterns: [
'.eslintrc.cjs',
'scripts',
'src/utils/lodash/*',
'node_modules',
'dist',
'dist-cjs',
'*.js',
'*.cjs',
'*.d.ts',
],
rules: {
// You can add or override any rules here, for example:
// "no-console": "warn", // Warn when using console.log
},
};
================================================
FILE: .github/workflows/ci.yml
================================================
# Run formatting on all PRs
name: CI
on:
push:
branches: ["main"]
pull_request:
workflow_dispatch: # Allows triggering the workflow manually in GitHub UI
# If another push to the same PR or branch happens while this workflow is still running,
# cancel the earlier run in favor of the next run.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
format:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable --mode=skip-build
- name: Check formatting
run: yarn format:check
lint:
name: Check linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable --mode=skip-build
- name: Check linting
run: yarn run lint:all
================================================
FILE: .gitignore
================================================
# npm
node_modules/
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
ui-debug.log*
# local env files
.env*.local
# typescript
*.tsbuildinfo
# vercel
.vercel
# testing
coverage
# next.js
.next/
out/
# fumadocs
.source
# production
build
dist
apps/docs/public/registry/
# turbo
.turbo
# env
.env
# cursor
.cursor
.cursor/
#llm_context
llm_context/
test_docs
.swc
================================================
FILE: .prettierrc
================================================
{
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2
}
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2024 [Your Name or Organization Name]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# AI PDF Chatbot & Agent Powered by LangChain and LangGraph
This monorepo is a customizable template example of an AI chatbot agent that "ingests" PDF documents, stores embeddings in a vector database (Supabase), and then answers user queries using OpenAI (or another LLM provider) utilising LangChain and LangGraph as orchestration frameworks.
This template is also an accompanying example to the book [Learning LangChain (O'Reilly)](https://www.oreilly.com/library/view/learning-langchain/9781098167271): Building AI and LLM applications with LangChain and LangGraph.
**Here's what the Chatbot UI looks like:**
<img width="1096" alt="Screenshot 2025-02-20 at 05 39 55" src="https://github.com/user-attachments/assets/3a9ddea7-b718-476b-bdae-38839be20c12" />
## Table of Contents
1. [Features](#features)
2. [Architecture Overview](#architecture-overview)
3. [Prerequisites](#prerequisites)
4. [Installation](#installation)
5. [Environment Variables](#environment-variables)
- [Frontend Variables](#frontend-variables)
- [Backend Variables](#backend-variables)
6. [Local Development](#local-development)
- [Running the Backend](#running-the-backend)
- [Running the Frontend](#running-the-frontend)
7. [Usage](#usage)
- [Uploading/Ingesting PDFs](#uploadingingesting-pdfs)
- [Asking Questions](#asking-questions)
- [Viewing Chat History](#viewing-chat-history)
8. [Production Build & Deployment](#production-build--deployment)
9. [Customizing the Agent](#customizing-the-agent)
10. [Troubleshooting](#troubleshooting)
11. [Next Steps](#next-steps)
---
## Features
- **Document Ingestion Graph**: Upload and parse PDFs into `Document` objects, then store vector embeddings into a vector database (we use Supabase in this example).
- **Retrieval Graph**: Handle user questions, decide whether to retrieve documents or give a direct answer, then generate concise responses with references to the retrieved documents.
- **Streaming Responses**: Real-time streaming of partial responses from the server to the client UI.
- **LangGraph Integration**: Built using LangGraph’s state machine approach to orchestrate ingestion and retrieval, visualise your agentic workflow, and debug each step of the graph.
- **Next.js Frontend**: Allows file uploads, real-time chat, and easy extension with React components and Tailwind.
---
## Architecture Overview
```ascii
┌─────────────────────┐ 1. Upload PDFs ┌───────────────────────────┐
│Frontend (Next.js) │ ────────────────────> │Backend (LangGraph) │
│ - React UI w/ chat │ │ - Ingestion Graph │
│ - Upload .pdf files │ <────────────────────┤ + Vector embedding via │
└─────────────────────┘ 2. Confirmation │ SupabaseVectorStore │
(storing embeddings in DB)
┌─────────────────────┐ 3. Ask questions ┌───────────────────────────┐
│Frontend (Next.js) │ ────────────────────> │Backend (LangGraph) │
│ - Chat + SSE stream │ │ - Retrieval Graph │
│ - Display sources │ <────────────────────┤ + Chat model (OpenAI) │
└─────────────────────┘ 4. Streamed answers └───────────────────────────┘
```
- **Supabase** is used as the vector store to store and retrieve relevant documents at query time.
- **OpenAI** (or other LLM providers) is used for language modeling.
- **LangGraph** orchestrates the "graph" steps for ingestion, routing, and generating responses.
- **Next.js** (React) powers the user interface for uploading PDFs and real-time chat.
The system consists of:
- **Backend**: A Node.js/TypeScript service that contains LangGraph agent "graphs" for:
- **Ingestion** (`src/ingestion_graph.ts`) - handles indexing/ingesting documents
- **Retrieval** (`src/retrieval_graph.ts`) - question-answering over the ingested documents
- **Configuration** (`src/shared/configuration.ts`) - handles configuration for the backend api including model providers and vector stores
- **Frontend**: A Next.js/React app that provides a web UI for users to upload PDFs and chat with the AI.
---
## Prerequisites
1. **Node.js v18+** (we recommend Node v20).
2. **Yarn** (or npm, but this monorepo is pre-configured with Yarn).
3. **Supabase project** (if you plan to store embeddings in Supabase; see [Setting up Supabase](https://supabase.com/docs/guides/getting-started)).
- You will need:
- `SUPABASE_URL`
- `SUPABASE_SERVICE_ROLE_KEY`
- A table named `documents` and a function named `match_documents` for vector similarity search (see [LangChain documentation for guidance on setting up the tables](https://js.langchain.com/docs/integrations/vectorstores/supabase/)).
4. **OpenAI API Key** (or another LLM provider’s key, supported by LangChain).
5. **LangChain API Key** (free and optional, but highly recommended for debugging and tracing your LangChain and LangGraph applications). Learn more [here](https://docs.smith.langchain.com/administration/how_to_guides/organization_management/create_account_api_key)
---
## Installation
1. **Clone** the repository:
```bash
git clone https://github.com/mayooear/ai-pdf-chatbot-langchain.git
cd ai-pdf-chatbot-langchain
```
2. Install dependencies (from the monorepo root):
yarn install
3. Configure environment variables in both backend and frontend. See .`env.example` files for details.
## Environment Variables
The project relies on environment variables to configure keys and endpoints. Each sub-project (backend and frontend) has its own .env.example. Copy these to .env and fill in your details.
### Frontend Variables
Create a .env file in frontend:
`cp frontend/.env.example frontend/.env`
```
NEXT_PUBLIC_LANGGRAPH_API_URL=http://localhost:2024
LANGCHAIN_API_KEY=your-langsmith-api-key-here # Optional: LangSmith API key
LANGGRAPH_INGESTION_ASSISTANT_ID=ingestion_graph
LANGGRAPH_RETRIEVAL_ASSISTANT_ID=retrieval_graph
LANGCHAIN_TRACING_V2=true # Optional: Enable LangSmith tracing
LANGCHAIN_PROJECT="pdf-chatbot" # Optional: LangSmith project name
```
### Backend Variables
Create a .env file in backend:
`cp backend/.env.example backend/.env`
```
OPENAI_API_KEY=your-openai-api-key-here
SUPABASE_URL=your-supabase-url-here
SUPABASE_SERVICE_ROLE_KEY=your-supabase-service-role-key-here
LANGCHAIN_TRACING_V2=true # Optional: Enable LangSmith tracing
LANGCHAIN_PROJECT="pdf-chatbot" # Optional: LangSmith project name
```
**Explanation of Environment Variables:**
- `NEXT_PUBLIC_LANGGRAPH_API_URL`: The URL where your LangGraph backend server is running. Defaults to `http://localhost:2024` for local development.
- `LANGCHAIN_API_KEY`: Your LangSmith API key. This is optional, but highly recommended for debugging and tracing your LangChain and LangGraph applications.
- `LANGGRAPH_INGESTION_ASSISTANT_ID`: The ID of the LangGraph assistant for document ingestion. Default is `ingestion_graph`.
- `LANGGRAPH_RETRIEVAL_ASSISTANT_ID`: The ID of the LangGraph assistant for question answering. Default is `retrieval_graph`.
- `LANGCHAIN_TRACING_V2`: Enable tracing to debug your application on the LangSmith platform. Set to `true` to enable.
- `LANGCHAIN_PROJECT`: The name of your LangSmith project.
- `OPENAI_API_KEY`: Your OpenAI API key.
- `SUPABASE_URL`: Your Supabase URL.
- `SUPABASE_SERVICE_ROLE_KEY`: Your Supabase service role key.
## Local Development
This monorepo uses Turborepo to manage both backend and frontend projects. You can run them separately for development.
### Running the Backend
1. Navigate to backend:
```bash
cd backend
```
2. Install dependencies (already done if you ran yarn install at the root).
3. Start LangGraph in dev mode:
```bash
yarn langgraph:dev
```
This will launch a local LangGraph server on port 2024 by default. It should redirect you to a UI for interacting with the LangGraph server. [Langgraph studio guide](https://langchain-ai.github.io/langgraph/concepts/langgraph_studio/)
### Running the Frontend
1. Navigate to frontend:
```bash
cd frontend
```
2. Start the Next.js development server:
```bash
yarn dev
```
This will start a local Next.js development server (by default on port 3000).
Access the UI in your browser at http://localhost:3000.
## Usage
Once both services are running:
1. Use langgraph studio UI to interact with the LangGraph server and ensure the workflow is working as expected.
2. Navigate to http://localhost:3000 to use the chatbot UI.
3. Upload a small PDF document via the file upload button at the bottom of the page. This will trigger the ingestion graph to extract the text and store the embeddings in Supabase via the frontend `app/api/ingest` route.
4. After the ingestion is complete, ask questions in the chat input.
5. The chatbot will trigger the retrieval graph via the `app/api/chat` route to retrieve the most relevant documents from the vector database and use the relevant PDF context (if needed) to answer.
### Uploading/Ingesting PDFs
Click on the paperclip icon in the chat input area.
Select one or more PDF files to upload ensuring a total of max 5, each under 10MB (you can change these threshold values in the `app/api/ingest` route).
The backend processes the PDFs, extracts text, and stores embeddings in Supabase (or your chosen vector store).
### Asking Questions
- Type your question in the chat input field.
- Responses stream in real time. If the system retrieved documents, you’ll see a link to “View Sources” for each chunk of text used in the answer.
### Viewing Chat History
- The system creates a unique thread per user session (frontend). All messages are kept in the state for the session.
- For demonstration purposes, the current example UI does not store the entire conversation beyond the local thread state and is not persistent across sessions. You can extend it to persist threads in a database. However, the "ingested documents" are persistent across sessions as they are stored in a vector database.
## Deploying the Backend
To deploy your LangGraph agent to a cloud service, you can either use LangGraph's cloud as per this [guide](https://langchain-ai.github.io/langgraph/cloud/quick_start/?h=studio#deploy-to-langgraph-cloud) or self-host it as per this [guide](https://langchain-ai.github.io/langgraph/how-tos/deploy-self-hosted/).
## Deploying the Frontend
The frontend can be deployed to any hosting that supports Next.js (Vercel, Netlify, etc.).
Make sure to set relevant environment variables in your deployment environment. In particular, ensure `NEXT_PUBLIC_LANGGRAPH_API_URL` is pointing to your deployed backend URL.
## Customizing the Agent
You can customize the agent on the backend and frontend.
### Backend
- In the configuration file `src/shared/configuration.ts`, you can change the default configs i.e. the vector store, k-value, and filter kwargs, shared between the ingestion and retrieval graphs. On the backend, configs can be used in each node of the graph workflow or from frontend, you can pass a config object into the graph's client.
- You can adjust the prompts in the `src/retrieval_graph/prompts.ts` file.
- If you'd like to change the retrieval model, you can do so in the `src/shared/retrieval.ts` file by adding another retriever function that encapsulates the desired client for the vector store and then updating the `makeRetriever` function to return the new retriever.
### Frontend
- You can modify the file upload restrictions in the `app/api/ingest` route.
- In `constants/graphConfigs.ts`, you can change the default config objects sent to the ingestion and retrieval graphs. These include the model provider, k value (no of source documents to retrieve), and retriever provider (i.e. vector store).
## Troubleshooting
1. .env Not Loaded
- Make sure you copied .env.example to .env in both backend and frontend.
- Check your environment variables are correct and restart the dev server.
2. Supabase Vector Store
- Ensure you have configured your Supabase instance with the documents table and match_documents function. Check the official LangChain docs on Supabase integration.
3. OpenAI Errors
- Double-check your OPENAI_API_KEY. Make sure you have enough credits/quota.
4. LangGraph Not Running
- If yarn langgraph:dev fails, confirm your Node version is >= 18 and that you have all dependencies installed.
5. Network Errors
- Frontend must point to the correct NEXT_PUBLIC_LANGGRAPH_API_URL. By default, it is http://localhost:2024.
## Next Steps
If you'd like to contribute to this project, feel free to open a pull request. Ensure it is well documented and includes tests in the test files.
If you'd like to learn more about building AI chatbots and agents with LangChain and LangGraph, check out the book [Learning LangChain (O'Reilly)](https://www.oreilly.com/library/view/learning-langchain/9781098167271/).
================================================
FILE: backend/.gitignore
================================================
# LangGraph API
.langgraph_api
================================================
FILE: backend/__tests__/ingestion_graph/state.test.ts
================================================
import { Document } from '@langchain/core/documents';
import { reduceDocs } from '../../src/shared/state.js';
describe('IndexStateAnnotation', () => {
describe('docs reducer', () => {
it('should handle adding new documents', () => {
const initialDocs: Document[] = [];
const newDoc = new Document({
pageContent: 'test content',
metadata: { source: 'test.pdf', page: 1 },
});
const result = reduceDocs(initialDocs, [newDoc]);
expect(result).toHaveLength(1);
expect(result[0].pageContent).toBe('test content');
expect(result[0].metadata).toEqual({ source: 'test.pdf', page: 1 });
});
it('should handle merging multiple documents', () => {
const initialDocs = [
new Document({
pageContent: 'initial doc',
metadata: { source: 'initial.pdf', page: 1 },
}),
];
const newDocs = [
new Document({
pageContent: 'new doc 1',
metadata: { source: 'new1.pdf', page: 1 },
}),
new Document({
pageContent: 'new doc 2',
metadata: { source: 'new2.pdf', page: 1 },
}),
];
const result = reduceDocs(initialDocs, newDocs);
expect(result).toHaveLength(3);
expect(result.map((doc: Document) => doc.pageContent)).toEqual([
'initial doc',
'new doc 1',
'new doc 2',
]);
expect(result.map((doc: Document) => doc.metadata.source)).toEqual([
'initial.pdf',
'new1.pdf',
'new2.pdf',
]);
});
it('should handle empty document arrays', () => {
const initialDocs: Document[] = [];
const newDocs: Document[] = [];
const result = reduceDocs(initialDocs, newDocs);
expect(result).toHaveLength(0);
});
it('should handle "delete" action', () => {
const initialDocs = [
new Document({
pageContent: 'to be deleted',
metadata: { source: 'delete.pdf', page: 1 },
}),
];
const result = reduceDocs(initialDocs, 'delete');
expect(result).toHaveLength(0);
});
});
});
================================================
FILE: backend/__tests__/retrieval_graph/integration.test.ts
================================================
import dotenv from 'dotenv';
dotenv.config();
import { graph } from '../../src/retrieval_graph/graph.js';
import { Document } from '@langchain/core/documents';
import { HumanMessage } from '@langchain/core/messages';
import { SupabaseVectorStore } from '@langchain/community/vectorstores/supabase';
import { OpenAIEmbeddings } from '@langchain/openai';
import { createClient } from '@supabase/supabase-js';
/**
* These tests require environment variables to be set:
* OPENAI_API_KEY=your_openai_api_key
* SUPABASE_URL=your_supabase_url
* SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
*
* To run the tests:
* 1. Create a .env file in the backend directory
* 2. Add the above environment variables with your values
* 3. Run: npm test retrieval_graph/integration
*/
describe('Retrieval Graph Integration', () => {
let vectorStore: SupabaseVectorStore;
beforeAll(async () => {
// Check for required environment variables
const requiredEnvVars = {
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
SUPABASE_URL: process.env.SUPABASE_URL,
SUPABASE_SERVICE_ROLE_KEY: process.env.SUPABASE_SERVICE_ROLE_KEY,
};
const missingEnvVars = Object.entries(requiredEnvVars)
.filter(([_, value]) => !value)
.map(([key]) => key);
if (missingEnvVars.length > 0) {
console.error('\nMissing required environment variables:');
console.error(missingEnvVars.join('\n'));
console.error(
'\nPlease create a .env file with the following variables:',
);
console.error('OPENAI_API_KEY=your_openai_api_key');
console.error('SUPABASE_URL=your_supabase_url');
console.error(
'SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key\n',
);
return;
}
try {
// Setup test documents in Supabase
const embeddings = new OpenAIEmbeddings({
model: 'text-embedding-3-small',
});
const supabaseClient = createClient(
process.env.SUPABASE_URL!,
process.env.SUPABASE_SERVICE_ROLE_KEY!,
);
vectorStore = new SupabaseVectorStore(embeddings, {
client: supabaseClient,
tableName: 'documents',
queryName: 'match_documents',
});
// Add test documents with specific, unique information and ensure IDs are set
const testDocs = [
new Document({
pageContent:
'Project XYZ-123 was initiated on March 15, 2024, with a budget of $2.5M. The project lead, Dr. Sarah Chen, established three primary objectives: improving system reliability by 35%, reducing operational costs by 28%, and implementing a new machine learning pipeline with 99.9% uptime.',
metadata: {
source: 'test',
topic: 'project_report',
id: 'test_xyz123',
},
}),
new Document({
pageContent:
'The quarterly security audit for Q1 2024 identified 17 low-priority vulnerabilities and 3 medium-priority issues. Team lead Michael Rodriguez implemented fixes for all medium-priority issues within 48 hours, achieving a new record response time. The remaining issues are scheduled for resolution by April 30, 2024.',
metadata: {
source: 'test',
topic: 'security_audit',
id: 'test_audit_q1_2024',
},
}),
];
// Clean up any existing test documents first
await supabaseClient
.from('documents')
.delete()
.eq('metadata->>source', 'test');
// Add the new test documents
await vectorStore.addDocuments(testDocs);
} catch (error) {
console.error('\nError setting up test environment:');
console.error(error);
console.error('\nPlease ensure:');
console.error('1. Your Supabase credentials are correct');
console.error('2. The documents table exists with the correct schema');
console.error('3. Your OpenAI API key is valid\n');
throw error; // Rethrow to fail the test suite if setup fails
}
}, 30000); // Increased timeout to 30 seconds
afterAll(async () => {
// Clean up test documents only if environment variables are available
if (!process.env.SUPABASE_URL || !process.env.SUPABASE_SERVICE_ROLE_KEY) {
return;
}
try {
const supabaseClient = createClient(
process.env.SUPABASE_URL,
process.env.SUPABASE_SERVICE_ROLE_KEY,
);
// Delete test documents
await supabaseClient
.from('documents')
.delete()
.eq('metadata->>source', 'test');
} catch (error) {
console.error('\nError cleaning up test documents:');
console.error(error);
}
});
// Skip all tests if environment variables are missing
const shouldRunTests = () => {
const hasEnvVars =
process.env.SUPABASE_URL &&
process.env.SUPABASE_SERVICE_ROLE_KEY &&
process.env.OPENAI_API_KEY;
if (!hasEnvVars) {
console.warn('Skipping tests due to missing environment variables');
}
return hasEnvVars;
};
describe('Direct Answer Path', () => {
it('should provide direct answers for general knowledge questions', async () => {
if (!shouldRunTests()) return;
const result = await graph.invoke({
messages: [],
query: 'What is 2+2?',
});
expect(result.messages).toHaveLength(1);
expect(result.messages[0]).toBeInstanceOf(HumanMessage);
const content = String(result.messages[0].content);
expect(content).toContain('4');
}, 30000);
});
describe('Retrieval Path', () => {
it('should retrieve and use context to answer specific project questions', async () => {
if (!shouldRunTests()) return;
const result = await graph.invoke({
messages: [],
query:
'What is the budget for Project XYZ-123 and who is the project lead?',
});
expect(result.messages).toHaveLength(1);
expect(result.documents).toBeDefined();
expect(result.documents.length).toBeGreaterThan(0);
const content = String(result.messages[0].content);
expect(content).toContain('$2.5M');
expect(content).toContain('Dr. Sarah Chen');
}, 30000);
it('should retrieve and provide security audit details', async () => {
if (!shouldRunTests()) return;
const result = await graph.invoke({
messages: [],
query:
'How many security vulnerabilities were found in Q1 2024 and who implemented the fixes?',
});
expect(result.messages).toHaveLength(1);
expect(result.documents).toBeDefined();
expect(result.documents.length).toBeGreaterThan(0);
const content = String(result.messages[0].content);
expect(content).toContain('17 low-priority');
expect(content).toContain('3 medium-priority');
expect(content).toContain('Michael Rodriguez');
}, 30000);
it('should handle questions without relevant context gracefully', async () => {
if (!shouldRunTests()) return;
const result = await graph.invoke({
messages: [],
query: 'What were the Q2 2024 security audit results?',
});
expect(result.messages).toHaveLength(1);
const content = String(result.messages[0].content);
expect(content.toLowerCase()).toMatch(
/(cannot|don't|not|sorry) (find|have|know|answer)/i,
);
}, 30000);
});
describe('Error Cases', () => {
it('should handle malformed queries gracefully', async () => {
if (!shouldRunTests()) return;
const result = await graph.invoke({
messages: [],
query: ' ',
});
expect(result.messages).toHaveLength(1);
const content = String(result.messages[0].content);
expect(content).toBeTruthy();
}, 30000);
});
describe('Message History', () => {
it('should preserve human messages in the conversation history', async () => {
if (!shouldRunTests()) return;
// First query
const result1 = await graph.invoke({
messages: [],
query: 'What is the budget for Project XYZ-123?',
});
// Second query should include history from first query
const result2 = await graph.invoke({
messages: result1.messages,
query: 'Who is the project lead?',
});
// Verify message history structure
expect(result2.messages.length).toBeGreaterThan(1);
// Find human messages in the history
const humanMessages = result2.messages.filter(
(msg) => msg instanceof HumanMessage,
);
const aiMessages = result2.messages.filter(
(msg) => !(msg instanceof HumanMessage),
);
// Verify we have both human and AI messages
expect(humanMessages.length).toBeGreaterThan(0);
expect(aiMessages.length).toBeGreaterThan(0);
// Verify the order - each human message should be followed by an AI message
result2.messages.forEach((msg, index) => {
if (
msg instanceof HumanMessage &&
index < result2.messages.length - 1
) {
expect(result2.messages[index + 1] instanceof HumanMessage).toBe(
false,
);
}
});
// Verify content of messages
expect(String(humanMessages[0].content)).toContain('budget');
expect(String(humanMessages[1].content)).toContain('project lead');
}, 30000);
});
});
================================================
FILE: backend/__tests__/retrieval_graph/promptTemplate.test.ts
================================================
import {
ROUTER_SYSTEM_PROMPT,
RESPONSE_SYSTEM_PROMPT,
} from '../../src/retrieval_graph/prompts.js';
describe('Prompt Templates', () => {
describe('ROUTER_SYSTEM_PROMPT', () => {
it('should format the router prompt correctly', async () => {
const query = 'What is the capital of France?';
const formattedPrompt = await ROUTER_SYSTEM_PROMPT.invoke({
query,
});
expect(formattedPrompt.toString()).toContain(
'You are a routing assistant',
);
expect(formattedPrompt.toString()).toContain(query);
expect(formattedPrompt.toString()).toContain("'retrieve'");
expect(formattedPrompt.toString()).toContain("'direct'");
});
});
describe('RESPONSE_SYSTEM_PROMPT', () => {
it('should format the response prompt correctly', async () => {
const context = 'Paris is the capital of France.';
const question = 'Tell me about the capital of France.';
const formattedPrompt = await RESPONSE_SYSTEM_PROMPT.invoke({
context: 'Paris is the capital of France.',
question: 'Tell me about the capital of France.',
});
console.log(formattedPrompt.toString());
expect(formattedPrompt.toString()).toContain(
'You are an assistant for question-answering tasks',
);
expect(formattedPrompt.toString()).toContain(context);
expect(formattedPrompt.toString()).toContain(question);
});
});
});
================================================
FILE: backend/demo.ts
================================================
import { Client } from '@langchain/langgraph-sdk';
import { graph } from './src/retrieval_graph/graph.js';
import dotenv from 'dotenv';
// Load environment variables from .env file
dotenv.config();
// Environment variables needed:
// LANGGRAPH_API_URL: The URL where your LangGraph server is running
// - For local development: http://localhost:2024 (or your local server port)
// - For LangSmith cloud: https://api.smith.langchain.com
//
const assistant_id = 'retrieval_graph';
async function runDemo() {
// Initialize the LangGraph client
const client = new Client({
apiUrl: process.env.LANGGRAPH_API_URL || 'http://localhost:2024',
});
// Create a new thread for this conversation
console.log('Creating new thread...');
const thread = await client.threads.create({
metadata: {
demo: 'retrieval-graph',
},
});
console.log('Thread created with ID:', thread.thread_id);
// Example question
const question = 'What is this document about?';
console.log('\n=== Streaming Example ===');
console.log('Question:', question);
// Run the graph with streaming
try {
console.log('\nStarting stream...');
const stream = await client.runs.stream(thread.thread_id, assistant_id, {
input: { query: question },
streamMode: ['values', 'messages', 'updates'], // Include all stream types
});
// Process the stream chunks
console.log('\nWaiting for stream chunks...');
for await (const chunk of stream) {
console.log('\nReceived chunk:');
// console.log('Event type:', chunk.event);
if (chunk.event === 'values') {
// console.log('Values data:', JSON.stringify(chunk.data, null, 2));
} else if (chunk.event === 'messages/partial') {
// console.log('Messages data:', JSON.stringify(chunk, null, 2));
} else if (chunk.event === 'updates') {
console.log('Update data:', JSON.stringify(chunk.data, null, 2));
}
}
console.log('\nStream completed.');
const messagesStream = await client.runs.stream(
thread.thread_id,
assistant_id,
{
input: { query: question },
streamMode: 'updates', // Include all stream types
},
);
for await (const chunk of messagesStream) {
console.log('\nReceived chunk:');
console.log('Event type:', chunk.event);
console.log('updates data:', JSON.stringify(chunk.data, null, 2));
}
} catch (error) {
console.error('Error in streaming run:', error);
// Log more details about the error
if (error instanceof Error) {
console.error('Error message:', error.message);
console.error('Error stack:', error.stack);
}
}
}
// Run the demo
runDemo().catch((error) => {
console.error('Fatal error:', error);
process.exit(1);
});
================================================
FILE: backend/ingest-demo.ipynb
================================================
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import { SupabaseVectorStore } from \"@langchain/community/vectorstores/supabase\";\n",
"import { OpenAIEmbeddings } from \"@langchain/openai\";\n",
"import { createClient } from \"@supabase/supabase-js\";\n",
"import dotenv from \"dotenv\";\n",
"dotenv.config();\n",
"\n",
"const embeddings = new OpenAIEmbeddings({\n",
" model: \"text-embedding-3-small\",\n",
" });\n",
"\n",
" const supabaseClient = createClient(\n",
" process.env.SUPABASE_URL ?? '',\n",
" process.env.SUPABASE_SERVICE_ROLE_KEY ?? '',\n",
" );\n",
" const vectorStore = new SupabaseVectorStore(embeddings, {\n",
" client: supabaseClient,\n",
" tableName: 'documents',\n",
" queryName: 'match_documents',\n",
" });\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" pageContent: 'UNITED\\tSTATES\\n' +\n",
" 'SECURITIES\\tAND\\tEXCHANGE\\tCOMMISSION\\n' +\n",
" 'Washington,\\tD.C.\\t20549\\n' +\n",
" 'FORM\\t10-K\\n' +\n",
" '(Mark\\tOne)\\n' +\n",
" 'xANNUAL\\tREPORT\\tPURSUANT\\tTO\\tSECTION\\t13\\tOR\\t15(d)\\tOF\\tTHE\\tSECURITIES\\tEXCHANGE\\tACT\\tOF\\t1934\\n' +\n",
" 'For\\tthe\\tfiscal\\tyear\\tended\\tDecember\\t31,\\t2023\\n' +\n",
" 'OR\\n' +\n",
" 'oTRANSITION\\tREPORT\\tPURSUANT\\tTO\\tSECTION\\t13\\tOR\\t15(d)\\tOF\\tTHE\\tSECURITIES\\tEXCHANGE\\tACT\\tOF\\t1934\\n' +\n",
" 'For\\tthe\\ttransition\\tperiod\\tfrom\\t_________\\tto\\t_________\\n' +\n",
" 'Commission\\tFile\\tNumber:\\t001-34756\\n' +\n",
" 'Tesla,\\tInc.\\n' +\n",
" '(Exact\\tname\\tof\\tregistrant\\tas\\tspecified\\tin\\tits\\tcharter)\\n' +\n",
" 'Delaware91-2197729\\n' +\n",
" '(State\\tor\\tother\\tjurisdiction\\tof\\n' +\n",
" 'incorporation\\tor\\torganization)\\n' +\n",
" '(I.R.S.\\tEmployer\\n' +\n",
" 'Identification\\tNo.)\\n' +\n",
" '1\\tTesla\\tRoad\\n' +\n",
" 'Austin,\\tTexas78725\\n' +\n",
" '(Address\\tof\\tprincipal\\texecutive\\toffices)(Zip\\tCode)\\n' +\n",
" '(512)\\t516-8177\\n' +\n",
" '(Registrant’s\\ttelephone\\tnumber,\\tincluding\\tarea\\tcode)\\n' +\n",
" 'Securities\\tregistered\\tpursuant\\tto\\tSection\\t12(b)\\tof\\tthe\\tAct:\\n' +\n",
" 'Title\\tof\\teach\\tclassTrading\\tSymbol(s)Name\\tof\\teach\\texchange\\ton\\twhich\\tregistered\\n' +\n",
" 'Common\\tstockTSLAThe\\tNasdaq\\tGlobal\\tSelect\\tMarket\\n' +\n",
" 'Securities\\tregistered\\tpursuant\\tto\\tSection\\t12(g)\\tof\\tthe\\tAct:\\n' +\n",
" 'None\\n' +\n",
" 'Indicate\\tby\\tcheck\\tmark\\twhether\\tthe\\tregistrant\\tis\\ta\\twell-known\\tseasoned\\tissuer,\\tas\\tdefined\\tin\\tRule\\t405\\tof\\tthe\\tSecurities\\tAct.\\tYes\\tx\\tNo\\to\\n' +\n",
" 'Indicate\\tby\\tcheck\\tmark\\tif\\tthe\\tregistrant\\tis\\tnot\\trequired\\tto\\tfile\\treports\\tpursuant\\tto\\tSection\\t13\\tor\\t15(d)\\tof\\tthe\\tAct.\\tYes\\to\\tNo\\tx\\n' +\n",
" 'Indicate\\tby\\tcheck\\tmark\\twhether\\tthe\\tregistrant\\t(1)\\thas\\tfiled\\tall\\treports\\trequired\\tto\\tbe\\tfiled\\tby\\tSection\\t13\\tor\\t15(d)\\tof\\tthe\\tSecurities\\tExchange\\tAct\\tof\\t1934\\t(“Exchange\\tAct”)\\n' +\n",
" 'during\\tthe\\tpreceding\\t12\\tmonths\\t(or\\tfor\\tsuch\\tshorter\\tperiod\\tthat\\tthe\\tregistrant\\twas\\trequired\\tto\\tfile\\tsuch\\treports),\\tand\\t(2)\\thas\\tbeen\\tsubject\\tto\\tsuch\\tfiling\\trequirements\\tfor\\tthe\\tpast\\t90\\n' +\n",
" 'days.\\tYes\\tx\\tNo\\to\\n' +\n",
" 'Indicate\\tby\\tcheck\\tmark\\twhether\\tthe\\tregistrant\\thas\\tsubmitted\\telectronically\\tevery\\tInteractive\\tData\\tFile\\trequired\\tto\\tbe\\tsubmitted\\tpursuant\\tto\\tRule\\t405\\tof\\tRegulation\\tS-T\\n' +\n",
" '(§232.405\\tof\\tthis\\tchapter)\\tduring\\tthe\\tpreceding\\t12\\tmonths\\t(or\\tfor\\tsuch\\tshorter\\tperiod\\tthat\\tthe\\tregistrant\\twas\\trequired\\tto\\tsubmit\\tsuch\\tfiles).\\tYes\\tx\\tNo\\to',\n",
" metadata: {\n",
" source: './test_docs/test-tsla-10k-2023.pdf',\n",
" pdf: {\n",
" version: '1.10.100',\n",
" info: [Object],\n",
" metadata: null,\n",
" totalPages: 130\n",
" },\n",
" loc: { pageNumber: 1, lines: [Object] },\n",
" uuid: 'f96c76fd-d49a-476e-8565-29bbe5d60101'\n",
" },\n",
" id: 'f96c76fd-d49a-476e-8565-29bbe5d60101'\n",
"}\n"
]
}
],
"source": [
"import { PDFLoader } from \"@langchain/community/document_loaders/fs/pdf\";\n",
"import { RecursiveCharacterTextSplitter } from \"@langchain/textsplitters\";\n",
"import { writeFile } from \"fs/promises\";\n",
"import { reduceDocs } from \"./src/shared/state.js\";\n",
"\n",
"const pdfPath = \"./test_docs/test-tsla-10k-2023.pdf\"\n",
"\n",
"const loader = new PDFLoader(pdfPath);\n",
"\n",
"const docs = await loader.load();\n",
"\n",
"\n",
"const textSplitter = new RecursiveCharacterTextSplitter({\n",
" chunkSize: 2000,\n",
" chunkOverlap: 50,\n",
" });\n",
"const docSplits = await textSplitter.splitDocuments(docs);\n",
"\n",
"const finalDocs = reduceDocs([], docSplits);\n",
"\n",
" \n",
"finalDocs[0]\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\n",
" 'f96c76fd-d49a-476e-8565-29bbe5d60101',\n",
" 'cf036396-4b2b-46fb-9ca4-20bbd6a3947e',\n",
" 'f725b551-cdad-4b17-9681-6c7ac07742aa',\n",
" '950dc7ea-3040-4e32-926f-3d2ad76598ba',\n",
" 'd756834a-3b9c-4ac4-90f2-5a5bb9a88b89',\n",
" '15dcb874-9a11-414c-a612-4ba9ac78df9b',\n",
" '27c14e27-544b-4e2d-bd30-5271fc1c1945',\n",
" 'c087b995-9b3c-43c9-849e-1ffccfa710e0',\n",
" 'ac0b84ff-f893-4a95-aaad-c79b9951c32e',\n",
" '2f176e4f-1128-47ee-8803-ee004b725458',\n",
" 'b72bf8bd-47be-4392-8781-1fee00cd8028',\n",
" 'f87b847c-07e7-4e87-8a73-533028f7d778',\n",
" 'a2a571cf-bbec-40b6-a5e7-8a33fd36d1dd',\n",
" '2405ac0e-8041-41e6-b8d2-c695a03a8a9a',\n",
" '157becfc-79c8-43f6-941b-df7e62a51811',\n",
" '79d2e706-1212-4a89-85f6-ff117f8a43cc',\n",
" '97353508-c3d5-4c16-9b13-ab792aabd89b',\n",
" 'c63472f4-bd4d-4469-96a5-8eb01cd5fad2',\n",
" '0f221405-317e-4c2a-ac61-7ad049a3bcf4',\n",
" 'de3767fe-d129-4218-b062-4b3c689797a6',\n",
" 'ba25d45b-6d25-467e-bf25-0106088d9da8',\n",
" '4a391f87-1ccb-4f66-8cc8-d7a7f98c1455',\n",
" '844ef3dc-9281-4912-9ddb-52260891237d',\n",
" 'c9b88bc9-6711-4c1d-a44d-878f3c9567d3',\n",
" 'cff9d8f9-0037-4666-a9a6-bbdce8ec6281',\n",
" 'a59d30c4-4ff6-4ade-b7b7-72130510fdc2',\n",
" '8189a997-b7db-412c-a24a-d2ad899996c3',\n",
" '3b84ebcb-83ff-4c28-a820-ba220b1182e0',\n",
" 'cee3e54f-28da-44ba-8e89-3e7190da9c4d',\n",
" '7b8c2bfd-4e60-4dc0-9925-d91f12687bb9',\n",
" '6ee122b7-711c-41b3-8cff-c91c937521fb',\n",
" '90cfc70d-ed91-40df-a950-6156b58a958d',\n",
" 'f65b5f7c-6188-4fbc-97a3-fe4a9a0195ef',\n",
" '93838d7f-cbc1-49c0-b1c3-7346890a33c6',\n",
" '4a151e15-2168-4c82-9328-ec9b38d74a33',\n",
" '468454c2-3de2-4fb9-94d4-0401bd6bbe5a',\n",
" '9ec60200-82d7-4be9-ac08-0b23ec063bbd',\n",
" 'c14d0c79-9fcf-4881-97b9-28a26909623b',\n",
" '5dd44111-2198-4450-a775-a127f1871113',\n",
" '893ebdd6-03c4-4bb0-804c-6450c878a9ea',\n",
" '31a4d42a-7754-4577-8ba3-0a3f8211de83',\n",
" '77d5342d-4ba5-456b-8847-f4035db744fc',\n",
" '99b1d564-b7c2-4ca1-9ffc-32a166750e79',\n",
" 'b42d8825-beb6-408d-a52a-ee173c0145e1',\n",
" 'f8c0c005-4d91-46f7-b814-9b4b13899e30',\n",
" '6ba1713f-edc4-42bd-860b-96919be6571d',\n",
" 'aa5bc2b5-4f0a-4c22-9612-998c5cd69bb1',\n",
" '91b91359-d140-458e-8fab-83ee5453a790',\n",
" '9f0bf3da-5c8e-45aa-bc48-3d4e61c3ebdb',\n",
" '1be204e4-70b0-47fc-b21e-7224eab69a75',\n",
" 'be8393f0-ca5f-45c9-b1d7-986a303d0369',\n",
" '89be8879-eb8b-46a6-82e2-e51792f681b9',\n",
" '2522017c-9477-472d-8108-d76459ba8aa7',\n",
" 'a691255f-4a4c-48ec-a3a3-80aba6c18c79',\n",
" 'd2fb69aa-4717-445f-92cb-508218940968',\n",
" 'db3123f4-4123-46b9-b9f4-0e6e1fa7e3c3',\n",
" '40f718e8-6881-4bb9-9d39-13aab528056d',\n",
" 'a5dbff0a-3b09-4d12-b8ad-654bce0f5dee',\n",
" '6aea630d-a505-49cf-8d10-8174bd4faa15',\n",
" '496d2ee5-ab26-46b4-8b9d-7acc9ea36075',\n",
" 'd34e623c-072f-49d3-9e94-4b70fcda51b2',\n",
" '18e26f1c-e144-4777-8f5f-776de83fb3be',\n",
" '938c7da4-2359-488e-89b8-fb4be3ce5b01',\n",
" 'e6ebe707-26b2-4b18-91cc-a4a331217b2a',\n",
" 'b025fdeb-35b7-46cc-85d1-3ec4ca0caddc',\n",
" 'ddead230-69b3-410d-9eea-e89545dfff25',\n",
" 'fb934adb-735c-4fed-a052-d896ddd437bf',\n",
" 'ae420132-f438-4ff4-b992-3a3ccb69a5ef',\n",
" '38784dc9-ecdd-4759-97a8-4ee22aca4634',\n",
" '9d56a989-f2d2-4ad5-9e49-1898dd6e75f2',\n",
" '18400d6c-ab86-4f50-86aa-4b234b62f009',\n",
" 'a4494df8-bfd6-44c6-b8b2-b81ff61a74fe',\n",
" 'f8f51316-2feb-4b31-9e46-4689bf46787c',\n",
" 'df12bf50-6dd4-492b-9c18-0e2e4841a4a4',\n",
" '34ceec9a-0016-43c0-8c55-7fcfe4495a8b',\n",
" 'bbf9a474-4f3a-4abf-9342-699d2e9fe409',\n",
" '4f6ea7fc-2786-45f1-a4d2-7ecfbd36582a',\n",
" '71767cfe-8200-4971-820b-73129cdc9545',\n",
" '202e0e63-e8a5-4f7d-8484-4d46aad50d7f',\n",
" 'bd131dd5-5d7b-45b1-9799-1ffb62d98797',\n",
" '1feb01f4-846c-494d-a6b8-5f4537fca483',\n",
" 'a2c43dbe-dd5a-49eb-9cf6-38746b7d1f5c',\n",
" 'd8c2ffce-9430-4a0b-8693-1aacca4182dd',\n",
" '315485dc-3489-4d76-872e-265b70a48bed',\n",
" '6068a764-8f01-4cbd-97f5-53350c8a05a0',\n",
" 'c6f489c6-e661-4dd0-a648-94876c401f76',\n",
" 'b807e746-b164-4d77-9920-add981023992',\n",
" 'f326c9c3-fec6-4261-aad3-ca1e6c24e3e0',\n",
" '4c03255a-7007-4b62-89f9-7102969d292b',\n",
" '771daa63-07ad-4342-b1e8-8ea7236b5e03',\n",
" '0dc20776-a46a-49cf-a85e-9d76fd294360',\n",
" 'd6270cad-f2c1-4832-84dd-af0d4b757226',\n",
" '1d105310-5247-4bf1-8594-c8f32b2d1b7e',\n",
" 'bc5e8845-9e7e-4c4d-be6f-46eda519185d',\n",
" 'fd844e2f-d433-46c2-87d6-b3c64535a8a2',\n",
" '7381ceeb-a2b0-4ff9-b72f-3cbf8f1641b8',\n",
" '52751f69-2718-4306-b7ec-57a142906aa2',\n",
" '2772db49-0b98-4c5d-9814-82c5b7439271',\n",
" 'a622b09e-03bd-4a18-a927-5c52dfb9293e',\n",
" '06e6b02a-6967-44d3-aa7f-13cec5746ab3',\n",
" ... 193 more items\n",
"]\n"
]
}
],
"source": [
"const documentIds = finalDocs.map((doc) => doc.id);\n",
"await vectorStore.addDocuments(finalDocs, {ids: documentIds});\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" error: null,\n",
" data: [\n",
" { id: 'f96c76fd-d49a-476e-8565-29bbe5d60101' },\n",
" { id: 'cf036396-4b2b-46fb-9ca4-20bbd6a3947e' },\n",
" { id: 'f725b551-cdad-4b17-9681-6c7ac07742aa' },\n",
" { id: '950dc7ea-3040-4e32-926f-3d2ad76598ba' },\n",
" { id: 'd756834a-3b9c-4ac4-90f2-5a5bb9a88b89' },\n",
" { id: '15dcb874-9a11-414c-a612-4ba9ac78df9b' },\n",
" { id: '27c14e27-544b-4e2d-bd30-5271fc1c1945' },\n",
" { id: 'c087b995-9b3c-43c9-849e-1ffccfa710e0' },\n",
" { id: 'ac0b84ff-f893-4a95-aaad-c79b9951c32e' },\n",
" { id: '2f176e4f-1128-47ee-8803-ee004b725458' },\n",
" { id: 'b72bf8bd-47be-4392-8781-1fee00cd8028' },\n",
" { id: 'f87b847c-07e7-4e87-8a73-533028f7d778' },\n",
" { id: 'a2a571cf-bbec-40b6-a5e7-8a33fd36d1dd' },\n",
" { id: '2405ac0e-8041-41e6-b8d2-c695a03a8a9a' },\n",
" { id: '157becfc-79c8-43f6-941b-df7e62a51811' },\n",
" { id: '79d2e706-1212-4a89-85f6-ff117f8a43cc' },\n",
" { id: '97353508-c3d5-4c16-9b13-ab792aabd89b' },\n",
" { id: 'a59d30c4-4ff6-4ade-b7b7-72130510fdc2' },\n",
" { id: 'c63472f4-bd4d-4469-96a5-8eb01cd5fad2' },\n",
" { id: '0f221405-317e-4c2a-ac61-7ad049a3bcf4' },\n",
" { id: 'de3767fe-d129-4218-b062-4b3c689797a6' },\n",
" { id: 'ba25d45b-6d25-467e-bf25-0106088d9da8' },\n",
" { id: '755a56bf-ba20-4fc6-885b-97b1f1389cca' },\n",
" { id: '4a391f87-1ccb-4f66-8cc8-d7a7f98c1455' },\n",
" { id: '844ef3dc-9281-4912-9ddb-52260891237d' },\n",
" { id: 'c9b88bc9-6711-4c1d-a44d-878f3c9567d3' },\n",
" { id: 'cff9d8f9-0037-4666-a9a6-bbdce8ec6281' },\n",
" { id: '5c1ca925-732a-4eb1-b89e-222149802725' },\n",
" { id: '8189a997-b7db-412c-a24a-d2ad899996c3' },\n",
" { id: '3b84ebcb-83ff-4c28-a820-ba220b1182e0' },\n",
" { id: 'cee3e54f-28da-44ba-8e89-3e7190da9c4d' },\n",
" { id: '7b8c2bfd-4e60-4dc0-9925-d91f12687bb9' },\n",
" { id: '6ee122b7-711c-41b3-8cff-c91c937521fb' },\n",
" { id: '90cfc70d-ed91-40df-a950-6156b58a958d' },\n",
" { id: 'f65b5f7c-6188-4fbc-97a3-fe4a9a0195ef' },\n",
" { id: '93838d7f-cbc1-49c0-b1c3-7346890a33c6' },\n",
" { id: '4a151e15-2168-4c82-9328-ec9b38d74a33' },\n",
" { id: '468454c2-3de2-4fb9-94d4-0401bd6bbe5a' },\n",
" { id: '01bdc318-486d-4fc3-9494-54e89528b837' },\n",
" { id: '9ec60200-82d7-4be9-ac08-0b23ec063bbd' },\n",
" { id: 'c14d0c79-9fcf-4881-97b9-28a26909623b' },\n",
" { id: '5dd44111-2198-4450-a775-a127f1871113' },\n",
" { id: '893ebdd6-03c4-4bb0-804c-6450c878a9ea' },\n",
" { id: '31a4d42a-7754-4577-8ba3-0a3f8211de83' },\n",
" { id: '77d5342d-4ba5-456b-8847-f4035db744fc' },\n",
" { id: '99b1d564-b7c2-4ca1-9ffc-32a166750e79' },\n",
" { id: 'b42d8825-beb6-408d-a52a-ee173c0145e1' },\n",
" { id: '18e26f1c-e144-4777-8f5f-776de83fb3be' },\n",
" { id: 'f8c0c005-4d91-46f7-b814-9b4b13899e30' },\n",
" { id: '6ba1713f-edc4-42bd-860b-96919be6571d' },\n",
" { id: 'aa5bc2b5-4f0a-4c22-9612-998c5cd69bb1' },\n",
" { id: '91b91359-d140-458e-8fab-83ee5453a790' },\n",
" { id: 'bbf9a474-4f3a-4abf-9342-699d2e9fe409' },\n",
" { id: '9f0bf3da-5c8e-45aa-bc48-3d4e61c3ebdb' },\n",
" { id: '1be204e4-70b0-47fc-b21e-7224eab69a75' },\n",
" { id: 'be8393f0-ca5f-45c9-b1d7-986a303d0369' },\n",
" { id: '89be8879-eb8b-46a6-82e2-e51792f681b9' },\n",
" { id: '6068a764-8f01-4cbd-97f5-53350c8a05a0' },\n",
" { id: '2522017c-9477-472d-8108-d76459ba8aa7' },\n",
" { id: 'a691255f-4a4c-48ec-a3a3-80aba6c18c79' },\n",
" { id: 'd2fb69aa-4717-445f-92cb-508218940968' },\n",
" { id: 'db3123f4-4123-46b9-b9f4-0e6e1fa7e3c3' },\n",
" { id: '40f718e8-6881-4bb9-9d39-13aab528056d' },\n",
" { id: 'a5dbff0a-3b09-4d12-b8ad-654bce0f5dee' },\n",
" { id: '6aea630d-a505-49cf-8d10-8174bd4faa15' },\n",
" { id: '496d2ee5-ab26-46b4-8b9d-7acc9ea36075' },\n",
" { id: 'd34e623c-072f-49d3-9e94-4b70fcda51b2' },\n",
" { id: '938c7da4-2359-488e-89b8-fb4be3ce5b01' },\n",
" { id: 'e6ebe707-26b2-4b18-91cc-a4a331217b2a' },\n",
" { id: 'b025fdeb-35b7-46cc-85d1-3ec4ca0caddc' },\n",
" { id: 'ddead230-69b3-410d-9eea-e89545dfff25' },\n",
" { id: 'e00c5fe1-c425-4bea-9c37-0836c2c6befa' },\n",
" { id: 'fb934adb-735c-4fed-a052-d896ddd437bf' },\n",
" { id: 'ae420132-f438-4ff4-b992-3a3ccb69a5ef' },\n",
" { id: '38784dc9-ecdd-4759-97a8-4ee22aca4634' },\n",
" { id: '9d56a989-f2d2-4ad5-9e49-1898dd6e75f2' },\n",
" { id: 'fd844e2f-d433-46c2-87d6-b3c64535a8a2' },\n",
" { id: '18400d6c-ab86-4f50-86aa-4b234b62f009' },\n",
" { id: 'a4494df8-bfd6-44c6-b8b2-b81ff61a74fe' },\n",
" { id: 'f8f51316-2feb-4b31-9e46-4689bf46787c' },\n",
" { id: 'df12bf50-6dd4-492b-9c18-0e2e4841a4a4' },\n",
" { id: '34ceec9a-0016-43c0-8c55-7fcfe4495a8b' },\n",
" { id: '4f6ea7fc-2786-45f1-a4d2-7ecfbd36582a' },\n",
" { id: '71767cfe-8200-4971-820b-73129cdc9545' },\n",
" { id: '202e0e63-e8a5-4f7d-8484-4d46aad50d7f' },\n",
" { id: 'bd131dd5-5d7b-45b1-9799-1ffb62d98797' },\n",
" { id: 'a565e1b0-c95b-4e11-a3d6-c63866c31261' },\n",
" { id: '1feb01f4-846c-494d-a6b8-5f4537fca483' },\n",
" { id: 'a2c43dbe-dd5a-49eb-9cf6-38746b7d1f5c' },\n",
" { id: 'd8c2ffce-9430-4a0b-8693-1aacca4182dd' },\n",
" { id: '315485dc-3489-4d76-872e-265b70a48bed' },\n",
" { id: '4ff4df53-51dd-4735-b7ec-1ad08951e16e' },\n",
" { id: 'c6f489c6-e661-4dd0-a648-94876c401f76' },\n",
" { id: 'b807e746-b164-4d77-9920-add981023992' },\n",
" { id: 'f326c9c3-fec6-4261-aad3-ca1e6c24e3e0' },\n",
" { id: '4c03255a-7007-4b62-89f9-7102969d292b' },\n",
" { id: '771daa63-07ad-4342-b1e8-8ea7236b5e03' },\n",
" { id: '0dc20776-a46a-49cf-a85e-9d76fd294360' },\n",
" { id: 'd6270cad-f2c1-4832-84dd-af0d4b757226' },\n",
" { id: '1d105310-5247-4bf1-8594-c8f32b2d1b7e' },\n",
" ... 193 more items\n",
" ],\n",
" count: 293,\n",
" status: 200,\n",
" statusText: 'OK'\n",
"}\n"
]
}
],
"source": [
"//count the number of documents in the vector store\n",
"\n",
"await vectorStore.client.from('documents').select('id', { count: \n",
"'exact'});\n"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\n",
" Document {\n",
" pageContent: 'security\\tincidents,\\twhich\\tcould\\tresult\\tin\\tdata\\tbreaches,\\tintellectual\\tproperty\\ttheft,\\tclaims,\\tlitigation,\\tregulatory\\tinvestigations,\\tsignificant\\tliability,\\n' +\n",
" 'reputational\\tdamage\\tand\\tother\\tadverse\\tconsequences”\\tincluded\\tas\\tpart\\tof\\tour\\trisk\\tfactor\\tdisclosures\\tat\\tItem\\t1A\\tof\\tthis\\tAnnual\\tReport\\ton\\tForm\\t10-K.\\n' +\n",
" 'Cybersecurity\\tGovernance\\n' +\n",
" 'Cybersecurity\\tis\\tan\\timportant\\tpart\\tof\\tour\\trisk\\tmanagement\\tprocesses\\tand\\tan\\tarea\\tof\\tfocus\\tfor\\tour\\tBoard\\tand\\tmanagement.\\tOur\\tAudit\\tCommittee\\tis\\n' +\n",
" 'responsible\\tfor\\tthe\\toversight\\tof\\trisks\\tfrom\\tcybersecurity\\tthreats.\\tMembers\\tof\\tthe\\tAudit\\tCommittee\\treceive\\tupdates\\ton\\ta\\tquarterly\\tbasis\\tfrom\\tsenior\\n' +\n",
" 'management,\\tincluding\\tleaders\\tfrom\\tour\\tInformation\\tSecurity,\\tProduct\\tSecurity,\\tCompliance\\tand\\tLegal\\tteams\\tregarding\\tmatters\\tof\\tcybersecurity.\\tThis\\n' +\n",
" 'includes\\texisting\\tand\\tnew\\tcybersecurity\\trisks,\\tstatus\\ton\\thow\\tmanagement\\tis\\taddressing\\tand/or\\tmitigating\\tthose\\trisks,\\tcybersecurity\\tand\\tdata\\tprivacy\\n' +\n",
" 'incidents\\t(if\\tany)\\tand\\tstatus\\ton\\tkey\\tinformation\\tsecurity\\tinitiatives.\\tOur\\tBoard\\tmembers\\talso\\tengage\\tin\\tad\\thoc\\tconversations\\twith\\tmanagement\\ton\\n' +\n",
" 'cybersecurity-related\\tnews\\tevents\\tand\\tdiscuss\\tany\\tupdates\\tto\\tour\\tcybersecurity\\trisk\\tmanagement\\tand\\tstrategy\\tprograms.\\n' +\n",
" '29',\n",
" metadata: {\n",
" loc: [Object],\n",
" pdf: [Object],\n",
" uuid: '6068a764-8f01-4cbd-97f5-53350c8a05a0',\n",
" source: './test_docs/test-tsla-10k-2023.pdf'\n",
" },\n",
" id: undefined\n",
" },\n",
" Document {\n",
" pageContent: 'Risks\\tRelated\\tto\\tOur\\tAbility\\tto\\tGrow\\tOur\\tBusiness\\n' +\n",
" 'We\\tmay\\texperience\\tdelays\\tin\\tlaunching\\tand\\tramping\\tthe\\tproduction\\tof\\tour\\tproducts\\tand\\tfeatures,\\tor\\twe\\tmay\\tbe\\tunable\\tto\\tcontrol\\n' +\n",
" 'our\\tmanufacturing\\tcosts.\\n' +\n",
" 'We\\thave\\tpreviously\\texperienced\\tand\\tmay\\tin\\tthe\\tfuture\\texperience\\tlaunch\\tand\\tproduction\\tramp\\tdelays\\tfor\\tnew\\tproducts\\tand\\tfeatures.\\tFor\\texample,\\n' +\n",
" 'we\\tencountered\\tunanticipated\\tsupplier\\tissues\\tthat\\tled\\tto\\tdelays\\tduring\\tthe\\tinitial\\tramp\\tof\\tour\\tfirst\\tModel\\tX\\tand\\texperienced\\tchallenges\\twith\\ta\\tsupplier\\tand\\n' +\n",
" 'with\\tramping\\tfull\\tautomation\\tfor\\tcertain\\tof\\tour\\tinitial\\tModel\\t3\\tmanufacturing\\tprocesses.\\tIn\\taddition,\\twe\\tmay\\tintroduce\\tin\\tthe\\tfuture\\tnew\\tor\\tunique\\n' +\n",
" 'manufacturing\\tprocesses\\tand\\tdesign\\tfeatures\\tfor\\tour\\tproducts.\\tAs\\twe\\texpand\\tour\\tvehicle\\tofferings\\tand\\tglobal\\tfootprint,\\tthere\\tis\\tno\\tguarantee\\tthat\\twe\\twill\\n' +\n",
" 'be\\table\\tto\\tsuccessfully\\tand\\ttimely\\tintroduce\\tand\\tscale\\tsuch\\tprocesses\\tor\\tfeatures.\\n' +\n",
" '14',\n",
" metadata: {\n",
" loc: [Object],\n",
" pdf: [Object],\n",
" uuid: '4a151e15-2168-4c82-9328-ec9b38d74a33',\n",
" source: './test_docs/test-tsla-10k-2023.pdf'\n",
" },\n",
" id: undefined\n",
" },\n",
" Document {\n",
" pageContent: 'Employees\\tare\\tencouraged\\tto\\tspeak\\tup\\tboth\\tin\\tregard\\tto\\tmisconduct\\tand\\tsafety\\tconcerns\\tand\\tcan\\tdo\\tso\\tby\\tcontacting\\tthe\\tintegrity\\tline,\\tsubmitting\\n' +\n",
" 'concerns\\tthrough\\tour\\tTake\\tCharge\\tprocess,\\tor\\tnotifying\\ttheir\\tHuman\\tResource\\tPartner\\tor\\tany\\tmember\\tof\\tmanagement.\\tConcerns\\tare\\treviewed\\tin\\n' +\n",
" 'accordance\\twith\\testablished\\tprotocols\\tby\\tinvestigators\\twith\\texpertise,\\twho\\talso\\treview\\tfor\\ttrends\\tand\\toutcomes\\tfor\\tremediation\\tand\\tappropriate\\tcontrols.\\n' +\n",
" 'Responding\\tto\\tquestions\\ttimely\\tis\\tkey\\tso\\tHuman\\tResource\\tPartners\\tfor\\teach\\tfunctional\\tarea\\tare\\tvisible\\tthroughout\\tfacilities\\tand\\tare\\tactively\\tinvolved\\tin\\n' +\n",
" 'driving\\tculture\\tand\\tengagement\\talongside\\tbusiness\\tleaders.\\n' +\n",
" 'Available\\tInformation\\n' +\n",
" 'We\\tfile\\tor\\tfurnish\\tperiodic\\treports\\tand\\tamendments\\tthereto,\\tincluding\\tour\\tAnnual\\tReports\\ton\\tForm\\t10-K,\\tour\\tQuarterly\\tReports\\ton\\tForm\\t10-Q\\tand\\n' +\n",
" 'Current\\tReports\\ton\\tForm\\t8-K,\\tproxy\\tstatements\\tand\\tother\\tinformation\\twith\\tthe\\tSEC.\\tIn\\taddition,\\tthe\\tSEC\\tmaintains\\ta\\twebsite\\t(www.sec.gov)\\tthat\\tcontains\\n' +\n",
" 'reports,\\tproxy\\tand\\tinformation\\tstatements,\\tand\\tother\\tinformation\\tregarding\\tissuers\\tthat\\tfile\\telectronically.\\tOur\\twebsite\\tis\\tlocated\\tat\\twww.tesla.com,\\tand\\n' +\n",
" 'our\\treports,\\tamendments\\tthereto,\\tproxy\\tstatements\\tand\\tother\\tinformation\\tare\\talso\\tmade\\tavailable,\\tfree\\tof\\tcharge,\\ton\\tour\\tinvestor\\trelations\\twebsite\\tat\\n' +\n",
" 'ir.tesla.com\\tas\\tsoon\\tas\\treasonably\\tpracticable\\tafter\\twe\\telectronically\\tfile\\tor\\tfurnish\\tsuch\\tinformation\\twith\\tthe\\tSEC.\\tThe\\tinformation\\tposted\\ton\\tour\\twebsite\\n' +\n",
" 'is\\tnot\\tincorporated\\tby\\treference\\tinto\\tthis\\tAnnual\\tReport\\ton\\tForm\\t10-K.\\n' +\n",
" 'ITEM\\t1A.\\tRISK\\tFACTORS\\n' +\n",
" 'You\\tshould\\tcarefully\\tconsider\\tthe\\trisks\\tdescribed\\tbelow\\ttogether\\twith\\tthe\\tother\\tinformation\\tset\\tforth\\tin\\tthis\\treport,\\twhich\\tcould\\tmaterially\\taffect\\tour\\n' +\n",
" 'business,\\tfinancial\\tcondition\\tand\\tfuture\\tresults.\\tThe\\trisks\\tdescribed\\tbelow\\tare\\tnot\\tthe\\tonly\\trisks\\tfacing\\tour\\tcompany.\\tRisks\\tand\\tuncertainties\\tnot\\tcurrently\\n' +\n",
" 'known\\tto\\tus\\tor\\tthat\\twe\\tcurrently\\tdeem\\tto\\tbe\\timmaterial\\talso\\tmay\\tmaterially\\tadversely\\taffect\\tour\\tbusiness,\\tfinancial\\tcondition\\tand\\toperating\\tresults.',\n",
" metadata: {\n",
" loc: [Object],\n",
" pdf: [Object],\n",
" uuid: '93838d7f-cbc1-49c0-b1c3-7346890a33c6',\n",
" source: './test_docs/test-tsla-10k-2023.pdf'\n",
" },\n",
" id: undefined\n",
" },\n",
" Document {\n",
" pageContent: 'damage,\\tinterruptions,\\tsystem\\tmalfunctions,\\tpower\\toutages,\\tterrorism,\\tacts\\tof\\tvandalism,\\tsecurity\\tbreaches,\\tsecurity\\tincidents,\\tinadvertent\\tor\\tintentional\\n' +\n",
" 'actions\\tby\\temployees\\tor\\tother\\tthird\\tparties,\\tand\\tother\\tcyber-attacks.\\n' +\n",
" 'To\\tthe\\textent\\tany\\tsecurity\\tincident\\tresults\\tin\\tunauthorized\\taccess\\tor\\tdamage\\tto\\tor\\tacquisition,\\tuse,\\tcorruption,\\tloss,\\tdestruction,\\talteration\\tor\\n' +\n",
" 'dissemination\\tof\\tour\\tdata,\\tincluding\\tintellectual\\tproperty\\tand\\tpersonal\\tinformation,\\tor\\tour\\tproducts\\tor\\tvehicles,\\tor\\tfor\\tit\\tto\\tbe\\tbelieved\\tor\\treported\\tthat\\tany\\n' +\n",
" 'of\\tthese\\toccurred,\\tit\\tcould\\tdisrupt\\tour\\tbusiness,\\tharm\\tour\\treputation,\\tcompel\\tus\\tto\\tcomply\\twith\\tapplicable\\tdata\\tbreach\\tnotification\\tlaws,\\tsubject\\tus\\tto\\ttime\\n' +\n",
" 'consuming,\\tdistracting\\tand\\texpensive\\tlitigation,\\tregulatory\\tinvestigation\\tand\\toversight,\\tmandatory\\tcorrective\\taction,\\trequire\\tus\\tto\\tverify\\tthe\\tcorrectness\\n' +\n",
" 'of\\tdatabase\\tcontents,\\tor\\totherwise\\tsubject\\tus\\tto\\tliability\\tunder\\tlaws,\\tregulations\\tand\\tcontractual\\tobligations,\\tincluding\\tthose\\tthat\\tprotect\\tthe\\tprivacy\\tand\\n' +\n",
" 'security\\tof\\tpersonal\\tinformation.\\tThis\\tcould\\tresult\\tin\\tincreased\\tcosts\\tto\\tus\\tand\\tresult\\tin\\tsignificant\\tlegal\\tand\\tfinancial\\texposure\\tand/or\\treputational\\tharm.\\n' +\n",
" 'We\\talso\\trely\\ton\\tservice\\tproviders,\\tand\\tsimilar\\tincidents\\trelating\\tto\\ttheir\\tinformation\\ttechnology\\tsystems\\tcould\\talso\\thave\\ta\\tmaterial\\tadverse\\teffect\\ton\\n' +\n",
" 'our\\tbusiness.\\tThere\\thave\\tbeen\\tand\\tmay\\tcontinue\\tto\\tbe\\tsignificant\\tsupply\\tchain\\tattacks.\\tOur\\tservice\\tproviders,\\tincluding\\tour\\tworkforce\\tmanagement\\n' +\n",
" 'software\\tprovider,\\thave\\tbeen\\tsubject\\tto\\transomware\\tand\\tother\\tsecurity\\tincidents,\\tand\\twe\\tcannot\\tguarantee\\tthat\\tour\\tor\\tour\\tservice\\tproviders’\\tsystems\\n' +\n",
" 'have\\tnot\\tbeen\\tbreached\\tor\\tthat\\tthey\\tdo\\tnot\\tcontain\\texploitable\\tdefects,\\tbugs,\\tor\\tvulnerabilities\\tthat\\tcould\\tresult\\tin\\ta\\tsecurity\\tincident,\\tor\\tother\\tdisruption\\n' +\n",
" 'to,\\tour\\tor\\tour\\tservice\\tproviders’\\tsystems.\\tOur\\tability\\tto\\tmonitor\\tour\\tservice\\tproviders’\\tsecurity\\tmeasures\\tis\\tlimited,\\tand,\\tin\\tany\\tevent,\\tmalicious\\tthird\\n' +\n",
" 'parties\\tmay\\tbe\\table\\tto\\tcircumvent\\tthose\\tsecurity\\tmeasures.',\n",
" metadata: {\n",
" loc: [Object],\n",
" pdf: [Object],\n",
" uuid: '40f718e8-6881-4bb9-9d39-13aab528056d',\n",
" source: './test_docs/test-tsla-10k-2023.pdf'\n",
" },\n",
" id: undefined\n",
" }\n",
"]\n"
]
}
],
"source": [
"await vectorStore.similaritySearch(\"risk factors\");"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"AIMessage {\n",
" \"id\": \"chatcmpl-AvntuDz8xFKGEO0DZMK5vBU0xcFZL\",\n",
" \"content\": \"The name of the company in the report is Tesla, Inc.\",\n",
" \"additional_kwargs\": {},\n",
" \"response_metadata\": {\n",
" \"tokenUsage\": {\n",
" \"promptTokens\": 1653,\n",
" \"completionTokens\": 14,\n",
" \"totalTokens\": 1667\n",
" },\n",
" \"finish_reason\": \"stop\",\n",
" \"model_name\": \"gpt-4o-2024-08-06\",\n",
" \"usage\": {\n",
" \"prompt_tokens\": 1653,\n",
" \"completion_tokens\": 14,\n",
" \"total_tokens\": 1667,\n",
" \"prompt_tokens_details\": {\n",
" \"cached_tokens\": 0,\n",
" \"audio_tokens\": 0\n",
" },\n",
" \"completion_tokens_details\": {\n",
" \"reasoning_tokens\": 0,\n",
" \"audio_tokens\": 0,\n",
" \"accepted_prediction_tokens\": 0,\n",
" \"rejected_prediction_tokens\": 0\n",
" }\n",
" },\n",
" \"system_fingerprint\": \"fp_50cad350e4\"\n",
" },\n",
" \"tool_calls\": [],\n",
" \"invalid_tool_calls\": [],\n",
" \"usage_metadata\": {\n",
" \"output_tokens\": 14,\n",
" \"input_tokens\": 1653,\n",
" \"total_tokens\": 1667,\n",
" \"input_token_details\": {\n",
" \"audio\": 0,\n",
" \"cache_read\": 0\n",
" },\n",
" \"output_token_details\": {\n",
" \"audio\": 0,\n",
" \"reasoning\": 0\n",
" }\n",
" }\n",
"}\n"
]
}
],
"source": [
"import { pull } from \"langchain/hub\";\n",
"import { ChatPromptTemplate } from \"@langchain/core/prompts\";\n",
"import { z } from \"zod\";\n",
"import { ChatOpenAI } from \"@langchain/openai\";\n",
"\n",
"const retriever = vectorStore.asRetriever({\n",
" k: 2,\n",
"})\n",
"\n",
"const answerSchema = z.object({\n",
" answer: z.string().describe(\"The answer to the question\"),\n",
" sources: z.array(z.string()).describe(\"The full text of the documents used to answer the question\"),\n",
"});\n",
"\n",
"const llm = new ChatOpenAI({\n",
" model: \"gpt-4o\",\n",
" temperature: 0,\n",
" })\n",
"\n",
"\n",
"const promptTemplate = await pull<ChatPromptTemplate>(\"rlm/rag-prompt\");\n",
"\n",
"const query = \"What is the name of the company in the report?\"\n",
"\n",
"const retrievedDocs = await retriever.invoke(query)\n",
"\n",
"const formattedPrompt = await promptTemplate.invoke({\n",
" context: retrievedDocs,\n",
" question: query,\n",
"});\n",
"\n",
"const response = await llm.invoke(formattedPrompt);\n",
"\n",
"console.log(response);\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" error: {\n",
" code: '22P02',\n",
" details: null,\n",
" hint: null,\n",
" message: 'invalid input syntax for type uuid: \"\"'\n",
" },\n",
" data: null,\n",
" count: null,\n",
" status: 400,\n",
" statusText: 'Bad Request'\n",
"}\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"UncaughtException: Error: Unexpected pending rebuildTimer\n",
" at sys.setTimeout (/opt/homebrew/lib/node_modules/tslab/dist/converter.js:111:19)\n",
" at Object.scheduleInvalidateResolutionsOfFailedLookupLocations (/opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:122719:55)\n",
" at scheduleInvalidateResolutionOfFailedLookupLocation (/opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:121553:22)\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:121474:9\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:5810:11\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:5560:101\n",
" at Array.forEach (<anonymous>)\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:5560:85\n",
" at FSWatcher.callbackChangingToMissingFileSystemEntry (/opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:6104:11)\n",
" at FSWatcher.emit (node:events:518:28)\n",
"UncaughtException: Error: Unexpected pending rebuildTimer\n",
" at sys.setTimeout (/opt/homebrew/lib/node_modules/tslab/dist/converter.js:111:19)\n",
" at Object.scheduleInvalidateResolutionsOfFailedLookupLocations (/opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:122719:55)\n",
" at scheduleInvalidateResolutionOfFailedLookupLocation (/opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:121553:22)\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:121474:9\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:5810:11\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:5560:101\n",
" at Array.forEach (<anonymous>)\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:5560:85\n",
" at FSWatcher.callbackChangingToMissingFileSystemEntry (/opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:6104:11)\n",
" at FSWatcher.emit (node:events:518:28)\n",
"UncaughtException: Error: Unexpected pending rebuildTimer\n",
" at sys.setTimeout (/opt/homebrew/lib/node_modules/tslab/dist/converter.js:111:19)\n",
" at Object.scheduleInvalidateResolutionsOfFailedLookupLocations (/opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:122719:55)\n",
" at scheduleInvalidateResolutionOfFailedLookupLocation (/opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:121553:22)\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:121474:9\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:5810:11\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:5560:101\n",
" at Array.forEach (<anonymous>)\n",
" at /opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:5560:85\n",
" at FSWatcher.callbackChangingToMissingFileSystemEntry (/opt/homebrew/lib/node_modules/tslab/node_modules/@tslab/typescript-for-tslab/lib/typescript.js:6104:11)\n",
" at FSWatcher.emit (node:events:518:28)\n"
]
}
],
"source": [
"// delete all documents from the vector store\n",
"\n",
"await vectorStore.client.from('documents').delete().neq('id', '');\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "TypeScript",
"language": "typescript",
"name": "tslab"
},
"language_info": {
"codemirror_mode": {
"mode": "typescript",
"name": "javascript",
"typescript": true
},
"file_extension": ".ts",
"mimetype": "text/typescript",
"name": "typescript",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
================================================
FILE: backend/jest.config.js
================================================
/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
preset: 'ts-jest',
testEnvironment: 'node',
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
useESM: true,
},
],
},
// Test configuration
testMatch: ['**/__tests__/**/*.test.ts'],
// Coverage configuration
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/**/*.d.ts',
'!src/**/*.test.ts',
],
coveragePathIgnorePatterns: ['/node_modules/', '/__tests__/', '/dist/'],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
coverageDirectory: 'coverage',
// Helpful test output
verbose: true,
};
================================================
FILE: backend/langgraph.json
================================================
{
"node_version": "20",
"graphs": {
"ingestion_graph": "./src/ingestion_graph/graph.ts:graph",
"retrieval_graph": "./src/retrieval_graph/graph.ts:graph"
},
"env": ".env",
"dependencies":["."]
}
================================================
FILE: backend/package.json
================================================
{
"name": "backend",
"version": "0.0.1",
"description": "Chat with your PDF using this AI agent",
"author": "Mayo Oshin",
"license": "MIT",
"private": true,
"type": "module",
"scripts": {
"build": "tsc",
"clean": "rm -rf dist",
"demo": "npx tsx demo.ts",
"test": "jest",
"test:watch": "jest --watch",
"test:changed": "jest --onlyChanged --passWithNoTests",
"test:related": "jest --findRelatedTests",
"test:coverage": "jest --coverage",
"test:int": "jest --testPathPattern=\\.int\\.test\\.ts$",
"format": "prettier --write .",
"format:check": "prettier --check .",
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"lint:langgraph-json": "node scripts/checkLanggraphPaths.js",
"lint:all": "yarn lint & yarn lint:langgraph-json",
"langgraph:dev": "npx @langchain/langgraph-cli dev"
},
"dependencies": {
"@langchain/community": "^0.3.26",
"@langchain/core": "^0.3.32",
"@langchain/langgraph": "^0.2.41",
"@langchain/langgraph-cli": "^0.0.1",
"@langchain/langgraph-sdk": "^0.0.36",
"@langchain/openai": "^0.3.17",
"@mendable/firecrawl-js": "^1.15.7",
"@supabase/supabase-js": "^2.48.1",
"chromadb": "^1.10.4",
"pdf-parse": "^1.1.1",
"uuid": "^11.0.5",
"ws": "^8.18.0",
"zod": "^3.24.1"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.9.1",
"@jest/globals": "^29.7.0",
"@tsconfig/recommended": "^1.0.7",
"@types/jest": "^29.5.0",
"@types/node": "^22.10.6",
"@typescript-eslint/eslint-plugin": "5.59.8",
"@typescript-eslint/parser": "5.59.8",
"cross-env": "^7.0.3",
"dotenv": "^16.4.7",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-no-instanceof": "^1.0.1",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"ts-jest": "^29.2.5",
"tsx": "^4.19.2",
"typescript": "^5.3.3"
}
}
================================================
FILE: backend/src/ingestion_graph/configuration.ts
================================================
import { Annotation } from '@langchain/langgraph';
import { RunnableConfig } from '@langchain/core/runnables';
import {
BaseConfigurationAnnotation,
ensureBaseConfiguration,
} from '../shared/configuration.js';
// This file contains sample documents to index, based on the following LangChain and LangGraph documentation pages:
const DEFAULT_DOCS_FILE = './src/sample_docs.json';
/**
* The configuration for the indexing process.
*/
export const IndexConfigurationAnnotation = Annotation.Root({
...BaseConfigurationAnnotation.spec,
/**
* Path to a JSON file containing default documents to index.
*/
docsFile: Annotation<string>,
useSampleDocs: Annotation<boolean>,
});
/**
* Create an typeof IndexConfigurationAnnotation.State instance from a RunnableConfig object.
*
* @param config - The configuration object to use.
* @returns An instance of typeof IndexConfigurationAnnotation.State with the specified configuration.
*/
export function ensureIndexConfiguration(
config: RunnableConfig,
): typeof IndexConfigurationAnnotation.State {
const configurable = (config?.configurable || {}) as Partial<
typeof IndexConfigurationAnnotation.State
>;
const baseConfig = ensureBaseConfiguration(config);
return {
...baseConfig,
docsFile: configurable.docsFile || DEFAULT_DOCS_FILE,
useSampleDocs: configurable.useSampleDocs || false,
};
}
================================================
FILE: backend/src/ingestion_graph/graph.ts
================================================
/**
* This "graph" simply exposes an endpoint for a user to upload docs to be indexed.
*/
import { RunnableConfig } from '@langchain/core/runnables';
import { StateGraph, END, START } from '@langchain/langgraph';
import fs from 'fs/promises';
import { IndexStateAnnotation } from './state.js';
import { makeRetriever } from '../shared/retrieval.js';
import {
ensureIndexConfiguration,
IndexConfigurationAnnotation,
} from './configuration.js';
import { reduceDocs } from '../shared/state.js';
async function ingestDocs(
state: typeof IndexStateAnnotation.State,
config?: RunnableConfig,
): Promise<typeof IndexStateAnnotation.Update> {
if (!config) {
throw new Error('Configuration required to run index_docs.');
}
const configuration = ensureIndexConfiguration(config);
let docs = state.docs;
if (!docs || docs.length === 0) {
if (configuration.useSampleDocs) {
const fileContent = await fs.readFile(configuration.docsFile, 'utf-8');
const serializedDocs = JSON.parse(fileContent);
docs = reduceDocs([], serializedDocs);
} else {
throw new Error('No sample documents to index.');
}
} else {
docs = reduceDocs([], docs);
}
const retriever = await makeRetriever(config);
await retriever.addDocuments(docs);
return { docs: 'delete' };
}
// Define the graph
const builder = new StateGraph(
IndexStateAnnotation,
IndexConfigurationAnnotation,
)
.addNode('ingestDocs', ingestDocs)
.addEdge(START, 'ingestDocs')
.addEdge('ingestDocs', END);
// Compile into a graph object that you can invoke and deploy.
export const graph = builder
.compile()
.withConfig({ runName: 'IngestionGraph' });
================================================
FILE: backend/src/ingestion_graph/state.ts
================================================
import { Annotation } from '@langchain/langgraph';
import { Document } from '@langchain/core/documents';
import { reduceDocs } from '../shared/state.js';
/**
* Represents the state for document indexing and retrieval.
*
* This interface defines the structure of the index state, which includes
* the documents to be indexed and the retriever used for searching
* these documents.
*/
export const IndexStateAnnotation = Annotation.Root({
/**
* A list of documents that the agent can index.
*/
docs: Annotation<
Document[],
Document[] | { [key: string]: any }[] | string[] | string | 'delete'
>({
default: () => [],
reducer: reduceDocs,
}),
});
export type IndexStateType = typeof IndexStateAnnotation.State;
================================================
FILE: backend/src/retrieval_graph/configuration.ts
================================================
import { Annotation } from '@langchain/langgraph';
import { RunnableConfig } from '@langchain/core/runnables';
import {
BaseConfigurationAnnotation,
ensureBaseConfiguration,
} from '../shared/configuration.js';
/**
* The configuration for the agent.
*/
export const AgentConfigurationAnnotation = Annotation.Root({
...BaseConfigurationAnnotation.spec,
// models
/**
* The language model used for processing and refining queries.
* Should be in the form: provider/model-name.
*/
queryModel: Annotation<string>,
});
/**
* Create a typeof ConfigurationAnnotation.State instance from a RunnableConfig object.
*
* @param config - The configuration object to use.
* @returns An instance of typeof ConfigurationAnnotation.State with the specified configuration.
*/
export function ensureAgentConfiguration(
config: RunnableConfig,
): typeof AgentConfigurationAnnotation.State {
const configurable = (config?.configurable || {}) as Partial<
typeof AgentConfigurationAnnotation.State
>;
const baseConfig = ensureBaseConfiguration(config);
return {
...baseConfig,
queryModel: configurable.queryModel || 'openai/gpt-4o',
};
}
================================================
FILE: backend/src/retrieval_graph/graph.ts
================================================
import { StateGraph, START, END } from '@langchain/langgraph';
import { AgentStateAnnotation } from './state.js';
import { makeRetriever } from '../shared/retrieval.js';
import { formatDocs } from './utils.js';
import { HumanMessage } from '@langchain/core/messages';
import { z } from 'zod';
import { RESPONSE_SYSTEM_PROMPT, ROUTER_SYSTEM_PROMPT } from './prompts.js';
import { RunnableConfig } from '@langchain/core/runnables';
import {
AgentConfigurationAnnotation,
ensureAgentConfiguration,
} from './configuration.js';
import { loadChatModel } from '../shared/utils.js';
async function checkQueryType(
state: typeof AgentStateAnnotation.State,
config: RunnableConfig,
): Promise<{
route: 'retrieve' | 'direct';
}> {
//schema for routing
const schema = z.object({
route: z.enum(['retrieve', 'direct']),
directAnswer: z.string().optional(),
});
const configuration = ensureAgentConfiguration(config);
const model = await loadChatModel(configuration.queryModel);
const routingPrompt = ROUTER_SYSTEM_PROMPT;
const formattedPrompt = await routingPrompt.invoke({
query: state.query,
});
const response = await model
.withStructuredOutput(schema)
.invoke(formattedPrompt.toString());
const route = response.route;
return { route };
}
async function answerQueryDirectly(
state: typeof AgentStateAnnotation.State,
config: RunnableConfig,
): Promise<typeof AgentStateAnnotation.Update> {
const configuration = ensureAgentConfiguration(config);
const model = await loadChatModel(configuration.queryModel);
const userHumanMessage = new HumanMessage(state.query);
const response = await model.invoke([userHumanMessage]);
return { messages: [userHumanMessage, response] };
}
async function routeQuery(
state: typeof AgentStateAnnotation.State,
): Promise<'retrieveDocuments' | 'directAnswer'> {
const route = state.route;
if (!route) {
throw new Error('Route is not set');
}
if (route === 'retrieve') {
return 'retrieveDocuments';
} else if (route === 'direct') {
return 'directAnswer';
} else {
throw new Error('Invalid route');
}
}
async function retrieveDocuments(
state: typeof AgentStateAnnotation.State,
config: RunnableConfig,
): Promise<typeof AgentStateAnnotation.Update> {
const retriever = await makeRetriever(config);
const response = await retriever.invoke(state.query);
return { documents: response };
}
async function generateResponse(
state: typeof AgentStateAnnotation.State,
config: RunnableConfig,
): Promise<typeof AgentStateAnnotation.Update> {
const configuration = ensureAgentConfiguration(config);
const context = formatDocs(state.documents);
const model = await loadChatModel(configuration.queryModel);
const promptTemplate = RESPONSE_SYSTEM_PROMPT;
const formattedPrompt = await promptTemplate.invoke({
question: state.query,
context: context,
});
const userHumanMessage = new HumanMessage(state.query);
// Create a human message with the formatted prompt that includes context
const formattedPromptMessage = new HumanMessage(formattedPrompt.toString());
const messageHistory = [...state.messages, formattedPromptMessage];
// Let MessagesAnnotation handle the message history
const response = await model.invoke(messageHistory);
// Return both the current query and the AI response to be handled by MessagesAnnotation's reducer
return { messages: [userHumanMessage, response] };
}
const builder = new StateGraph(
AgentStateAnnotation,
AgentConfigurationAnnotation,
)
.addNode('retrieveDocuments', retrieveDocuments)
.addNode('generateResponse', generateResponse)
.addNode('checkQueryType', checkQueryType)
.addNode('directAnswer', answerQueryDirectly)
.addEdge(START, 'checkQueryType')
.addConditionalEdges('checkQueryType', routeQuery, [
'retrieveDocuments',
'directAnswer',
])
.addEdge('retrieveDocuments', 'generateResponse')
.addEdge('generateResponse', END)
.addEdge('directAnswer', END);
export const graph = builder.compile().withConfig({
runName: 'RetrievalGraph',
});
================================================
FILE: backend/src/retrieval_graph/prompts.ts
================================================
import { ChatPromptTemplate } from '@langchain/core/prompts';
const ROUTER_SYSTEM_PROMPT = ChatPromptTemplate.fromMessages([
[
'system',
"You are a routing assistant. Your job is to determine if a question needs document retrieval or can be answered directly.\n\nRespond with either:\n'retrieve' - if the question requires retrieving documents\n'direct' - if the question can be answered directly AND your direct answer",
],
['human', '{query}'],
]);
const RESPONSE_SYSTEM_PROMPT = ChatPromptTemplate.fromMessages([
[
'system',
`You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question.
If you don't know the answer, just say that you don't know. Use three sentences maximum and keep the answer concise.
question:
{question}
context:
{context}
`,
],
]);
export { ROUTER_SYSTEM_PROMPT, RESPONSE_SYSTEM_PROMPT };
================================================
FILE: backend/src/retrieval_graph/state.ts
================================================
import { Annotation, MessagesAnnotation } from '@langchain/langgraph';
import { reduceDocs } from '../shared/state.js';
import { Document } from '@langchain/core/documents';
/**
* Represents the state of the retrieval graph / agent.
*/
export const AgentStateAnnotation = Annotation.Root({
query: Annotation<string>(),
route: Annotation<string>(),
...MessagesAnnotation.spec,
/**
* Populated by the retriever. This is a list of documents that the agent can reference.
* @type {Document[]}
*/
documents: Annotation<
Document[],
Document[] | { [key: string]: any }[] | string[] | string | 'delete'
>({
default: () => [],
// @ts-ignore
reducer: reduceDocs,
}),
// Additional attributes can be added here as needed
});
================================================
FILE: backend/src/retrieval_graph/utils.ts
================================================
import { Document } from '@langchain/core/documents';
export function formatDoc(doc: Document): string {
const metadata = doc.metadata || {};
const meta = Object.entries(metadata)
.map(([k, v]) => ` ${k}=${v}`)
.join('');
const metaStr = meta ? ` ${meta}` : '';
return `<document${metaStr}>\n${doc.pageContent}\n</document>`;
}
export function formatDocs(docs?: Document[]): string {
/**Format a list of documents as XML. */
if (!docs || docs.length === 0) {
return '<documents></documents>';
}
const formatted = docs.map(formatDoc).join('\n');
return `<documents>\n${formatted}\n</documents>`;
}
================================================
FILE: backend/src/sample_docs.json
================================================
[
{
"pageContent": "UNITED\tSTATES\nSECURITIES\tAND\tEXCHANGE\tCOMMISSION\nWashington,\tD.C.\t20549\nFORM\t10-K\n(Mark\tOne)\nxANNUAL\tREPORT\tPURSUANT\tTO\tSECTION\t13\tOR\t15(d)\tOF\tTHE\tSECURITIES\tEXCHANGE\tACT\tOF\t1934\nFor\tthe\tfiscal\tyear\tended\tDecember\t31,\t2023\nOR\noTRANSITION\tREPORT\tPURSUANT\tTO\tSECTION\t13\tOR\t15(d)\tOF\tTHE\tSECURITIES\tEXCHANGE\tACT\tOF\t1934\nFor\tthe\ttransition\tperiod\tfrom\t_________\tto\t_________\nCommission\tFile\tNumber:\t001-34756\nTesla,\tInc.\n(Exact\tname\tof\tregistrant\tas\tspecified\tin\tits\tcharter)\nDelaware91-2197729\n(State\tor\tother\tjurisdiction\tof\nincorporation\tor\torganization)\n(I.R.S.\tEmployer\nIdentification\tNo.)\n1\tTesla\tRoad\nAustin,\tTexas78725\n(Address\tof\tprincipal\texecutive\toffices)(Zip\tCode)\n(512)\t516-8177\n(Registrant’s\ttelephone\tnumber,\tincluding\tarea\tcode)\nSecurities\tregistered\tpursuant\tto\tSection\t12(b)\tof\tthe\tAct:\nTitle\tof\teach\tclassTrading\tSymbol(s)Name\tof\teach\texchange\ton\twhich\tregistered\nCommon\tstockTSLAThe\tNasdaq\tGlobal\tSelect\tMarket\nSecurities\tregistered\tpursuant\tto\tSection\t12(g)\tof\tthe\tAct:\nNone\nIndicate\tby\tcheck\tmark\twhether\tthe\tregistrant\tis\ta\twell-known\tseasoned\tissuer,\tas\tdefined\tin\tRule\t405\tof\tthe\tSecurities\tAct.\tYes\tx\tNo\to\nIndicate\tby\tcheck\tmark\tif\tthe\tregistrant\tis\tnot\trequired\tto\tfile\treports\tpursuant\tto\tSection\t13\tor\t15(d)\tof\tthe\tAct.\tYes\to\tNo\tx\nIndicate\tby\tcheck\tmark\twhether\tthe\tregistrant\t(1)\thas\tfiled\tall\treports\trequired\tto\tbe\tfiled\tby\tSection\t13\tor\t15(d)\tof\tthe\tSecurities\tExchange\tAct\tof\t1934\t(“Exchange\tAct”)\nduring\tthe\tpreceding\t12\tmonths\t(or\tfor\tsuch\tshorter\tperiod\tthat\tthe\tregistrant\twas\trequired\tto\tfile\tsuch\treports),\tand\t(2)\thas\tbeen\tsubject\tto\tsuch\tfiling\trequirements\tfor\tthe\tpast\t90\ndays.\tYes\tx\tNo\to\nIndicate\tby\tcheck\tmark\twhether\tthe\tregistrant\thas\tsubmitted\telectronically\tevery\tInteractive\tData\tFile\trequired\tto\tbe\tsubmitted\tpursuant\tto\tRule\t405\tof\tRegulation\tS-T\n(§232.405\tof\tthis\tchapter)\tduring\tthe\tpreceding\t12\tmonths\t(or\tfor\tsuch\tshorter\tperiod\tthat\tthe\tregistrant\twas\trequired\tto\tsubmit\tsuch\tfiles).\tYes\tx\tNo\to",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 1,
"lines": {
"from": 1,
"to": 35
}
}
}
},
{
"pageContent": "Indicate\tby\tcheck\tmark\twhether\tthe\tregistrant\tis\ta\tlarge\taccelerated\tfiler,\tan\taccelerated\tfiler,\ta\tnon-accelerated\tfiler,\ta\tsmaller\treporting\tcompany,\tor\tan\temerging\tgrowth\ncompany.\tSee\tthe\tdefinitions\tof\t“large\taccelerated\tfiler,”\t“accelerated\tfiler,”\t“smaller\treporting\tcompany”\tand\t“emerging\tgrowth\tcompany”\tin\tRule\t12b-2\tof\tthe\tExchange\tAct:\nLarge\taccelerated\tfilerx\tAccelerated\tfilero\nNon-accelerated\tfilero\tSmaller\treporting\tcompanyo\nEmerging\tgrowth\tcompanyo",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 1,
"lines": {
"from": 36,
"to": 40
}
}
}
},
{
"pageContent": "If\tan\temerging\tgrowth\tcompany,\tindicate\tby\tcheck\tmark\tif\tthe\tregistrant\thas\telected\tnot\tto\tuse\tthe\textended\ttransition\tperiod\tfor\tcomplying\twith\tany\tnew\tor\trevised\tfinancial\naccounting\tstandards\tprovided\tpursuant\tto\tSection\t13(a)\tof\tthe\tExchange\tAct.\to\nIndicate\tby\tcheck\tmark\twhether\tthe\tRegistrant\thas\tfiled\ta\treport\ton\tand\tattestation\tto\tits\tmanagement’s\tassessment\tof\tthe\teffectiveness\tof\tits\tinternal\tcontrol\tover\tfinancial\nreporting\tunder\tSection\t404(b)\tof\tthe\tSarbanes-Oxley\tAct\t(15\tU.S.C.\t7262(b))\tby\tthe\tregistered\tpublic\taccounting\tfirm\tthat\tprepared\tor\tissued\tits\taudit\treport.\tx\nIf\tsecurities\tare\tregistered\tpursuant\tto\tSection\t12(b)\tof\tthe\tAct,\tindicate\tby\tcheck\tmark\twhether\tthe\tfinancial\tstatements\tof\tthe\tregistrant\tincluded\tin\tthe\tfiling\treflect\tthe\ncorrection\tof\tan\terror\tto\tpreviously\tissued\tfinancial\tstatements.\to\nIndicate\tby\tcheck\tmark\twhether\tany\tof\tthose\terror\tcorrections\tare\trestatements\tthat\trequired\ta\trecovery\tanalysis\tof\tincentive-based\tcompensation\treceived\tby\tany\tof\tthe\nregistrant’s\texecutive\tofficers\tduring\tthe\trelevant\trecovery\tperiod\tpursuant\tto\t§240.10D-1(b).\to\nIndicate\tby\tcheck\tmark\twhether\tthe\tregistrant\tis\ta\tshell\tcompany\t(as\tdefined\tin\tRule\t12b-2\tof\tthe\tExchange\tAct).\tYes\to\tNo\tx\nThe\taggregate\tmarket\tvalue\tof\tvoting\tstock\theld\tby\tnon-affiliates\tof\tthe\tregistrant,\tas\tof\tJune\t30,\t2023,\tthe\tlast\tday\tof\tthe\tregistrant’s\tmost\trecently\tcompleted\tsecond\tfiscal\nquarter,\twas\t$722.52\tbillion\t(based\ton\tthe\tclosing\tprice\tfor\tshares\tof\tthe\tregistrant’s\tCommon\tStock\tas\treported\tby\tthe\tNASDAQ\tGlobal\tSelect\tMarket\ton\tJune\t30,\t2023).\tShares\tof\nCommon\tStock\theld\tby\teach\texecutive\tofficer\tand\tdirector\thave\tbeen\texcluded\tin\tthat\tsuch\tpersons\tmay\tbe\tdeemed\tto\tbe\taffiliates.\tThis\tdetermination\tof\taffiliate\tstatus\tis\tnot\nnecessarily\ta\tconclusive\tdetermination\tfor\tother\tpurposes.\nAs\tof\tJanuary\t22,\t2024,\tthere\twere\t3,184,790,415\tshares\tof\tthe\tregistrant’s\tcommon\tstock\toutstanding.\nDOCUMENTS\tINCORPORATED\tBY\tREFERENCE",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 2,
"lines": {
"from": 1,
"to": 15
}
}
}
},
{
"pageContent": "DOCUMENTS\tINCORPORATED\tBY\tREFERENCE\nPortions\tof\tthe\tregistrant’s\tProxy\tStatement\tfor\tthe\t2024\tAnnual\tMeeting\tof\tStockholders\tare\tincorporated\therein\tby\treference\tin\tPart\tIII\tof\tthis\tAnnual\tReport\ton\tForm\t10-K\tto\nthe\textent\tstated\therein.\tSuch\tproxy\tstatement\twill\tbe\tfiled\twith\tthe\tSecurities\tand\tExchange\tCommission\twithin\t120\tdays\tof\tthe\tregistrant’s\tfiscal\tyear\tended\tDecember\t31,\t2023.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 2,
"lines": {
"from": 15,
"to": 17
}
}
}
},
{
"pageContent": "TESLA,\tINC.\nANNUAL\tREPORT\tON\tFORM\t10-K\tFOR\tTHE\tYEAR\tENDED\tDECEMBER\t31,\t2023\nINDEX\n\t\tPage\nPART\tI.\n\t\t\nItem\t1.Business4\nItem\t1A.Risk\tFactors14\nItem\t1B.Unresolved\tStaff\tComments28\nItem\t1C.Cybersecurity29\nItem\t2.Properties30\nItem\t3.Legal\tProceedings30\nItem\t4.Mine\tSafety\tDisclosures30\n\t\nPART\tII.\n\t\nItem\t5.Market\tfor\tRegistrant's\tCommon\tEquity,\tRelated\tStockholder\tMatters\tand\tIssuer\tPurchases\tof\tEquity\tSecurities31\nItem\t6.[Reserved]32\nItem\t7.Management's\tDiscussion\tand\tAnalysis\tof\tFinancial\tCondition\tand\tResults\tof\tOperations33\nItem\t7A.Quantitative\tand\tQualitative\tDisclosures\tabout\tMarket\tRisk45\nItem\t8.Financial\tStatements\tand\tSupplementary\tData46\nItem\t9.Changes\tin\tand\tDisagreements\twith\tAccountants\ton\tAccounting\tand\tFinancial\tDisclosure93\nItem\t9A.Controls\tand\tProcedures93\nItem\t9B.Other\tInformation94\nItem\t9C.Disclosure\tRegarding\tForeign\tJurisdictions\tthat\tPrevent\tInspections94\n\t\nPART\tIII.\n\t\nItem\t10.Directors,\tExecutive\tOfficers\tand\tCorporate\tGovernance95\nItem\t11.Executive\tCompensation95\nItem\t12.Security\tOwnership\tof\tCertain\tBeneficial\tOwners\tand\tManagement\tand\tRelated\tStockholder\tMatters95\nItem\t13.Certain\tRelationships\tand\tRelated\tTransactions,\tand\tDirector\tIndependence95\nItem\t14.Principal\tAccountant\tFees\tand\tServices95\n\t\nPART\tIV.\n\t\nItem\t15.Exhibits\tand\tFinancial\tStatement\tSchedules96\nItem\t16.Summary111\n\t\nSignatures",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 3,
"lines": {
"from": 1,
"to": 40
}
}
}
},
{
"pageContent": "Table\tof\tContents\nForward-Looking\tStatements\nThe\tdiscussions\tin\tthis\tAnnual\tReport\ton\tForm\t10-K\tcontain\tforward-looking\tstatements\treflecting\tour\tcurrent\texpectations\tthat\tinvolve\trisks\tand\nuncertainties.\tThese\tforward-looking\tstatements\tinclude,\tbut\tare\tnot\tlimited\tto,\tstatements\tconcerning\tsupply\tchain\tconstraints,\tour\tstrategy,\ncompetition,\tfuture\toperations\tand\tproduction\tcapacity,\tfuture\tfinancial\tposition,\tfuture\trevenues,\tprojected\tcosts,\tprofitability,\texpected\tcost\treductions,\ncapital\tadequacy,\texpectations\tregarding\tdemand\tand\tacceptance\tfor\tour\ttechnologies,\tgrowth\topportunities\tand\ttrends\tin\tthe\tmarkets\tin\twhich\twe\noperate,\tprospects\tand\tplans\tand\tobjectives\tof\tmanagement.\tThe\twords\t“anticipates,”\t“believes,”\t“could,”\t“estimates,”\t“expects,”\t“intends,”\t“may,”\n“plans,”\t“projects,”\t“will,”\t“would”\tand\tsimilar\texpressions\tare\tintended\tto\tidentify\tforward-looking\tstatements,\talthough\tnot\tall\tforward-looking\nstatements\tcontain\tthese\tidentifying\twords.\tWe\tmay\tnot\tactually\tachieve\tthe\tplans,\tintentions\tor\texpectations\tdisclosed\tin\tour\tforward-looking\nstatements\tand\tyou\tshould\tnot\tplace\tundue\treliance\ton\tour\tforward-looking\tstatements.\tActual\tresults\tor\tevents\tcould\tdiffer\tmaterially\tfrom\tthe\tplans,\nintentions\tand\texpectations\tdisclosed\tin\tthe\tforward-looking\tstatements\tthat\twe\tmake.\tThese\tforward-looking\tstatements\tinvolve\trisks\tand\tuncertainties\nthat\tcould\tcause\tour\tactual\tresults\tto\tdiffer\tmaterially\tfrom\tthose\tin\tthe\tforward-looking\tstatements,\tincluding,\twithout\tlimitation,\tthe\trisks\tset\tforth\tin\tPart\nI,\tItem\t1A,\t“Risk\tFactors”\tof\tthe\tAnnual\tReport\ton\tForm\t10-K\tfor\tthe\tfiscal\tyear\tended\tDecember\t31,\t2023\tand\tthat\tare\totherwise\tdescribed\tor\tupdated\nfrom\ttime\tto\ttime\tin\tour\tother\tfilings\twith\tthe\tSecurities\tand\tExchange\tCommission\t(the\t“SEC”).\tThe\tdiscussion\tof\tsuch\trisks\tis\tnot\tan\tindication\tthat\tany\nsuch\trisks\thave\toccurred\tat\tthe\ttime\tof\tthis\tfiling.\tWe\tdo\tnot\tassume\tany\tobligation\tto\tupdate\tany\tforward-looking\tstatements.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 4,
"lines": {
"from": 1,
"to": 15
}
}
}
},
{
"pageContent": "Table\tof\tContents\nPART\tI\nITEM\t1.\tBUSINESS\nOverview\nWe\tdesign,\tdevelop,\tmanufacture,\tsell\tand\tlease\thigh-performance\tfully\telectric\tvehicles\tand\tenergy\tgeneration\tand\tstorage\tsystems,\tand\toffer\nservices\trelated\tto\tour\tproducts.\tWe\tgenerally\tsell\tour\tproducts\tdirectly\tto\tcustomers,\tand\tcontinue\tto\tgrow\tour\tcustomer-facing\tinfrastructure\tthrough\ta\nglobal\tnetwork\tof\tvehicle\tshowrooms\tand\tservice\tcenters,\tMobile\tService,\tbody\tshops,\tSupercharger\tstations\tand\tDestination\tChargers\tto\taccelerate\tthe\nwidespread\tadoption\tof\tour\tproducts.\tWe\temphasize\tperformance,\tattractive\tstyling\tand\tthe\tsafety\tof\tour\tusers\tand\tworkforce\tin\tthe\tdesign\tand\nmanufacture\tof\tour\tproducts\tand\tare\tcontinuing\tto\tdevelop\tfull\tself-driving\ttechnology\tfor\timproved\tsafety.\tWe\talso\tstrive\tto\tlower\tthe\tcost\tof\townership\nfor\tour\tcustomers\tthrough\tcontinuous\tefforts\tto\treduce\tmanufacturing\tcosts\tand\tby\toffering\tfinancial\tand\tother\tservices\ttailored\tto\tour\tproducts.\nOur\tmission\tis\tto\taccelerate\tthe\tworld’s\ttransition\tto\tsustainable\tenergy.\tWe\tbelieve\tthat\tthis\tmission,\talong\twith\tour\tengineering\texpertise,\nvertically\tintegrated\tbusiness\tmodel\tand\tfocus\ton\tuser\texperience\tdifferentiate\tus\tfrom\tother\tcompanies.\nSegment\tInformation\nWe\toperate\tas\ttwo\treportable\tsegments:\t(i)\tautomotive\tand\t(ii)\tenergy\tgeneration\tand\tstorage.\nThe\tautomotive\tsegment\tincludes\tthe\tdesign,\tdevelopment,\tmanufacturing,\tsales\tand\tleasing\tof\thigh-performance\tfully\telectric\tvehicles\tas\twell\tas\nsales\tof\tautomotive\tregulatory\tcredits.\tAdditionally,\tthe\tautomotive\tsegment\talso\tincludes\tservices\tand\tother,\twhich\tincludes\tsales\tof\tused\tvehicles,\tnon-\nwarranty\tafter-sales\tvehicle\tservices,\tbody\tshop\tand\tparts,\tpaid\tSupercharging,\tvehicle\tinsurance\trevenue\tand\tretail\tmerchandise.\tThe\tenergy\tgeneration\nand\tstorage\tsegment\tincludes\tthe\tdesign,\tmanufacture,\tinstallation,\tsales\tand\tleasing\tof\tsolar\tenergy\tgeneration\tand\tenergy\tstorage\tproducts\tand\trelated\nservices\tand\tsales\tof\tsolar\tenergy\tsystems\tincentives.\nOur\tProducts\tand\tServices\nAutomotive",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 5,
"lines": {
"from": 1,
"to": 21
}
}
}
},
{
"pageContent": "Our\tProducts\tand\tServices\nAutomotive\nWe\tcurrently\tmanufacture\tfive\tdifferent\tconsumer\tvehicles\t–\tthe\tModel\t3,\tY,\tS,\tX\tand\tCybertruck.\tModel\t3\tis\ta\tfour-door\tmid-size\tsedan\tthat\twe\ndesigned\tfor\tmanufacturability\twith\ta\tbase\tprice\tfor\tmass-market\tappeal.\tModel\tY\tis\ta\tcompact\tsport\tutility\tvehicle\t(“SUV”)\tbuilt\ton\tthe\tModel\t3\tplatform\nwith\tseating\tfor\tup\tto\tseven\tadults.\tModel\tS\tis\ta\tfour-door\tfull-size\tsedan\tand\tModel\tX\tis\ta\tmid-size\tSUV\twith\tseating\tfor\tup\tto\tseven\tadults.\tModel\tS\tand\nModel\tX\tfeature\tthe\thighest\tperformance\tcharacteristics\tand\tlongest\tranges\tthat\twe\toffer\tin\ta\tsedan\tand\tSUV,\trespectively.\tIn\tNovember\t2023,\twe\nentered\tthe\tconsumer\tpickup\ttruck\tmarket\twith\tfirst\tdeliveries\tof\tthe\tCybertruck,\ta\tfull-size\telectric\tpickup\ttruck\twith\ta\tstainless\tsteel\texterior\tthat\thas\nthe\tutility\tand\tstrength\tof\ta\ttruck\twhile\tfeaturing\tthe\tspeed\tof\ta\tsports\tcar.\nIn\t2022,\twe\talso\tbegan\tearly\tproduction\tand\tdeliveries\tof\ta\tcommercial\telectric\tvehicle,\tthe\tTesla\tSemi.\tWe\thave\tplanned\telectric\tvehicles\tto\naddress\tadditional\tvehicle\tmarkets,\tand\tto\tcontinue\tleveraging\tdevelopments\tin\tour\tproprietary\tFull\tSelf-Driving\t(“FSD”)\tCapability\tfeatures,\tbattery\tcell\nand\tother\ttechnologies.\nEnergy\tGeneration\tand\tStorage\nEnergy\tStorage\tProducts\nPowerwall\tand\tMegapack\tare\tour\tlithium-ion\tbattery\tenergy\tstorage\tproducts.\tPowerwall,\twhich\twe\tsell\tdirectly\tto\tcustomers,\tas\twell\tas\tthrough\nchannel\tpartners,\tis\tdesigned\tto\tstore\tenergy\tat\ta\thome\tor\tsmall\tcommercial\tfacility.\tMegapack\tis\tan\tenergy\tstorage\tsolution\tfor\tcommercial,\tindustrial,\nutility\tand\tenergy\tgeneration\tcustomers,\tmultiple\tof\twhich\tmay\tbe\tgrouped\ttogether\tto\tform\tlarger\tinstallations\tof\tgigawatt\thours\t(“GWh”)\tor\tgreater\ncapacity.\nWe\talso\tcontinue\tto\tdevelop\tsoftware\tcapabilities\tfor\tremotely\tcontrolling\tand\tdispatching\tour\tenergy\tstorage\tsystems\tacross\ta\twide\trange\tof\nmarkets\tand\tapplications,\tincluding\tthrough\tour\treal-time\tenergy\tcontrol\tand\toptimization\tplatforms.\n4",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 5,
"lines": {
"from": 20,
"to": 39
}
}
}
},
{
"pageContent": "Table\tof\tContents\nSolar\tEnergy\tOfferings\nWe\tsell\tretrofit\tsolar\tenergy\tsystems\tto\tcustomers\tand\tchannel\tpartners\tand\talso\tmake\tthem\tavailable\tthrough\tpower\tpurchase\tagreement\t(“PPA”)\narrangements.\tWe\tpurchase\tmost\tof\tthe\tcomponents\tfor\tour\tretrofit\tsolar\tenergy\tsystems\tfrom\tmultiple\tsources\tto\tensure\tcompetitive\tpricing\tand\nadequate\tsupply.\tWe\talso\tdesign\tand\tmanufacture\tcertain\tcomponents\tfor\tour\tsolar\tenergy\tproducts.\nWe\tsell\tour\tSolar\tRoof,\twhich\tcombines\tpremium\tglass\troof\ttiles\twith\tenergy\tgeneration,\tdirectly\tto\tcustomers,\tas\twell\tas\tthrough\tchannel\ncustomers.\tWe\tcontinue\tto\timprove\tour\tinstallation\tcapability\tand\tefficiency,\tincluding\tthrough\tcollaboration\twith\treal\testate\tdevelopers\tand\tbuilders\ton\nnew\thomes.\nTechnology\nAutomotive\nBattery\tand\tPowertrain\nOur\tcore\tvehicle\ttechnology\tcompetencies\tinclude\tpowertrain\tengineering\tand\tmanufacturing\tand\tour\tability\tto\tdesign\tvehicles\tthat\tutilize\tthe\nunique\tadvantages\tof\tan\telectric\tpowertrain.\tWe\thave\tdesigned\tour\tproprietary\tpowertrain\tsystems\tto\tbe\tadaptable,\tefficient,\treliable\tand\tcost-effective\nwhile\twithstanding\tthe\trigors\tof\tan\tautomotive\tenvironment.\tWe\toffer\tdual\tmotor\tpowertrain\tvehicles,\twhich\tuse\ttwo\telectric\tmotors\tto\tmaximize\ttraction\nand\tperformance\tin\tan\tall-wheel\tdrive\tconfiguration,\tas\twell\tas\tvehicle\tpowertrain\ttechnology\tfeaturing\tthree\telectric\tmotors\tfor\tfurther\tincreased\nperformance\tin\tcertain\tversions\tof\tModel\tS\tand\tModel\tX,\tCybertruck\tand\tthe\tTesla\tSemi.\nWe\tmaintain\textensive\ttesting\tand\tR&D\tcapabilities\tfor\tbattery\tcells,\tpacks\tand\tsystems,\tand\thave\tbuilt\tan\texpansive\tbody\tof\tknowledge\ton\tlithium-\nion\tcell\tchemistry\ttypes\tand\tperformance\tcharacteristics.\tIn\torder\tto\tenable\ta\tgreater\tsupply\tof\tcells\tfor\tour\tproducts\twith\thigher\tenergy\tdensity\tat\tlower\ncosts,\twe\thave\tdeveloped\ta\tnew\tproprietary\tlithium-ion\tbattery\tcell\tand\timproved\tmanufacturing\tprocesses.\nVehicle\tControl\tand\tInfotainment\tSoftware",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 6,
"lines": {
"from": 1,
"to": 20
}
}
}
},
{
"pageContent": "Vehicle\tControl\tand\tInfotainment\tSoftware\nThe\tperformance\tand\tsafety\tsystems\tof\tour\tvehicles\tand\ttheir\tbattery\tpacks\tutilize\tsophisticated\tcontrol\tsoftware.\tControl\tsystems\tin\tour\tvehicles\noptimize\tperformance,\tcustomize\tvehicle\tbehavior,\tmanage\tcharging\tand\tcontrol\tall\tinfotainment\tfunctions.\tWe\tdevelop\talmost\tall\tof\tthis\tsoftware,\nincluding\tmost\tof\tthe\tuser\tinterfaces,\tinternally\tand\tupdate\tour\tvehicles’\tsoftware\tregularly\tthrough\tover-the-air\tupdates.\nSelf-Driving\tDevelopment\tand\tArtificial\tIntelligence\nWe\thave\texpertise\tin\tdeveloping\ttechnologies,\tsystems\tand\tsoftware\tto\tenable\tself-driving\tvehicles\tusing\tprimarily\tvision-based\ttechnologies.\tOur\nFSD\tComputer\truns\tour\tneural\tnetworks\tin\tour\tvehicles,\tand\twe\tare\talso\tdeveloping\tadditional\tcomputer\thardware\tto\tbetter\tenable\tthe\tmassive\tamounts\nof\tfield\tdata\tcaptured\tby\tour\tvehicles\tto\tcontinually\ttrain\tand\timprove\tthese\tneural\tnetworks\tfor\treal-world\tperformance.\nCurrently,\twe\toffer\tin\tour\tvehicles\tcertain\tadvanced\tdriver\tassist\tsystems\tunder\tour\tAutopilot\tand\tFSD\tCapability\toptions.\tAlthough\tat\tpresent\tthe\ndriver\tis\tultimately\tresponsible\tfor\tcontrolling\tthe\tvehicle,\tour\tsystems\tprovide\tsafety\tand\tconvenience\tfunctionality\tthat\trelieves\tdrivers\tof\tthe\tmost\ntedious\tand\tpotentially\tdangerous\taspects\tof\troad\ttravel\tmuch\tlike\tthe\tsystem\tthat\tairplane\tpilots\tuse,\twhen\tconditions\tpermit.\tAs\twith\tother\tvehicle\nsystems,\twe\timprove\tthese\tfunctions\tin\tour\tvehicles\tover\ttime\tthrough\tover-the-air\tupdates.\nWe\tintend\tto\testablish\tin\tthe\tfuture\tan\tautonomous\tTesla\tride-hailing\tnetwork,\twhich\twe\texpect\twould\talso\tallow\tus\tto\taccess\ta\tnew\tcustomer\tbase\neven\tas\tmodes\tof\ttransportation\tevolve.\nWe\tare\talso\tapplying\tour\tartificial\tintelligence\tlearnings\tfrom\tself-driving\ttechnology\tto\tthe\tfield\tof\trobotics,\tsuch\tas\tthrough\tOptimus,\ta\trobotic\nhumanoid\tin\tdevelopment,\twhich\tis\tcontrolled\tby\tthe\tsame\tAI\tsystem.\n5",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 6,
"lines": {
"from": 20,
"to": 36
}
}
}
},
{
"pageContent": "Table\tof\tContents\nEnergy\tGeneration\tand\tStorage\nEnergy\tStorage\tProducts\nWe\tleverage\tmany\tof\tthe\tcomponent-level\ttechnologies\tfrom\tour\tvehicles\tin\tour\tenergy\tstorage\tproducts.\tBy\ttaking\ta\tmodular\tapproach\tto\tthe\ndesign\tof\tbattery\tsystems,\twe\tcan\toptimize\tmanufacturing\tcapacity\tof\tour\tenergy\tstorage\tproducts.\tAdditionally,\tour\texpertise\tin\tpower\telectronics\nenables\tour\tbattery\tsystems\tto\tinterconnect\twith\telectricity\tgrids\twhile\tproviding\tfast-acting\tsystems\tfor\tpower\tinjection\tand\tabsorption.\tWe\thave\talso\ndeveloped\tsoftware\tto\tremotely\tcontrol\tand\tdispatch\tour\tenergy\tstorage\tsystems.\nSolar\tEnergy\tSystems\nWe\thave\tengineered\tSolar\tRoof\tover\tnumerous\titerations\tto\tcombine\taesthetic\tappeal\tand\tdurability\twith\tpower\tgeneration.\tThe\tefficiency\tof\tour\nsolar\tenergy\tproducts\tis\taided\tby\tour\town\tsolar\tinverter,\twhich\tincorporates\tour\tpower\telectronics\ttechnologies.\tWe\tdesigned\tboth\tproducts\tto\tintegrate\nwith\tPowerwall.\nDesign\tand\tEngineering\nAutomotive\nWe\thave\testablished\tsignificant\tin-house\tcapabilities\tin\tthe\tdesign\tand\ttest\tengineering\tof\telectric\tvehicles\tand\ttheir\tcomponents\tand\tsystems.\tOur\nteam\thas\tsignificant\texperience\tin\tcomputer-aided\tdesign\tas\twell\tas\tdurability,\tstrength\tand\tcrash\ttest\tsimulations,\twhich\treduces\tthe\tproduct\ndevelopment\ttime\tof\tnew\tmodels.\tWe\thave\talso\tachieved\tcomplex\tengineering\tfeats\tin\tstamping,\tcasting\tand\tthermal\tsystems,\tand\tdeveloped\ta\tmethod\nto\tintegrate\tbatteries\tdirectly\twith\tvehicle\tbody\tstructures\twithout\tseparate\tbattery\tpacks\tto\toptimize\tmanufacturability,\tweight,\trange\tand\tcost\ncharacteristics.\nWe\tare\talso\texpanding\tour\tmanufacturing\toperations\tglobally\twhile\ttaking\taction\tto\tlocalize\tour\tvehicle\tdesigns\tand\tproduction\tfor\tparticular\nmarkets,\tincluding\tcountry-specific\tmarket\tdemands\tand\tfactory\toptimizations\tfor\tlocal\tworkforces.\tAs\twe\tincrease\tour\tcapabilities,\tparticularly\tin\tthe\nareas\tof\tautomation,\tdie-making\tand\tline-building,\twe\tare\talso\tmaking\tstrides\tin\tthe\tsimulations\tmodeling\tthese\tcapabilities\tprior\tto\tconstruction.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 7,
"lines": {
"from": 1,
"to": 21
}
}
}
},
{
"pageContent": "Energy\tGeneration\tand\tStorage\nOur\texpertise\tin\telectrical,\tmechanical,\tcivil\tand\tsoftware\tengineering\tallows\tus\tto\tdesign,\tengineer,\tmanufacture\tand\tinstall\tenergy\tgenerating\tand\nstorage\tproducts\tand\tcomponents,\tincluding\tat\tthe\tresidential\tthrough\tutility\tscale.\tFor\texample,\tthe\tmodular\tdesign\tof\tour\tMegapack\tutility-scale\tbattery\nline\tis\tintended\tto\tsignificantly\treduce\tthe\tamount\tof\tassembly\trequired\tin\tthe\tfield.\tWe\talso\tcustomize\tsolutions\tincluding\tour\tenergy\tstorage\tproducts,\nsolar\tenergy\tsystems\tand/or\tSolar\tRoof\tfor\tcustomers\tto\tmeet\ttheir\tspecific\tneeds.\nSales\tand\tMarketing\nHistorically,\twe\thave\tbeen\table\tto\tachieve\tsales\twithout\ttraditional\tadvertising\tand\tat\trelatively\tlow\tmarketing\tcosts.\tWe\tcontinue\tto\tmonitor\tour\npublic\tnarrative\tand\tbrand,\tand\ttailor\tour\tmarketing\tefforts\taccordingly,\tincluding\tthrough\tinvestments\tin\tcustomer\teducation\tand\tadvertising\tas\nnecessary.\nAutomotive\nDirect\tSales\nOur\tvehicle\tsales\tchannels\tcurrently\tinclude\tour\twebsite\tand\tan\tinternational\tnetwork\tof\tcompany-owned\tstores.\tIn\tsome\tjurisdictions,\twe\talso\thave\ngalleries\tto\teducate\tand\tinform\tcustomers\tabout\tour\tproducts,\tbut\tsuch\tlocations\tdo\tnot\ttransact\tin\tthe\tsale\tof\tvehicles.\tWe\tbelieve\tthis\tinfrastructure\nenables\tus\tto\tbetter\tcontrol\tcosts\tof\tinventory,\tmanage\twarranty\tservice\tand\tpricing,\teducate\tconsumers\tabout\telectric\tvehicles,\tmake\tour\tvehicles\tmore\naffordable,\tmaintain\tand\tstrengthen\tthe\tTesla\tbrand\tand\tobtain\trapid\tcustomer\tfeedback.\nWe\treevaluate\tour\tsales\tstrategy\tboth\tglobally\tand\tat\ta\tlocation-by-location\tlevel\tfrom\ttime\tto\ttime\tto\toptimize\tour\tsales\tchannels.\tHowever,\tsales\nof\tvehicles\tin\tthe\tautomobile\tindustry\ttend\tto\tbe\tcyclical\tin\tmany\tmarkets,\twhich\tmay\texpose\tus\tto\tvolatility\tfrom\ttime\tto\ttime.\n6",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 7,
"lines": {
"from": 22,
"to": 39
}
}
}
},
{
"pageContent": "Table\tof\tContents\nUsed\tVehicle\tSales\nOur\tused\tvehicle\tbusiness\tsupports\tnew\tvehicle\tsales\tby\tintegrating\tthe\ttrade-in\tof\ta\tcustomer’s\texisting\tTesla\tor\tnon-Tesla\tvehicle\twith\tthe\tsale\tof\na\tnew\tor\tused\tTesla\tvehicle.\tThe\tTesla\tand\tnon-Tesla\tvehicles\twe\tacquire\tas\ttrade-ins\tare\tsubsequently\tremarketed,\teither\tdirectly\tby\tus\tor\tthrough\tthird\nparties.\tWe\talso\tremarket\tused\tTesla\tvehicles\tacquired\tfrom\tother\tsources\tincluding\tlease\treturns.\nPublic\tCharging\nWe\thave\ta\tgrowing\tglobal\tnetwork\tof\tTesla\tSuperchargers,\twhich\tare\tour\tindustrial-grade,\thigh-speed\tvehicle\tchargers.\tWhere\tpossible,\twe\tco-\nlocate\tSuperchargers\twith\tour\tsolar\tand\tenergy\tstorage\tsystems\tto\treduce\tcosts\tand\tpromote\trenewable\tpower.\tSupercharger\tstations\tare\ttypically\nplaced\talong\twell-traveled\troutes\tand\tin\tand\taround\tdense\tcity\tcenters\tto\tallow\tvehicle\towners\tthe\tability\tto\tenjoy\tquick,\treliable\tcharging\talong\tan\nextensive\tnetwork\twith\tconvenient\tstops.\tUse\tof\tthe\tSupercharger\tnetwork\teither\trequires\tpayment\tof\ta\tfee\tor\tis\tfree\tunder\tcertain\tsales\tprograms.\tIn\nNovember\t2021,\twe\tbegan\tto\toffer\tSupercharger\taccess\tto\tnon-Tesla\tvehicles\tin\tcertain\tlocations\tin\tsupport\tof\tour\tmission\tto\taccelerate\tthe\tworld’s\ntransition\tto\tsustainable\tenergy,\tand\tin\tNovember\t2022,\twe\topened\tup\tour\tpreviously\tproprietary\tcharging\tconnector\tas\tthe\tNorth\tAmerican\tCharging\nStandard\t(NACS).\tThis\tenables\tall\telectric\tvehicles\tand\tcharging\tstations\tto\tinteroperate\t—\twhich\tmakes\tcharging\teasier\tand\tmore\tefficient\tfor\teveryone\nand\tadvances\tour\tmission\tto\taccelerate\tthe\tworld’s\ttransition\tto\tsustainable\tenergy.\tFollowing\tthis,\ta\tnumber\tof\tmajor\tautomotive\tcompanies\tannounced\ntheir\tadoption\tof\tNACS,\twith\ttheir\taccess\tto\tthe\tSupercharger\tnetwork\tbeginning\tin\tphases\tin\t2024\tand\ttheir\tproduction\tof\tNACS\tvehicles\tbeginning\tno\nlater\tthan\t2025.\tWe\talso\tengaged\tSAE\tInternational\tto\tgovern\tNACS\tas\tan\tindustry\tstandard,\tnow\tnamed\tJ3400.\tWe\tcontinue\tto\tmonitor\tand\tincrease\tour\nnetwork\tof\tTesla\tSuperchargers\tin\tanticipation\tof\tfuture\tdemand.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 8,
"lines": {
"from": 1,
"to": 17
}
}
}
},
{
"pageContent": "We\talso\twork\twith\ta\twide\tvariety\tof\thospitality,\tretail\tand\tpublic\tdestinations,\tas\twell\tas\tbusinesses\twith\tcommuting\temployees,\tto\toffer\tadditional\ncharging\toptions\tfor\tour\tcustomers,\tas\twell\tas\tsingle-family\thomeowners\tand\tmulti-family\tresidential\tentities,\tto\tdeploy\thome\tcharging\tsolutions.\nIn-App\tUpgrades\nAs\tour\tvehicles\tare\tcapable\tof\tbeing\tupdated\tremotely\tover-the-air,\tour\tcustomers\tmay\tpurchase\tadditional\tpaid\toptions\tand\tfeatures\tthrough\tthe\nTesla\tapp\tor\tthrough\tthe\tin-vehicle\tuser\tinterface.\tWe\texpect\tthat\tthis\tfunctionality\twill\talso\tallow\tus\tto\toffer\tcertain\toptions\tand\tfeatures\ton\ta\nsubscription\tbasis\tin\tthe\tfuture.\nEnergy\tGeneration\tand\tStorage\nWe\tmarket\tand\tsell\tour\tsolar\tand\tenergy\tstorage\tproducts\tto\tresidential,\tcommercial\tand\tindustrial\tcustomers\tand\tutilities\tthrough\ta\tvariety\tof\nchannels,\tincluding\tthrough\tour\twebsite,\tstores\tand\tgalleries,\tas\twell\tas\tthrough\tour\tnetwork\tof\tchannel\tpartners,\tand\tin\tthe\tcase\tof\tsome\tcommercial\ncustomers,\tthrough\tPPA\ttransactions.\tWe\temphasize\tsimplicity,\tstandardization\tand\taccessibility\tto\tmake\tit\teasy\tand\tcost-effective\tfor\tcustomers\tto\tadopt\nclean\tenergy,\twhile\treducing\tour\tcustomer\tacquisition\tcosts.\nService\tand\tWarranty\nAutomotive\nService\nWe\tprovide\tservice\tfor\tour\telectric\tvehicles\tat\tour\tcompany-owned\tservice\tlocations\tand\tthrough\tTesla\tMobile\tService\ttechnicians\twho\tperform\twork\nremotely\tat\tcustomers’\thomes\tor\tother\tlocations.\tServicing\tthe\tvehicles\tourselves\tallows\tus\tto\tidentify\tproblems\tand\timplement\tsolutions\tand\nimprovements\tfaster\tthan\ttraditional\tautomobile\tmanufacturers\tand\ttheir\tdealer\tnetworks.\tThe\tconnectivity\tof\tour\tvehicles\talso\tallows\tus\tto\tdiagnose\tand\nremedy\tmany\tproblems\tremotely\tand\tproactively.\nVehicle\tLimited\tWarranties\tand\tExtended\tService\tPlans\nWe\tprovide\ta\tmanufacturer’s\tlimited\twarranty\ton\tall\tnew\tand\tused\tTesla\tvehicles\twe\tsell\tdirectly\tto\tconsumers,\twhich\tmay\tinclude\tlimited",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 8,
"lines": {
"from": 18,
"to": 37
}
}
}
},
{
"pageContent": "warranties\ton\tcertain\tcomponents,\tspecific\ttypes\tof\tdamage\tor\tbattery\tcapacity\tretention.\tWe\talso\tcurrently\toffer\toptional\textended\tservice\tplans\tthat\nprovide\tcoverage\tbeyond\tthe\tnew\tvehicle\tlimited\twarranties\tfor\tcertain\tmodels\tin\tspecified\tregions.\n7",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 8,
"lines": {
"from": 38,
"to": 40
}
}
}
},
{
"pageContent": "Table\tof\tContents\nEnergy\tGeneration\tand\tStorage\nWe\tprovide\tservice\tand\trepairs\tto\tour\tenergy\tproduct\tcustomers,\tincluding\tunder\twarranty\twhere\tapplicable.\tWe\tgenerally\tprovide\tmanufacturer’s\nlimited\twarranties\twith\tour\tenergy\tstorage\tproducts\tand\toffer\tcertain\textended\tlimited\twarranties\tthat\tare\tavailable\tat\tthe\ttime\tof\tpurchase\tof\tthe\nsystem.\tIf\twe\tinstall\ta\tsystem,\twe\talso\tprovide\tcertain\tlimited\twarranties\ton\tour\tinstallation\tworkmanship.\nFor\tretrofit\tsolar\tenergy\tsystems,\twe\tprovide\tseparate\tlimited\twarranties\tfor\tworkmanship\tand\tagainst\troof\tleaks,\tand\tfor\tSolar\tRoof,\twe\talso\nprovide\tlimited\twarranties\tfor\tdefects\tand\tweatherization.\tFor\tcomponents\tnot\tmanufactured\tby\tus,\twe\tgenerally\tpass-through\tthe\tapplicable\nmanufacturers’\twarranties.\nAs\tpart\tof\tour\tsolar\tenergy\tsystem\tand\tenergy\tstorage\tcontracts,\twe\tmay\tprovide\tthe\tcustomer\twith\tperformance\tguarantees\tthat\tcommit\tthat\tthe\nunderlying\tsystem\twill\tmeet\tor\texceed\tthe\tminimum\tenergy\tgeneration\tor\tperformance\trequirements\tspecified\tin\tthe\tcontract.\nFinancial\tServices\nAutomotive\nPurchase\tFinancing\tand\tLeases\nWe\toffer\tleasing\tand/or\tloan\tfinancing\tarrangements\tfor\tour\tvehicles\tin\tcertain\tjurisdictions\tin\tNorth\tAmerica,\tEurope\tand\tAsia\tourselves\tand\nthrough\tvarious\tfinancial\tinstitutions.\tUnder\tcertain\tof\tsuch\tprograms,\twe\thave\tprovided\tresale\tvalue\tguarantees\tor\tbuyback\tguarantees\tthat\tmay\nobligate\tus\tto\tcover\ta\tresale\tloss\tup\tto\ta\tcertain\tlimit\tor\trepurchase\tthe\tsubject\tvehicles\tat\tpre-determined\tvalues.\nInsurance\nIn\t2021,\twe\tlaunched\tour\tinsurance\tproduct\tusing\treal-time\tdriving\tbehavior\tin\tselect\tstates,\twhich\toffers\trates\tthat\tare\toften\tbetter\tthan\tother\nalternatives\tand\tpromotes\tsafer\tdriving.\tOur\tinsurance\tproducts\tare\tcurrently\tavailable\tin\t12\tstates\tand\twe\tplan\tto\texpand\tthe\tmarkets\tin\twhich\twe\toffer\ninsurance\tproducts,\tas\tpart\tof\tour\tongoing\teffort\tto\tdecrease\tthe\ttotal\tcost\tof\townership\tfor\tour\tcustomers.\nEnergy\tGeneration\tand\tStorage",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 9,
"lines": {
"from": 1,
"to": 21
}
}
}
},
{
"pageContent": "Energy\tGeneration\tand\tStorage\nWe\toffer\tcertain\tfinancing\toptions\tto\tour\tsolar\tcustomers,\twhich\tenable\tthe\tcustomer\tto\tpurchase\tand\town\ta\tsolar\tenergy\tsystem,\tSolar\tRoof\tor\nintegrated\tsolar\tand\tPowerwall\tsystem.\tOur\tsolar\tPPAs,\toffered\tprimarily\tto\tcommercial\tcustomers,\tcharge\ta\tfee\tper\tkilowatt-hour\tbased\ton\tthe\tamount\tof\nelectricity\tproduced\tby\tour\tsolar\tenergy\tsystems.\nManufacturing\nWe\tcurrently\thave\tmanufacturing\tfacilities\tin\tthe\tU.S.\tin\tNorthern\tCalifornia,\tin\tBuffalo,\tNew\tYork,\tGigafactory\tNew\tYork;\tin\tAustin,\tTexas,\nGigafactory\tTexas\tand\tnear\tReno,\tNevada,\tGigafactory\tNevada.\tAt\tthese\tfacilities,\twe\tmanufacture\tand\tassemble,\tamong\tother\tthings,\tvehicles,\tcertain\nvehicle\tparts\tand\tcomponents,\tsuch\tas\tour\tbattery\tpacks\tand\tbattery\tcells,\tenergy\tstorage\tcomponents\tand\tsolar\tproducts\tand\tcomponents.\nInternationally,\twe\talso\thave\tmanufacturing\tfacilities\tin\tChina\t(Gigafactory\tShanghai)\tand\tGermany\t(Gigafactory\tBerlin-Brandenburg),\twhich\tallows\nus\tto\tincrease\tthe\taffordability\tof\tour\tvehicles\tfor\tcustomers\tin\tlocal\tmarkets\tby\treducing\ttransportation\tand\tmanufacturing\tcosts\tand\teliminating\tthe\nimpact\tof\tunfavorable\ttariffs.\tIn\tMarch\t2023,\twe\tannounced\tthe\tlocation\tof\tour\tnext\tGigafactory\tin\tMonterrey,\tMexico.\tGenerally,\twe\tcontinue\tto\texpand\nproduction\tcapacity\tat\tour\texisting\tfacilities.\tWe\talso\tintend\tto\tfurther\tincrease\tcost-competitiveness\tin\tour\tsignificant\tmarkets\tby\tstrategically\tadding\nlocal\tmanufacturing.\nSupply\tChain\nOur\tproducts\tuse\tthousands\tof\tparts\tthat\tare\tsourced\tfrom\thundreds\tof\tsuppliers\tacross\tthe\tworld.\tWe\thave\tdeveloped\tclose\trelationships\twith\nvendors\tof\tkey\tparts\tsuch\tas\tbattery\tcells,\telectronics\tand\tcomplex\tvehicle\tassemblies.\tCertain\tcomponents\tpurchased\tfrom\tthese\tsuppliers\tare\tshared\tor\nare\tsimilar\tacross\tmany\tproduct\tlines,\tallowing\tus\tto\ttake\tadvantage\tof\tpricing\tefficiencies\tfrom\teconomies\tof\tscale.\n8",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 9,
"lines": {
"from": 21,
"to": 38
}
}
}
},
{
"pageContent": "Table\tof\tContents\nAs\tis\tthe\tcase\tfor\tsome\tautomotive\tcompanies,\tsome\tof\tour\tprocured\tcomponents\tand\tsystems\tare\tsourced\tfrom\tsingle\tsuppliers.\tWhere\tmultiple\nsources\tare\tavailable\tfor\tcertain\tkey\tcomponents,\twe\twork\tto\tqualify\tmultiple\tsuppliers\tfor\tthem\twhere\tit\tis\tsensible\tto\tdo\tso\tin\torder\tto\tminimize\npotential\tproduction\trisks\tdue\tto\tdisruptions\tin\ttheir\tsupply.\tWe\talso\tmitigate\trisk\tby\tmaintaining\tsafety\tstock\tfor\tkey\tparts\tand\tassemblies\tand\tdie\tbanks\nfor\tcomponents\twith\tlengthy\tprocurement\tlead\ttimes.\nOur\tproducts\tuse\tvarious\traw\tmaterials\tincluding\taluminum,\tsteel,\tcobalt,\tlithium,\tnickel\tand\tcopper.\tPricing\tfor\tthese\tmaterials\tis\tgoverned\tby\nmarket\tconditions\tand\tmay\tfluctuate\tdue\tto\tvarious\tfactors\toutside\tof\tour\tcontrol,\tsuch\tas\tsupply\tand\tdemand\tand\tmarket\tspeculation.\tWe\tstrive\tto\nexecute\tlong-term\tsupply\tcontracts\tfor\tsuch\tmaterials\tat\tcompetitive\tpricing\twhen\tfeasible,\tand\twe\tcurrently\tbelieve\tthat\twe\thave\tadequate\taccess\tto\nraw\tmaterials\tsupplies\tto\tmeet\tthe\tneeds\tof\tour\toperations.\nGovernmental\tPrograms,\tIncentives\tand\tRegulations\nGlobally,\tthe\townership\tof\tour\tproducts\tby\tour\tcustomers\tis\timpacted\tby\tvarious\tgovernment\tcredits,\tincentives,\tand\tpolicies.\tOur\tbusiness\tand\nproducts\tare\talso\tsubject\tto\tnumerous\tgovernmental\tregulations\tthat\tvary\tamong\tjurisdictions.\nThe\toperation\tof\tour\tbusiness\tis\talso\timpacted\tby\tvarious\tgovernment\tprograms,\tincentives,\tand\tother\tarrangements.\tSee\tNote\t2,\tSummary\tof\nSignificant\tAccounting\tPolicies,\tto\tthe\tconsolidated\tfinancial\tstatements\tincluded\telsewhere\tin\tthis\tAnnual\tReport\ton\tForm\t10-K\tfor\tfurther\tdetails.\nPrograms\tand\tIncentives\nInflation\tReduction\tAct\nOn\tAugust\t16,\t2022,\tthe\tInflation\tReduction\tAct\tof\t2022\t(“IRA”)\twas\tenacted\tinto\tlaw\tand\tis\teffective\tfor\ttaxable\tyears\tbeginning\tafter\tDecember\n31,\t2022,\tand\tremains\tsubject\tto\tfuture\tguidance\treleases.\tThe\tIRA\tincludes\tmultiple\tincentives\tto\tpromote\tclean\tenergy,\telectric\tvehicles,\tbattery\tand",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 10,
"lines": {
"from": 1,
"to": 18
}
}
}
},
{
"pageContent": "energy\tstorage\tmanufacture\tor\tpurchase,\tincluding\tthrough\tproviding\ttax\tcredits\tto\tconsumers.\tFor\texample,\tqualifying\tTesla\tcustomers\tmay\treceive\tup\nto\t$7,500\tin\tfederal\ttax\tcredits\tfor\tthe\tpurchase\tof\tqualified\telectric\tvehicles\tin\tthe\tU.S.\tthrough\t2032.\nAutomotive\tRegulatory\tCredits\nWe\tearn\ttradable\tcredits\tin\tthe\toperation\tof\tour\tbusiness\tunder\tvarious\tregulations\trelated\tto\tzero-emission\tvehicles\t(“ZEVs”),\tgreenhouse\tgas,\tfuel\neconomy\tand\tclean\tfuel.\tWe\tsell\tthese\tcredits\tto\tother\tregulated\tentities\twho\tcan\tuse\tthe\tcredits\tto\tcomply\twith\temission\tstandards\tand\tother\tregulatory\nrequirements.\tSales\tof\tthese\tcredits\tare\trecognized\twithin\tautomotive\tregulatory\tcredits\trevenue\tin\tour\tconsolidated\tstatements\tof\toperations\tincluded\nelsewhere\tin\tthis\tAnnual\tReport\ton\tForm\t10-K.\nEnergy\tStorage\tSystem\tIncentives\tand\tPolicies\nWhile\tthe\tregulatory\tregime\tfor\tenergy\tstorage\tprojects\tis\tstill\tunder\tdevelopment,\tthere\tare\tvarious\tpolicies,\tincentives\tand\tfinancial\tmechanisms\nat\tthe\tfederal,\tstate\tand\tlocal\tlevels\tthat\tsupport\tthe\tadoption\tof\tenergy\tstorage.\nFor\texample,\tenergy\tstorage\tsystems\tthat\tare\tcharged\tusing\tsolar\tenergy\tmay\tbe\teligible\tfor\tthe\tsolar\tenergy-related\tU.S.\tfederal\ttax\tcredits\ndescribed\tbelow.\tThe\tFederal\tEnergy\tRegulatory\tCommission\t(“FERC”)\thas\talso\ttaken\tsteps\tto\tenable\tthe\tparticipation\tof\tenergy\tstorage\tin\twholesale\nenergy\tmarkets.\tIn\taddition,\tCalifornia\tand\ta\tnumber\tof\tother\tstates\thave\tadopted\tprocurement\ttargets\tfor\tenergy\tstorage,\tand\tbehind-the-meter\tenergy\nstorage\tsystems\tqualify\tfor\tfunding\tunder\tthe\tCalifornia\tSelf\tGeneration\tIncentive\tProgram.\tOur\tcustomers\tprimarily\tbenefit\tdirectly\tunder\tthese\nprograms.\tIn\tcertain\tinstances\tour\tcustomers\tmay\ttransfer\tsuch\tcredits\tto\tus\tas\tcontract\tconsideration.\tIn\tsuch\ttransactions,\tthey\tare\tincluded\tas\ta\ncomponent\tof\tenergy\tgeneration\tand\tstorage\trevenues\tin\tour\tconsolidated\tstatements\tof\toperations\tincluded\telsewhere\tin\tthis\tAnnual\tReport\ton\tForm\n10-K.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 10,
"lines": {
"from": 19,
"to": 35
}
}
}
},
{
"pageContent": "10-K.\nPursuant\tto\tthe\tIRA,\tunder\tSections\t48,\t48E\tand\t25D\tof\tthe\tInternal\tRevenue\tCode\t(”IRC”),\tstandalone\tenergy\tstorage\ttechnology\tis\teligible\tfor\ta\ttax\ncredit\tbetween\t6%\tand\t50%\tof\tqualified\texpenditures,\tregardless\tof\tthe\tsource\tof\tenergy,\twhich\tmay\tbe\tclaimed\tby\tour\tcustomers\tfor\tstorage\tsystems\nthey\tpurchase\tor\tby\tus\tfor\tarrangements\twhere\twe\town\tthe\tsystems.\tThese\ttax\tcredits\tare\tprimarily\tfor\tthe\tbenefit\tof\tour\tcustomers\tand\tare\tcurrently\nscheduled\tto\tphase-out\tstarting\tin\t2032\tor\tlater.\n9",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 10,
"lines": {
"from": 35,
"to": 40
}
}
}
},
{
"pageContent": "Table\tof\tContents\nSolar\tEnergy\tSystem\tIncentives\tand\tPolicies\nU.S.\tfederal,\tstate\tand\tlocal\tgovernments\thave\testablished\tvarious\tpolicies,\tincentives\tand\tfinancial\tmechanisms\tto\treduce\tthe\tcost\tof\tsolar\tenergy\nand\tto\taccelerate\tthe\tadoption\tof\tsolar\tenergy.\tThese\tincentives\tinclude\ttax\tcredits,\tcash\tgrants,\ttax\tabatements\tand\trebates.\nIn\tparticular,\tpursuant\tto\tthe\tIRA,\tSections\t48,\t48E\tand\t25D\tof\tthe\tIRC\tprovides\ta\ttax\tcredit\tbetween\t6%\tand\t70%\tof\tqualified\tcommercial\tor\nresidential\texpenditures\tfor\tsolar\tenergy\tsystems,\twhich\tmay\tbe\tclaimed\tby\tour\tcustomers\tfor\tsystems\tthey\tpurchase,\tor\tby\tus\tfor\tarrangements\twhere\nwe\town\tthe\tsystems\tfor\tproperties\tthat\tmeet\tstatutory\trequirements.\tThese\ttax\tcredits\tare\tprimarily\tfor\tthe\tdirect\tbenefit\tof\tour\tcustomers\tand\tare\ncurrently\tscheduled\tto\tphase-out\tstarting\tin\t2032\tor\tlater.\nRegulations\nVehicle\tSafety\tand\tTesting\nIn\tthe\tU.S.,\tour\tvehicles\tare\tsubject\tto\tregulation\tby\tthe\tNational\tHighway\tTraffic\tSafety\tAdministration\t(“NHTSA”),\tincluding\tall\tapplicable\tFederal\nMotor\tVehicle\tSafety\tStandards\t(“FMVSS”)\tand\tthe\tNHTSA\tbumper\tstandard.\tNumerous\tFMVSS\tapply\tto\tour\tvehicles,\tsuch\tas\tcrash-worthiness\tand\noccupant\tprotection\trequirements.\tOur\tcurrent\tvehicles\tfully\tcomply\tand\twe\texpect\tthat\tour\tvehicles\tin\tthe\tfuture\twill\tfully\tcomply\twith\tall\tapplicable\nFMVSS\twith\tlimited\tor\tno\texemptions,\thowever,\tFMVSS\tare\tsubject\tto\tchange\tfrom\ttime\tto\ttime.\tAs\ta\tmanufacturer,\twe\tmust\tself-certify\tthat\tour\tvehicles\nmeet\tall\tapplicable\tFMVSS\tand\tthe\tNHTSA\tbumper\tstandard,\tor\totherwise\tare\texempt,\tbefore\tthe\tvehicles\tmay\tbe\timported\tor\tsold\tin\tthe\tU.S.\nWe\tare\talso\trequired\tto\tcomply\twith\tother\tfederal\tlaws\tadministered\tby\tNHTSA,\tincluding\tthe\tCorporate\tAverage\tFuel\tEconomy\tstandards,\tTheft\nPrevention\tAct\trequirements,\tlabeling\trequirements\tand\tother\tinformation\tprovided\tto\tcustomers\tin\twriting,\tEarly\tWarning\tReporting\trequirements",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 11,
"lines": {
"from": 1,
"to": 17
}
}
}
},
{
"pageContent": "regarding\twarranty\tclaims,\tfield\treports,\tdeath\tand\tinjury\treports\tand\tforeign\trecalls,\ta\tStanding\tGeneral\tOrder\trequiring\treports\tregarding\tcrashes\ninvolving\tvehicles\tequipped\twith\tadvanced\tdriver\tassistance\tsystems,\tand\tadditional\trequirements\tfor\tcooperating\twith\tcompliance\tand\tsafety\ninvestigations\tand\trecall\treporting.\tThe\tU.S.\tAutomobile\tInformation\tand\tDisclosure\tAct\talso\trequires\tmanufacturers\tof\tmotor\tvehicles\tto\tdisclose\tcertain\ninformation\tregarding\tthe\tmanufacturer’s\tsuggested\tretail\tprice,\toptional\tequipment\tand\tpricing.\tIn\taddition,\tfederal\tlaw\trequires\tinclusion\tof\tfuel\neconomy\tratings,\tas\tdetermined\tby\tthe\tU.S.\tDepartment\tof\tTransportation\tand\tthe\tEnvironmental\tProtection\tAgency\t(the\t“EPA”),\tand\tNew\tCar\nAssessment\tProgram\tratings\tas\tdetermined\tby\tNHTSA,\tif\tavailable.\nOur\tvehicles\tsold\toutside\tof\tthe\tU.S.\tare\tsubject\tto\tsimilar\tforeign\tcompliance,\tsafety,\tenvironmental\tand\tother\tregulations.\tMany\tof\tthose\nregulations\tare\tdifferent\tfrom\tthose\tapplicable\tin\tthe\tU.S.\tand\tmay\trequire\tredesign\tand/or\tretesting.\tSome\tof\tthose\tregulations\timpact\tor\tprevent\tthe\nrollout\tof\tnew\tvehicle\tfeatures.\nSelf-Driving\tVehicles\nGenerally,\tlaws\tpertaining\tto\tself-driving\tvehicles\tare\tevolving\tglobally,\tand\tin\tsome\tcases\tmay\tcreate\trestrictions\ton\tfeatures\tor\tvehicle\tdesigns\nthat\twe\tdevelop.\tWhile\tthere\tare\tcurrently\tno\tfederal\tU.S.\tregulations\tpertaining\tspecifically\tto\tself-driving\tvehicles\tor\tself-driving\tequipment,\tNHTSA\thas\npublished\trecommended\tguidelines\ton\tself-driving\tvehicles,\tapart\tfrom\tthe\tFMVSS\tand\tmanufacturer\treporting\tobligations,\tand\tretains\tthe\tauthority\tto\ninvestigate\tand/or\ttake\taction\ton\tthe\tsafety\tor\tcompliance\tof\tany\tvehicle,\tequipment\tor\tfeatures\toperating\ton\tpublic\troads.\tCertain\tU.S.\tstates\talso\thave\nlegal\trestrictions\ton\tthe\toperation,\tregistration\tor\tlicensure\tof\tself-driving\tvehicles,\tand\tmany\tother\tstates\tare\tconsidering\tthem.\tThis\tregulatory\npatchwork\tincreases\tthe\tlegal\tcomplexity\twith\trespect\tto\tself-driving\tvehicles\tin\tthe\tU.S.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 11,
"lines": {
"from": 18,
"to": 33
}
}
}
},
{
"pageContent": "In\tmarkets\tthat\tfollow\tthe\tregulations\tof\tthe\tUnited\tNations\tEconomic\tCommission\tfor\tEurope\t(“ECE\tmarkets”),\tsome\trequirements\trestrict\tthe\ndesign\tof\tadvanced\tdriver-assistance\tor\tself-driving\tfeatures,\twhich\tcan\tcompromise\tor\tprevent\ttheir\tuse\tentirely.\tOther\tapplicable\tlaws,\tboth\tcurrent\tand\nproposed,\tmay\thinder\tthe\tpath\tand\ttimeline\tto\tintroducing\tself-driving\tvehicles\tfor\tsale\tand\tuse\tin\tthe\tmarkets\twhere\tthey\tapply.\nOther\tkey\tmarkets,\tincluding\tChina,\tcontinue\tto\tconsider\tself-driving\tregulation.\tAny\timplemented\tregulations\tmay\tdiffer\tmaterially\tfrom\tthe\tU.S.\nand\tECE\tmarkets,\twhich\tmay\tfurther\tincrease\tthe\tlegal\tcomplexity\tof\tself-driving\tvehicles\tand\tlimit\tor\tprevent\tcertain\tfeatures.\n10",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 11,
"lines": {
"from": 34,
"to": 39
}
}
}
},
{
"pageContent": "Table\tof\tContents\nAutomobile\tManufacturer\tand\tDealer\tRegulation\nIn\tthe\tU.S.,\tstate\tlaws\tregulate\tthe\tmanufacture,\tdistribution,\tsale\tand\tservice\tof\tautomobiles,\tand\tgenerally\trequire\tmotor\tvehicle\tmanufacturers\nand\tdealers\tto\tbe\tlicensed\tin\torder\tto\tsell\tvehicles\tdirectly\tto\tresidents.\tCertain\tstates\thave\tasserted\tthat\tthe\tlaws\tin\tsuch\tstates\tdo\tnot\tpermit\tautomobile\nmanufacturers\tto\tbe\tlicensed\tas\tdealers\tor\tto\tact\tin\tthe\tcapacity\tof\ta\tdealer,\tor\tthat\tthey\totherwise\trestrict\ta\tmanufacturer’s\tability\tto\tdeliver\tor\tperform\nwarranty\trepairs\ton\tvehicles.\tTo\tsell\tvehicles\tto\tresidents\tof\tstates\twhere\twe\tare\tnot\tlicensed\tas\ta\tdealer,\twe\tgenerally\tconduct\tthe\tsale\tout\tof\tthe\tstate.\nIn\tcertain\tsuch\tstates,\twe\thave\topened\t“galleries”\tthat\tserve\tan\teducational\tpurpose\tand\twhere\tsales\tmay\tnot\toccur.\nSome\tautomobile\tdealer\ttrade\tassociations\thave\tboth\tchallenged\tthe\tlegality\tof\tour\toperations\tin\tcourt\tand\tused\tadministrative\tand\tlegislative\nprocesses\tto\tattempt\tto\tprohibit\tor\tlimit\tour\tability\tto\toperate\texisting\tstores\tor\texpand\tto\tnew\tlocations.\tCertain\tdealer\tassociations\thave\talso\tactively\nlobbied\tstate\tlicensing\tagencies\tand\tlegislators\tto\tinterpret\texisting\tlaws\tor\tenact\tnew\tlaws\tin\tways\tnot\tfavorable\tto\tour\townership\tand\toperation\tof\tour\nown\tretail\tand\tservice\tlocations.\tWe\texpect\tsuch\tchallenges\tto\tcontinue,\tand\twe\tintend\tto\tactively\tfight\tany\tsuch\tefforts.\nBattery\tSafety\tand\tTesting\nOur\tbattery\tpacks\tare\tsubject\tto\tvarious\tU.S.\tand\tinternational\tregulations\tthat\tgovern\ttransport\tof\t“dangerous\tgoods,”\tdefined\tto\tinclude\tlithium-\nion\tbatteries,\twhich\tmay\tpresent\ta\trisk\tin\ttransportation.\tWe\tconduct\ttesting\tto\tdemonstrate\tour\tcompliance\twith\tsuch\tregulations.\nWe\tuse\tlithium-ion\tcells\tin\tour\thigh\tvoltage\tbattery\tpacks\tin\tour\tvehicles\tand\tenergy\tstorage\tproducts.\tThe\tuse,\tstorage\tand\tdisposal\tof\tour\tbattery\npacks\tare\tregulated\tunder\texisting\tlaws\tand\tare\tthe\tsubject\tof\tongoing\tregulatory\tchanges\tthat\tmay\tadd\tadditional\trequirements\tin\tthe\tfuture.\tWe\thave",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 12,
"lines": {
"from": 1,
"to": 16
}
}
}
},
{
"pageContent": "agreements\twith\tthird\tparty\tbattery\trecycling\tcompanies\tto\trecycle\tour\tbattery\tpacks,\tand\twe\tare\talso\tpiloting\tour\town\trecycling\ttechnology.\nSolar\tEnergy—General\nWe\tare\tsubject\tto\tcertain\tstate\tand\tfederal\tregulations\tapplicable\tto\tsolar\tand\tbattery\tstorage\tproviders\tand\tsellers\tof\telectricity.\tTo\toperate\tour\nsystems,\twe\tenter\tinto\tstandard\tinterconnection\tagreements\twith\tapplicable\tutilities.\tSales\tof\telectricity\tand\tnon-sale\tequipment\tleases\tby\tthird\tparties,\nsuch\tas\tour\tleases\tand\tPPAs,\thave\tfaced\tregulatory\tchallenges\tin\tsome\tstates\tand\tjurisdictions.\nSolar\tEnergy—Net\tMetering\nMost\tstates\tin\tthe\tU.S.\tmake\tnet\tenergy\tmetering,\tor\tnet\tmetering,\tavailable\tto\tsolar\tcustomers.\tNet\tmetering\ttypically\tallows\tsolar\tcustomers\tto\ninterconnect\ttheir\tsolar\tenergy\tsystems\tto\tthe\tutility\tgrid\tand\toffset\ttheir\tutility\telectricity\tpurchases\tby\treceiving\ta\tbill\tcredit\tfor\texcess\tenergy\tgenerated\nby\ttheir\tsolar\tenergy\tsystem\tthat\tis\texported\tto\tthe\tgrid.\tIn\tcertain\tjurisdictions,\tregulators\tor\tutilities\thave\treduced\tor\teliminated\tthe\tbenefit\tavailable\nunder\tnet\tmetering\tor\thave\tproposed\tto\tdo\tso.\nCompetition\nAutomotive\nThe\tworldwide\tautomotive\tmarket\tis\thighly\tcompetitive\tand\twe\texpect\tit\twill\tbecome\teven\tmore\tcompetitive\tin\tthe\tfuture\tas\ta\tsignificant\tand\ngrowing\tnumber\tof\testablished\tand\tnew\tautomobile\tmanufacturers,\tas\twell\tas\tother\tcompanies,\thave\tentered,\tor\tare\treported\tto\thave\tplans\tto\tenter\tthe\nelectric\tvehicle\tmarket.\nWe\tbelieve\tthat\tour\tvehicles\tcompete\tin\tthe\tmarket\tbased\ton\tboth\ttheir\ttraditional\tsegment\tclassification\tas\twell\tas\ttheir\tpropulsion\ttechnology.\tFor\nexample,\tCybertruck\tcompetes\twith\tother\tpickup\ttrucks,\tModel\tS\tand\tModel\tX\tcompete\tprimarily\twith\tpremium\tsedans\tand\tpremium\tSUVs\tand\tModel\t3\nand\tModel\tY\tcompete\twith\tsmall\tto\tmedium-sized\tsedans\tand\tcompact\tSUVs,\twhich\tare\textremely\tcompetitive\tmarkets.\tCompeting\tproducts\ttypically",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 12,
"lines": {
"from": 17,
"to": 34
}
}
}
},
{
"pageContent": "include\tinternal\tcombustion\tvehicles\tfrom\tmore\testablished\tautomobile\tmanufacturers;\thowever,\tmany\testablished\tand\tnew\tautomobile\tmanufacturers\nhave\tentered\tor\thave\tannounced\tplans\tto\tenter\tthe\tmarket\tfor\telectric\tand\tother\talternative\tfuel\tvehicles.\tOverall,\twe\tbelieve\tthese\tannouncements\tand\nvehicle\tintroductions,\tincluding\tthe\tintroduction\tof\telectric\tvehicles\tinto\trental\tcar\tcompany\tfleets,\tpromote\tthe\tdevelopment\tof\tthe\telectric\tvehicle\nmarket\tby\thighlighting\tthe\tattractiveness\tof\telectric\tvehicles\trelative\tto\tthe\tinternal\tcombustion\tvehicle.\tMany\tmajor\tautomobile\tmanufacturers\thave\nelectric\tvehicles\tavailable\ttoday\tin\tmajor\tmarkets\tincluding\tthe\tU.S.,\tChina\tand\tEurope,\tand\tother\tcurrent\tand\tprospective\tautomobile\tmanufacturers\tare\nalso\tdeveloping\telectric\tvehicles.\tIn\taddition,\tseveral\tmanufacturers\toffer\thybrid\tvehicles,\tincluding\tplug-in\tversions.\n11",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 12,
"lines": {
"from": 35,
"to": 41
}
}
}
},
{
"pageContent": "Table\tof\tContents\nWe\tbelieve\tthat\tthere\tis\talso\tincreasing\tcompetition\tfor\tour\tvehicle\tofferings\tas\ta\tplatform\tfor\tdelivering\tself-driving\ttechnologies,\tcharging\tsolutions\nand\tother\tfeatures\tand\tservices,\tand\twe\texpect\tto\tcompete\tin\tthis\tdeveloping\tmarket\tthrough\tcontinued\tprogress\ton\tour\tAutopilot,\tFSD\tand\tneural\nnetwork\tcapabilities,\tSupercharger\tnetwork\tand\tour\tinfotainment\tofferings.\nEnergy\tGeneration\tand\tStorage\nEnergy\tStorage\tSystems\nThe\tmarket\tfor\tenergy\tstorage\tproducts\tis\talso\thighly\tcompetitive,\tand\tboth\testablished\tand\temerging\tcompanies\thave\tintroduced\tproducts\tthat\tare\nsimilar\tto\tour\tproduct\tportfolio\tor\tthat\tare\talternatives\tto\tthe\telements\tof\tour\tsystems.\tWe\tcompete\twith\tthese\tcompanies\tbased\ton\tprice,\tenergy\tdensity\nand\tefficiency.\tWe\tbelieve\tthat\tthe\tspecifications\tand\tfeatures\tof\tour\tproducts,\tour\tstrong\tbrand\tand\tthe\tmodular,\tscalable\tnature\tof\tour\tenergy\tstorage\nproducts\tgive\tus\ta\tcompetitive\tadvantage\tin\tour\tmarkets.\nSolar\tEnergy\tSystems\nThe\tprimary\tcompetitors\tto\tour\tsolar\tenergy\tbusiness\tare\tthe\ttraditional\tlocal\tutility\tcompanies\tthat\tsupply\tenergy\tto\tour\tpotential\tcustomers.\tWe\ncompete\twith\tthese\ttraditional\tutility\tcompanies\tprimarily\tbased\ton\tprice\tand\tthe\tease\tby\twhich\tcustomers\tcan\tswitch\tto\telectricity\tgenerated\tby\tour\nsolar\tenergy\tsystems.\tWe\talso\tcompete\twith\tsolar\tenergy\tcompanies\tthat\tprovide\tproducts\tand\tservices\tsimilar\tto\tours.\tMany\tsolar\tenergy\tcompanies\nonly\tinstall\tsolar\tenergy\tsystems,\twhile\tothers\tonly\tprovide\tfinancing\tfor\tthese\tinstallations.\tWe\tbelieve\twe\thave\ta\tsignificant\texpansion\topportunity\twith\nour\tofferings\tand\tthat\tthe\tregulatory\tenvironment\tis\tincreasingly\tconducive\tto\tthe\tadoption\tof\trenewable\tenergy\tsystems.\nIntellectual\tProperty\nWe\tplace\ta\tstrong\temphasis\ton\tour\tinnovative\tapproach\tand\tproprietary\tdesigns\twhich\tbring\tintrinsic\tvalue\tand\tuniqueness\tto\tour\tproduct\tportfolio.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 13,
"lines": {
"from": 1,
"to": 18
}
}
}
},
{
"pageContent": "As\tpart\tof\tour\tbusiness,\twe\tseek\tto\tprotect\tthe\tunderlying\tintellectual\tproperty\trights\tof\tthese\tinnovations\tand\tdesigns\tsuch\tas\twith\trespect\tto\tpatents,\ntrademarks,\tcopyrights,\ttrade\tsecrets,\tconfidential\tinformation\tand\tother\tmeasures,\tincluding\tthrough\temployee\tand\tthird-party\tnondisclosure\nagreements\tand\tother\tcontractual\tarrangements.\tFor\texample,\twe\tplace\ta\thigh\tpriority\ton\tobtaining\tpatents\tto\tprovide\tthe\tbroadest\tand\tstrongest\npossible\tprotection\tto\tenable\tour\tfreedom\tto\toperate\tour\tinnovations\tand\tdesigns\tacross\tall\tof\tour\tproducts\tand\ttechnologies\tas\twell\tas\tto\tprotect\tand\ndefend\tour\tproduct\tportfolio.\tWe\thave\talso\tadopted\ta\tpatent\tpolicy\tin\twhich\twe\tirrevocably\tpledged\tthat\twe\twill\tnot\tinitiate\ta\tlawsuit\tagainst\tany\tparty\tfor\ninfringing\tour\tpatents\tthrough\tactivity\trelating\tto\telectric\tvehicles\tor\trelated\tequipment\tfor\tso\tlong\tas\tsuch\tparty\tis\tacting\tin\tgood\tfaith.\tWe\tmade\tthis\npledge\tin\torder\tto\tencourage\tthe\tadvancement\tof\ta\tcommon,\trapidly-evolving\tplatform\tfor\telectric\tvehicles,\tthereby\tbenefiting\tourselves,\tother\ncompanies\tmaking\telectric\tvehicles\tand\tthe\tworld.\nEnvironmental,\tSocial\tand\tGovernance\t(ESG)\tand\tHuman\tCapital\tResources\nESG\nThe\tvery\tpurpose\tof\tTesla's\texistence\tis\tto\taccelerate\tthe\tworld's\ttransition\tto\tsustainable\tenergy.\tWe\tbelieve\tthe\tworld\tcannot\treduce\tcarbon\nemissions\twithout\taddressing\tboth\tenergy\tgeneration\tand\tconsumption,\tand\twe\tare\tdesigning\tand\tmanufacturing\ta\tcomplete\tenergy\tand\ttransportation\necosystem\tto\tachieve\tthis\tgoal.\tAs\twe\texpand,\twe\tare\tbuilding\teach\tnew\tfactory\tto\tbe\tmore\tefficient\tand\tsustainably\tdesigned\tthan\tthe\tprevious\tone,\nincluding\twith\trespect\tto\tper-unit\twaste\treduction\tand\tresource\tconsumption,\tincluding\twater\tand\tenergy\tusage.\tWe\tare\tfocused\ton\tfurther\tenhancing\nsustainability\tof\toperations\toutside\tof\tour\tdirect\tcontrol,\tincluding\treducing\tthe\tcarbon\tfootprint\tof\tour\tsupply\tchain.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 13,
"lines": {
"from": 19,
"to": 33
}
}
}
},
{
"pageContent": "We\tare\tcommitted\tto\tsourcing\tonly\tresponsibly\tproduced\tmaterials,\tand\tour\tsuppliers\tare\trequired\tto\tprovide\tevidence\tof\tmanagement\tsystems\tthat\nensure\tsocial,\tenvironmental\tand\tsustainability\tbest\tpractices\tin\ttheir\town\toperations,\tas\twell\tas\tto\tdemonstrate\ta\tcommitment\tto\tresponsible\tsourcing\ninto\ttheir\tsupply\tchains.\tWe\thave\ta\tzero-tolerance\tpolicy\twhen\tit\tcomes\tto\tchild\tor\tforced\tlabor\tand\thuman\ttrafficking\tby\tour\tsuppliers\tand\twe\tlook\tto\tthe\nOrganization\tfor\tEconomic\tCo-operation\tand\tDevelopment\tDue\tDiligence\tGuidelines\tto\tinform\tour\tprocess\tand\tuse\tfeedback\tfrom\tour\tinternal\tand\nexternal\tstakeholders\tto\tfind\tways\tto\tcontinually\timprove.\tWe\tare\talso\tdriving\tsafety\tin\tour\town\tfactories\tby\tfocusing\ton\tworker\tengagement.\tOur\nincidents\tper\tvehicle\tcontinue\tto\tdrop\teven\tas\tour\tproduction\tvolumes\tincrease.\tWe\talso\tstrive\tto\tbe\tan\temployer\tof\tchoice\tby\toffering\tcompelling,\nimpactful\tjobs\twith\tbest\tin-industry\tbenefits.\n12",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 13,
"lines": {
"from": 34,
"to": 41
}
}
}
},
{
"pageContent": "Table\tof\tContents\nWe\tbelieve\tthat\tsound\tcorporate\tgovernance\tis\tcritical\tto\thelping\tus\tachieve\tour\tgoals,\tincluding\twith\trespect\tto\tESG.\tWe\tcontinue\tto\tevolve\ta\ngovernance\tframework\tthat\texercises\tappropriate\toversight\tof\tresponsibilities\tat\tall\tlevels\tthroughout\tthe\tcompany\tand\tmanages\tits\taffairs\tconsistent\nwith\thigh\tprinciples\tof\tbusiness\tethics.\tOur\tESG\tSustainability\tCouncil\tis\tmade\tup\tof\tleaders\tfrom\tacross\tour\tcompany,\tand\tregularly\tpresents\tto\tour\tBoard\nof\tDirectors,\twhich\toversees\tour\tESG\timpacts,\tinitiatives\tand\tpriorities.\nHuman\tCapital\tResources\nA\tcompetitive\tedge\tfor\tTesla\tis\tits\tability\tto\tattract\tand\tretain\thigh\tquality\temployees.\tDuring\tthe\tpast\tyear,\tTesla\tmade\tsubstantial\tinvestments\tin\nits\tworkforce,\tfurther\tstrengthening\tits\tstanding\tas\tone\tof\tthe\tmost\tdesirable\tand\tinnovative\tcompanies\tto\twork\tfor.\tAs\tof\tDecember\t31,\t2023,\tour\nemployee\theadcount\tworldwide\twas\t140,473.\nWe\thave\tcreated\tan\tenvironment\tthat\tfosters\tgrowth\topportunities,\tand\tas\tof\tthis\treport,\tnearly\ttwo-thirds\t(65%)\tof\tour\tmanagers\twere\tpromoted\nfrom\tan\tinternal,\tnon-manager\tposition,\tand\t43%\tof\tour\tmanagement\temployees\thave\tbeen\twith\tTesla\tfor\tmore\tthan\tfive\tyears.\tTesla’s\tgrowth\tof\t35%\nover\tthe\tpast\ttwo\tyears\thas\toffered\tinternal\tcareer\tdevelopment\tto\tour\temployees\tas\twell\tas\tthe\tability\tto\tmake\ta\tmeaningful\tcontribution\tto\ta\nsustainable\tfuture.\nWe\tare\table\tto\tretain\tour\temployees,\tin\tpart,\tnot\tonly\tbecause\temployees\tcan\tenjoy\townership\tin\tTesla\tthrough\tstock\t(of\twhich\t89%\thave\tbeen\ngiven\tthe\topportunity\tto),\tbut\tbecause\twe\talso\tprovide\tthem\twith\texcellent\thealth\tbenefits\tsuch\tas\tfree\tcounseling,\tpaid\tparental\tleave,\tpaid\ttime\toff\tand\nzero-premium\tmedical\tplan\toptions\tthat\tare\tmade\tavailable\ton\tthe\tfirst\tday\tof\temployment.\nWe\trecognize\tthe\tpositive\timpact\tthat\tleaders\tcan\thave\ton\ttheir\tteams\tand\toffer\tfundamental\tskills\ttraining\tand\tcontinuous\tdevelopment\tto\tall\nleaders\tthrough\tvarious\tprograms\tglobally.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 14,
"lines": {
"from": 1,
"to": 18
}
}
}
},
{
"pageContent": "leaders\tthrough\tvarious\tprograms\tglobally.\nWe\tdon’t\tstop\tthere.\tTesla\thas\tseveral\tother\tprograms\tstrategically\tdesigned\tto\tincrease\tpaths\tfor\tgreater\tcareer\topportunity\tsuch\tas:\n•Technician\tTrainee\t(Service)\t– The\tTesla\tTechnician\tTrainee\tProgram\tprovides\ton-the-job\tautomotive\tmaintenance\ttraining\tat\tTesla,\nresulting\tin\tan\tindustry\tcertification.\tTargeted\tat\tindividuals\twith\tlimited\texperience,\twhether\tin\tindustry\tor\tvocational\tschools,\tthe\tprogram\nprepares\ttrainees\tfor\temployment\tas\ttechnicians.\tIn\t2023,\twe\thired\tover\t1,900\tTechnician\tTrainees\tacross\tthe\tU.S.,\tGermany\tand\tChina.\n•START\t(Manufacturing\tand\tService)\t–\tTesla\tSTART\tis\tan\tintensive\ttraining\tprogram\tthat\tcomplements\tthe\tTechnician\tTrainee\tprogram\tand\nequips\tindividuals\twith\tthe\tskills\tneeded\tfor\ta\tsuccessful\ttechnician\trole\tat\tTesla.\tWe\thave\tpartnered\twith\tcolleges\tand\ttechnical\tacademies\tto\nlaunch\tTesla\tSTART\tin\tthe\tU.S.,\tUnited\tKingdom\tand\tGermany.\tIn\t2023,\twe\thired\tover\t350\ttrainees\tfor\tmanufacturing\tand\tservice\troles\tthrough\nthis\tprogram,\tproviding\tan\topportunity\tto\ttransition\tinto\tfull-time\temployment.\n•Internships\t–\tAnnually,\tTesla\thires\tover\t6,000\tuniversity\tand\tcollege\tstudents\tfrom\taround\tthe\tworld.\tWe\trecruit\tfrom\tdiverse\tstudent\norganizations\tand\tcampuses,\tseeking\ttop\ttalent\tpassionate\tabout\tour\tmission.\tOur\tinterns\tengage\tin\tmeaningful\twork\tfrom\tday\tone,\tand\twe\noften\toffer\tthem\tfull-time\tpositions\tpost-internship.\n•Military\tFellowship\tand\tTransition\tPrograms\t– The\tMilitary\tFellowship\tand\tTransition\tPrograms\tare\tdesigned\tto\toffer\texiting\tmilitary\tservice\nmembers\tin\tthe\tU.S.\tand\tEurope\twith\tcareer\tguidance\ton\ttransitioning\tinto\tthe\tcivil\tworkforce.\tWe\tpartner\twith\tthe\tcareer\ttransition\tservices\tof\nEuropean\tDefence\tMinistries\tacross\tfive\tcountries,\tas\twell\tas\tthe\tU.S.\tChamber\tof\tCommerce’s\tHire\tour\tHeroes.\tThese\tprograms\taim\tto\tconvert\nhigh-performing\tindividuals\tto\tfull-time\troles\tand\tcreate\ta\tveteran\ttalent\tpipeline.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 14,
"lines": {
"from": 18,
"to": 33
}
}
}
},
{
"pageContent": "•Apprenticeships\t–\tTesla\tApprenticeships\tare\toffered\tglobally,\tproviding\tacademic\tand\ton-the-job\ttraining\tto\tprepare\tspecialists\tin\tskilled\ntrades.\tApprentices\twill\tcomplete\tbetween\tone\tto\tfour\tyears\tof\ton-the-job\ttraining.\tApprentice\tprograms\thave\tseen\tskilled\ttrade\thires\tacross\tthe\nU.S.,\tAustralia,\tHong\tKong,\tKorea\tand\tGermany.\n•Manufacturing\tDevelopment\tProgram\t– Tesla's\tmanufacturing\tpathway\tprogram\tis\tdesigned\tto\tprovide\tgraduating\thigh\tschool\tseniors\twith\nthe\tfinancial\tresources,\tcoursework\tand\texperience\tthey\tneed\tto\tstart\ta\tsuccessful\tmanufacturing\tcareer\tat\tTesla.\tWe\thired\t373\tgraduates\nthrough\tthis\tprogram\tin\t2023,\tand\tour\tgoal\tin\t2024\tis\tgrow\tthis\tprogram\tto\tover\t600\tstudents\tannually\tacross\tour\tFremont\tFactory,\tGigafactory\nNevada,\tGigafactory\tTexas\tand\tGigafactory\tNew\tYork.\n13",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 14,
"lines": {
"from": 34,
"to": 41
}
}
}
},
{
"pageContent": "Table\tof\tContents\n•Engineering\tDevelopment\tProgram\t– Launched\tin\tJanuary\t2024,\tthis\tprogram\ttargets\trecent\tcollege\tand\tuniversity\tgraduates\tfor\tspecialized\nengineering\tfields.\tIn\tcollaboration\twith\tAustin\tCommunity\tCollege,\tthe\tprogram\teducates\tearly-career\tengineers\tin\tcontrols\tengineering,\nenhancing\ttheir\tknowledge\tof\thigh-demand\ttechnologies\tfor\tU.S.\tmanufacturing.\nWe\twill\tcontinue\tto\texpand\tthe\topportunities\tfor\tour\temployees\tto\tadd\tskills\tand\tdevelop\tprofessionally\twith\ta\tnew\tEmployee\tEducational\tAssistance\nProgram\tlaunching\tin\tthe\tU.S.\tin\tthe\tspring\tof\t2024\tto\thelp\temployees\tpursue\tselect\tcertificates\tor\tdegrees.\tWith\tvirtual,\tself-paced\teducation\toptions\navailable,\temployees\tcan\tpursue\ta\tnew\tpath\tor\texpand\ttheir\tknowledge\twhile\tcontinuing\tto\tgrow\ttheir\tcareer.\nAt\tTesla,\tour\temployees\tshow\tup\tpassionate\tabout\tmaking\ta\tdifference\tin\tthe\tworld\tand\tfor\teach\tother.\tWe\tremain\tunwavering\tin\tour\tdemand\tthat\nour\tfactories,\toffices,\tstores\tand\tservice\tcenters\tare\tplaces\twhere\tour\temployees\tfeel\trespected\tand\tappreciated.\tOur\tpolicies\tare\tdesigned\tto\tpromote\nfairness\tand\trespect\tfor\teveryone.\tWe\thire,\tevaluate\tand\tpromote\temployees\tbased\ton\ttheir\tskills\tand\tperformance.\tEveryone\tis\texpected\tto\tbe\ntrustworthy,\tdemonstrate\texcellence\tin\ttheir\tperformance\tand\tcollaborate\twith\tothers.\tWith\tthis\tin\tmind,\twe\twill\tnot\ttolerate\tcertain\tbehaviors.\tThese\ninclude\tharassment,\tretaliation,\tviolence,\tintimidation\tand\tdiscrimination\tof\tany\tkind\ton\tthe\tbasis\tof\trace,\tcolor,\treligion,\tnational\torigin,\tgender,\tsexual\norientation,\tgender\tidentity,\tgender\texpression,\tage,\tdisability\tor\tveteran\tstatus.\nAnti-harassment\ttraining\tis\tconducted\ton\tday\tone\tof\tnew\thire\torientation\tfor\tall\temployees\tand\treoccurring\tfor\tleaders.\tIn\taddition,\twe\trun\tvarious\nleadership\tdevelopment\tprograms\tthroughout\tthe\tyear\taimed\tat\tenhancing\tleaders’\tskills,\tand\tin\tparticular,\thelping\tthem\tto\tunderstand\thow\tto\nappropriately\trespond\tto\tand\taddress\temployee\tconcerns.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 15,
"lines": {
"from": 1,
"to": 16
}
}
}
},
{
"pageContent": "Employees\tare\tencouraged\tto\tspeak\tup\tboth\tin\tregard\tto\tmisconduct\tand\tsafety\tconcerns\tand\tcan\tdo\tso\tby\tcontacting\tthe\tintegrity\tline,\tsubmitting\nconcerns\tthrough\tour\tTake\tCharge\tprocess,\tor\tnotifying\ttheir\tHuman\tResource\tPartner\tor\tany\tmember\tof\tmanagement.\tConcerns\tare\treviewed\tin\naccordance\twith\testablished\tprotocols\tby\tinvestigators\twith\texpertise,\twho\talso\treview\tfor\ttrends\tand\toutcomes\tfor\tremediation\tand\tappropriate\tcontrols.\nResponding\tto\tquestions\ttimely\tis\tkey\tso\tHuman\tResource\tPartners\tfor\teach\tfunctional\tarea\tare\tvisible\tthroughout\tfacilities\tand\tare\tactively\tinvolved\tin\ndriving\tculture\tand\tengagement\talongside\tbusiness\tleaders.\nAvailable\tInformation\nWe\tfile\tor\tfurnish\tperiodic\treports\tand\tamendments\tthereto,\tincluding\tour\tAnnual\tReports\ton\tForm\t10-K,\tour\tQuarterly\tReports\ton\tForm\t10-Q\tand\nCurrent\tReports\ton\tForm\t8-K,\tproxy\tstatements\tand\tother\tinformation\twith\tthe\tSEC.\tIn\taddition,\tthe\tSEC\tmaintains\ta\twebsite\t(www.sec.gov)\tthat\tcontains\nreports,\tproxy\tand\tinformation\tstatements,\tand\tother\tinformation\tregarding\tissuers\tthat\tfile\telectronically.\tOur\twebsite\tis\tlocated\tat\twww.tesla.com,\tand\nour\treports,\tamendments\tthereto,\tproxy\tstatements\tand\tother\tinformation\tare\talso\tmade\tavailable,\tfree\tof\tcharge,\ton\tour\tinvestor\trelations\twebsite\tat\nir.tesla.com\tas\tsoon\tas\treasonably\tpracticable\tafter\twe\telectronically\tfile\tor\tfurnish\tsuch\tinformation\twith\tthe\tSEC.\tThe\tinformation\tposted\ton\tour\twebsite\nis\tnot\tincorporated\tby\treference\tinto\tthis\tAnnual\tReport\ton\tForm\t10-K.\nITEM\t1A.\tRISK\tFACTORS\nYou\tshould\tcarefully\tconsider\tthe\trisks\tdescribed\tbelow\ttogether\twith\tthe\tother\tinformation\tset\tforth\tin\tthis\treport,\twhich\tcould\tmaterially\taffect\tour\nbusiness,\tfinancial\tcondition\tand\tfuture\tresults.\tThe\trisks\tdescribed\tbelow\tare\tnot\tthe\tonly\trisks\tfacing\tour\tcompany.\tRisks\tand\tuncertainties\tnot\tcurrently\nknown\tto\tus\tor\tthat\twe\tcurrently\tdeem\tto\tbe\timmaterial\talso\tmay\tmaterially\tadversely\taffect\tour\tbusiness,\tfinancial\tcondition\tand\toperating\tresults.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 15,
"lines": {
"from": 17,
"to": 32
}
}
}
},
{
"pageContent": "Risks\tRelated\tto\tOur\tAbility\tto\tGrow\tOur\tBusiness\nWe\tmay\texperience\tdelays\tin\tlaunching\tand\tramping\tthe\tproduction\tof\tour\tproducts\tand\tfeatures,\tor\twe\tmay\tbe\tunable\tto\tcontrol\nour\tmanufacturing\tcosts.\nWe\thave\tpreviously\texperienced\tand\tmay\tin\tthe\tfuture\texperience\tlaunch\tand\tproduction\tramp\tdelays\tfor\tnew\tproducts\tand\tfeatures.\tFor\texample,\nwe\tencountered\tunanticipated\tsupplier\tissues\tthat\tled\tto\tdelays\tduring\tthe\tinitial\tramp\tof\tour\tfirst\tModel\tX\tand\texperienced\tchallenges\twith\ta\tsupplier\tand\nwith\tramping\tfull\tautomation\tfor\tcertain\tof\tour\tinitial\tModel\t3\tmanufacturing\tprocesses.\tIn\taddition,\twe\tmay\tintroduce\tin\tthe\tfuture\tnew\tor\tunique\nmanufacturing\tprocesses\tand\tdesign\tfeatures\tfor\tour\tproducts.\tAs\twe\texpand\tour\tvehicle\tofferings\tand\tglobal\tfootprint,\tthere\tis\tno\tguarantee\tthat\twe\twill\nbe\table\tto\tsuccessfully\tand\ttimely\tintroduce\tand\tscale\tsuch\tprocesses\tor\tfeatures.\n14",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 15,
"lines": {
"from": 33,
"to": 41
}
}
}
},
{
"pageContent": "Table\tof\tContents\nIn\tparticular,\tour\tfuture\tbusiness\tdepends\tin\tlarge\tpart\ton\tincreasing\tthe\tproduction\tof\tmass-market\tvehicles.\tIn\torder\tto\tbe\tsuccessful,\twe\twill\tneed\nto\timplement,\tmaintain\tand\tramp\tefficient\tand\tcost-effective\tmanufacturing\tcapabilities,\tprocesses\tand\tsupply\tchains\tand\tachieve\tthe\tdesign\ttolerances,\nhigh\tquality\tand\toutput\trates\twe\thave\tplanned\tat\tour\tmanufacturing\tfacilities\tin\tCalifornia,\tNevada,\tTexas,\tChina,\tGermany\tand\tany\tfuture\tsites\tsuch\tas\nMexico.\tWe\twill\talso\tneed\tto\thire,\ttrain\tand\tcompensate\tskilled\temployees\tto\toperate\tthese\tfacilities.\tBottlenecks\tand\tother\tunexpected\tchallenges\tsuch\nas\tthose\twe\texperienced\tin\tthe\tpast\tmay\tarise\tduring\tour\tproduction\tramps,\tand\twe\tmust\taddress\tthem\tpromptly\twhile\tcontinuing\tto\timprove\nmanufacturing\tprocesses\tand\treducing\tcosts.\tIf\twe\tare\tnot\tsuccessful\tin\tachieving\tthese\tgoals,\twe\tcould\tface\tdelays\tin\testablishing\tand/or\tsustaining\tour\nproduct\tramps\tor\tbe\tunable\tto\tmeet\tour\trelated\tcost\tand\tprofitability\ttargets.\nWe\thave\texperienced,\tand\tmay\talso\texperience\tsimilar\tfuture\tdelays\tin\tlaunching\tand/or\tramping\tproduction\tof\tour\tenergy\tstorage\tproducts\tand\nSolar\tRoof;\tnew\tproduct\tversions\tor\tvariants;\tnew\tvehicles;\tand\tfuture\tfeatures\tand\tservices\tbased\ton\tartificial\tintelligence.\tLikewise,\twe\tmay\tencounter\ndelays\twith\tthe\tdesign,\tconstruction\tand\tregulatory\tor\tother\tapprovals\tnecessary\tto\tbuild\tand\tbring\tonline\tfuture\tmanufacturing\tfacilities\tand\tproducts.\nAny\tdelay\tor\tother\tcomplication\tin\tramping\tthe\tproduction\tof\tour\tcurrent\tproducts\tor\tthe\tdevelopment,\tmanufacture,\tlaunch\tand\tproduction\tramp\tof\nour\tfuture\tproducts,\tfeatures\tand\tservices,\tor\tin\tdoing\tso\tcost-effectively\tand\twith\thigh\tquality,\tmay\tharm\tour\tbrand,\tbusiness,\tprospects,\tfinancial\ncondition\tand\toperating\tresults.\nOur\tsuppliers\tmay\tfail\tto\tdeliver\tcomponents\taccording\tto\tschedules,\tprices,\tquality\tand\tvolumes\tthat\tare\tacceptable\tto\tus,\tor\twe\nmay\tbe\tunable\tto\tmanage\tthese\tcomponents\teffectively.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 16,
"lines": {
"from": 1,
"to": 16
}
}
}
},
{
"pageContent": "Our\tproducts\tcontain\tthousands\tof\tparts\tpurchased\tglobally\tfrom\thundreds\tof\tsuppliers,\tincluding\tsingle-source\tdirect\tsuppliers,\twhich\texposes\tus\tto\nmultiple\tpotential\tsources\tof\tcomponent\tshortages.\tUnexpected\tchanges\tin\tbusiness\tconditions,\tmaterials\tpricing,\tincluding\tinflation\tof\traw\tmaterial\ncosts,\tlabor\tissues,\twars,\ttrade\tpolicies,\tnatural\tdisasters,\thealth\tepidemics\tsuch\tas\tthe\tglobal\tCOVID-19\tpandemic,\ttrade\tand\tshipping\tdisruptions,\tport\ncongestions,\tcyberattacks\tand\tother\tfactors\tbeyond\tour\tor\tour\tsuppliers’\tcontrol\tcould\talso\taffect\tthese\tsuppliers’\tability\tto\tdeliver\tcomponents\tto\tus\tor\tto\nremain\tsolvent\tand\toperational.\tFor\texample,\ta\tglobal\tshortage\tof\tsemiconductors\tbeginning\tin\tearly\t2021\thas\tcaused\tchallenges\tin\tthe\tmanufacturing\nindustry\tand\timpacted\tour\tsupply\tchain\tand\tproduction.\tAdditionally,\tif\tour\tsuppliers\tdo\tnot\taccurately\tforecast\tand\teffectively\tallocate\tproduction\tor\tif\nthey\tare\tnot\twilling\tto\tallocate\tsufficient\tproduction\tto\tus,\tor\tface\tother\tchallenges\tsuch\tas\tinsolvency,\tit\tmay\treduce\tour\taccess\tto\tcomponents\tand\nrequire\tus\tto\tsearch\tfor\tnew\tsuppliers.\tThe\tunavailability\tof\tany\tcomponent\tor\tsupplier\tcould\tresult\tin\tproduction\tdelays,\tidle\tmanufacturing\tfacilities,\nproduct\tdesign\tchanges\tand\tloss\tof\taccess\tto\timportant\ttechnology\tand\ttools\tfor\tproducing\tand\tsupporting\tour\tproducts,\tas\twell\tas\timpact\tour\tcapacity\nexpansion\tand\tour\tability\tto\tfulfill\tour\tobligations\tunder\tcustomer\tcontracts.\tMoreover,\tsignificant\tincreases\tin\tour\tproduction\tor\tproduct\tdesign\tchanges\nby\tus\thave\trequired\tand\tmay\tin\tthe\tfuture\trequire\tus\tto\tprocure\tadditional\tcomponents\tin\ta\tshort\tamount\tof\ttime.\tWe\thave\tfaced\tin\tthe\tpast,\tand\tmay\nface\tsuppliers\twho\tare\tunwilling\tor\tunable\tto\tsustainably\tmeet\tour\ttimelines\tor\tour\tcost,\tquality\tand\tvolume\tneeds,\twhich\tmay\tincrease\tour\tcosts\tor\nrequire\tus\tto\treplace\tthem\twith\tother\tsources.\tFinally,\tas\twe\tconstruct\tnew\tmanufacturing\tfacilities\tand\tadd\tproduction\tlines\tto\texisting\tfacilities,\twe\tmay",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 16,
"lines": {
"from": 17,
"to": 29
}
}
}
},
{
"pageContent": "experience\tissues\tin\tcorrespondingly\tincreasing\tthe\tlevel\tof\tlocalized\tprocurement\tat\tthose\tfacilities.\tWhile\twe\tbelieve\tthat\twe\twill\tbe\table\tto\tsecure\nadditional\tor\talternate\tsources\tor\tdevelop\tour\town\treplacements\tfor\tmost\tof\tour\tcomponents,\tthere\tis\tno\tassurance\tthat\twe\twill\tbe\table\tto\tdo\tso\tquickly\nor\tat\tall.\tAdditionally,\twe\tmay\tbe\tunsuccessful\tin\tour\tcontinuous\tefforts\tto\tnegotiate\twith\texisting\tsuppliers\tto\tobtain\tcost\treductions\tand\tavoid\nunfavorable\tchanges\tto\tterms,\tsource\tless\texpensive\tsuppliers\tfor\tcertain\tparts\tand\tredesign\tcertain\tparts\tto\tmake\tthem\tless\texpensive\tto\tproduce,\nespecially\tin\tthe\tcase\tof\tincreases\tin\tmaterials\tpricing.\tAny\tof\tthese\toccurrences\tmay\tharm\tour\tbusiness,\tprospects,\tfinancial\tcondition\tand\toperating\nresults.\nAs\tthe\tscale\tof\tour\tvehicle\tproduction\tincreases,\twe\twill\talso\tneed\tto\taccurately\tforecast,\tpurchase,\twarehouse\tand\ttransport\tcomponents\tat\thigh\nvolumes\tto\tour\tmanufacturing\tfacilities\tand\tservicing\tlocations\tinternationally.\tIf\twe\tare\tunable\tto\taccurately\tmatch\tthe\ttiming\tand\tquantities\tof\ncomponent\tpurchases\tto\tour\tactual\tneeds\tor\tsuccessfully\timplement\tautomation,\tinventory\tmanagement\tand\tother\tsystems\tto\taccommodate\tthe\nincreased\tcomplexity\tin\tour\tsupply\tchain\tand\tparts\tmanagement,\twe\tmay\tincur\tunexpected\tproduction\tdisruption,\tstorage,\ttransportation\tand\twrite-off\ncosts,\twhich\tmay\tharm\tour\tbusiness\tand\toperating\tresults.\nWe\tmay\tbe\tunable\tto\tmeet\tour\tprojected\tconstruction\ttimelines,\tcosts\tand\tproduction\tramps\tat\tnew\tfactories,\tor\twe\tmay\nexperience\tdifficulties\tin\tgenerating\tand\tmaintaining\tdemand\tfor\tproducts\tmanufactured\tthere.\nOur\tability\tto\tincrease\tproduction\tof\tour\tvehicles\ton\ta\tsustained\tbasis,\tmake\tthem\taffordable\tglobally\tby\taccessing\tlocal\tsupply\tchains\tand\nworkforces\tand\tstreamline\tdelivery\tlogistics\tis\tdependent\ton\tthe\tconstruction\tand\tramp\tof\tour\tcurrent\tand\tfuture\tfactories.\tThe\tconstruction\tof\tand\ncommencement\tand\tramp\tof\tproduction\tat\tthese\tfactories\tare\tsubject\n15",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 16,
"lines": {
"from": 30,
"to": 46
}
}
}
},
{
"pageContent": "Table\tof\tContents\nto\ta\tnumber\tof\tuncertainties\tinherent\tin\tall\tnew\tmanufacturing\toperations,\tincluding\tongoing\tcompliance\twith\tregulatory\trequirements,\tprocurement\tand\nmaintenance\tof\tconstruction,\tenvironmental\tand\toperational\tlicenses\tand\tapprovals\tfor\tadditional\texpansion,\tsupply\tchain\tconstraints,\thiring,\ttraining\tand\nretention\tof\tqualified\temployees\tand\tthe\tpace\tof\tbringing\tproduction\tequipment\tand\tprocesses\tonline\twith\tthe\tcapability\tto\tmanufacture\thigh-quality\nunits\tat\tscale.\tMoreover,\twe\twill\thave\tto\testablish\tand\tramp\tproduction\tof\tour\tproprietary\tbattery\tcells\tand\tpacks\tat\tour\tnew\tfactories,\tand\twe\tadditionally\nintend\tto\tincorporate\tsequential\tdesign\tand\tmanufacturing\tchanges\tinto\tvehicles\tmanufactured\tat\teach\tnew\tfactory.\tIf\twe\texperience\tany\tissues\tor\tdelays\nin\tmeeting\tour\tprojected\ttimelines,\tcosts,\tcapital\tefficiency\tand\tproduction\tcapacity\tfor\tour\tnew\tfactories,\texpanding\tand\tmanaging\tteams\tto\timplement\niterative\tdesign\tand\tproduction\tchanges\tthere,\tmaintaining\tand\tcomplying\twith\tthe\tterms\tof\tany\tdebt\tfinancing\tthat\twe\tobtain\tto\tfund\tthem\tor\tgenerating\nand\tmaintaining\tdemand\tfor\tthe\tvehicles\twe\tmanufacture\tthere,\tour\tbusiness,\tprospects,\toperating\tresults\tand\tfinancial\tcondition\tmay\tbe\tharmed.\nWe\tmay\tbe\tunable\tto\tgrow\tour\tglobal\tproduct\tsales,\tdelivery\tand\tinstallation\tcapabilities\tand\tour\tservicing\tand\tvehicle\tcharging\nnetworks,\tor\twe\tmay\tbe\tunable\tto\taccurately\tproject\tand\teffectively\tmanage\tour\tgrowth.\nOur\tsuccess\twill\tdepend\ton\tour\tability\tto\tcontinue\tto\texpand\tour\tsales\tcapabilities.\tWe\tare\ttargeting\ta\tglobal\tmass\tdemographic\twith\ta\tbroad\trange\nof\tpotential\tcustomers,\tin\twhich\twe\thave\trelatively\tlimited\texperience\tprojecting\tdemand\tand\tpricing\tour\tproducts.\tWe\tcurrently\tproduce\tnumerous\ninternational\tvariants\tat\ta\tlimited\tnumber\tof\tfactories,\tand\tif\tour\tspecific\tdemand\texpectations\tfor\tthese\tvariants\tprove\tinaccurate,\twe\tmay\tnot\tbe\table\tto",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 17,
"lines": {
"from": 1,
"to": 14
}
}
}
},
{
"pageContent": "timely\tgenerate\tdeliveries\tmatched\tto\tthe\tvehicles\tthat\twe\tproduce\tin\tthe\tsame\ttimeframe\tor\tthat\tare\tcommensurate\twith\tthe\tsize\tof\tour\toperations\tin\ta\ngiven\tregion.\tLikewise,\tas\twe\tdevelop\tand\tgrow\tour\tenergy\tproducts\tand\tservices\tworldwide,\tour\tsuccess\twill\tdepend\ton\tour\tability\tto\tcorrectly\tforecast\ndemand\tin\tvarious\tmarkets.\nBecause\twe\tdo\tnot\thave\tindependent\tdealer\tnetworks,\twe\tare\tresponsible\tfor\tdelivering\tall\tof\tour\tvehicles\tto\tour\tcustomers.\tAs\tour\tproduction\nvolumes\tcontinue\tto\tgrow,\twe\thave\tfaced\tin\tthe\tpast,\tand\tmay\tface\tchallenges\twith\tdeliveries\tat\tincreasing\tvolumes,\tparticularly\tin\tinternational\tmarkets\nrequiring\tsignificant\ttransit\ttimes.\tWe\thave\talso\tdeployed\ta\tnumber\tof\tdelivery\tmodels,\tsuch\tas\tdeliveries\tto\tcustomers’\thomes\tand\tworkplaces\tand\ntouchless\tdeliveries,\tbut\tthere\tis\tno\tguarantee\tthat\tsuch\tmodels\twill\tbe\tscalable\tor\tbe\taccepted\tglobally.\tLikewise,\tas\twe\tramp\tour\tenergy\tproducts,\twe\nare\tworking\tto\tsubstantially\tincrease\tour\tproduction\tand\tinstallation\tcapabilities.\tIf\twe\texperience\tproduction\tdelays\tor\tinaccurately\tforecast\tdemand,\tour\nbusiness,\tfinancial\tcondition\tand\toperating\tresults\tmay\tbe\tharmed.\nMoreover,\tbecause\tof\tour\tunique\texpertise\twith\tour\tvehicles,\twe\trecommend\tthat\tour\tvehicles\tbe\tserviced\tby\tus\tor\tby\tcertain\tauthorized\nprofessionals.\tIf\twe\texperience\tdelays\tin\tadding\tservicing\tcapacity\tor\tservicing\tour\tvehicles\tefficiently,\tor\texperience\tunforeseen\tissues\twith\tthe\treliability\nof\tour\tvehicles,\tparticularly\thigher-volume\tadditions\tto\tour\tfleet\tsuch\tas\tModel\t3\tand\tModel\tY,\tit\tcould\toverburden\tour\tservicing\tcapabilities\tand\tparts\ninventory.\tSimilarly,\tthe\tincreasing\tnumber\tof\tTesla\tvehicles\talso\trequires\tus\tto\tcontinue\tto\trapidly\tincrease\tthe\tnumber\tof\tour\tSupercharger\tstations\tand\nconnectors\tthroughout\tthe\tworld.\nThere\tis\tno\tassurance\tthat\twe\twill\tbe\table\tto\tramp\tour\tbusiness\tto\tmeet\tour\tsales,\tdelivery,\tinstallation,\tservicing\tand\tvehicle\tcharging\ttargets",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 17,
"lines": {
"from": 15,
"to": 29
}
}
}
},
{
"pageContent": "globally,\tthat\tour\tprojections\ton\twhich\tsuch\ttargets\tare\tbased\twill\tprove\taccurate\tor\tthat\tthe\tpace\tof\tgrowth\tor\tcoverage\tof\tour\tcustomer\tinfrastructure\nnetwork\twill\tmeet\tcustomer\texpectations.\tThese\tplans\trequire\tsignificant\tcash\tinvestments\tand\tmanagement\tresources\tand\tthere\tis\tno\tguarantee\tthat\nthey\twill\tgenerate\tadditional\tsales\tor\tinstallations\tof\tour\tproducts,\tor\tthat\twe\twill\tbe\table\tto\tavoid\tcost\toverruns\tor\tbe\table\tto\thire\tadditional\tpersonnel\tto\nsupport\tthem.\tAs\twe\texpand,\twe\twill\talso\tneed\tto\tensure\tour\tcompliance\twith\tregulatory\trequirements\tin\tvarious\tjurisdictions\tapplicable\tto\tthe\tsale,\ninstallation\tand\tservicing\tof\tour\tproducts,\tthe\tsale\tor\tdispatch\tof\telectricity\trelated\tto\tour\tenergy\tproducts\tand\tthe\toperation\tof\tSuperchargers.\tIf\twe\tfail\tto\nmanage\tour\tgrowth\teffectively,\tit\tmay\tharm\tour\tbrand,\tbusiness,\tprospects,\tfinancial\tcondition\tand\toperating\tresults.\nWe\twill\tneed\tto\tmaintain\tand\tsignificantly\tgrow\tour\taccess\tto\tbattery\tcells,\tincluding\tthrough\tthe\tdevelopment\tand\tmanufacture\tof\nour\town\tcells,\tand\tcontrol\tour\trelated\tcosts.\nWe\tare\tdependent\ton\tthe\tcontinued\tsupply\tof\tlithium-ion\tbattery\tcells\tfor\tour\tvehicles\tand\tenergy\tstorage\tproducts,\tand\twe\twill\trequire\tsubstantially\nmore\tcells\tto\tgrow\tour\tbusiness\taccording\tto\tour\tplans.\tCurrently,\twe\trely\ton\tsuppliers\tsuch\tas\tPanasonic\tand\tContemporary\tAmperex\tTechnology\tCo.\nLimited\t(CATL)\tfor\tthese\tcells.\tWe\thave\tto\tdate\tfully\tqualified\tonly\ta\tvery\tlimited\tnumber\tof\tsuch\tsuppliers\tand\thave\tlimited\tflexibility\tin\tchanging\nsuppliers.\tAny\tdisruption\tin\tthe\tsupply\tof\tbattery\tcells\tfrom\tour\tsuppliers\tcould\tlimit\tproduction\tof\tour\tvehicles\tand\tenergy\tstorage\tproducts.\tIn\tthe\tlong\nterm,\twe\tintend\tto\tsupplement\tcells\tfrom\tour\tsuppliers\twith\tcells\tmanufactured\tby\tus,\twhich\twe\tbelieve\twill\tbe\tmore\tefficient,\tmanufacturable\tat\tgreater\nvolumes\tand\tmore\tcost-effective\tthan\tcurrently\tavailable\tcells.\tHowever,\tour\tefforts\tto\tdevelop\tand\tmanufacture\tsuch\tbattery\tcells\thave\trequired,\tand",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 17,
"lines": {
"from": 30,
"to": 43
}
}
}
},
{
"pageContent": "may\tcontinue\tto\trequire,\tsignificant\tinvestments,\tand\tthere\tcan\tbe\tno\tassurance\tthat\twe\twill\tbe\table\tto\tachieve\tthese\ttargets\tin\tthe\ttimeframes\tthat\twe\nhave\tplanned\tor\tat\tall.\tIf\twe\tare\n16",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 17,
"lines": {
"from": 44,
"to": 46
}
}
}
},
{
"pageContent": "Table\tof\tContents\nunable\tto\tdo\tso,\twe\tmay\thave\tto\tcurtail\tour\tplanned\tvehicle\tand\tenergy\tstorage\tproduct\tproduction\tor\tprocure\tadditional\tcells\tfrom\tsuppliers\tat\npotentially\tgreater\tcosts,\teither\tof\twhich\tmay\tharm\tour\tbusiness\tand\toperating\tresults.\nIn\taddition,\tthe\tcost\tand\tmass\tproduction\tof\tbattery\tcells,\twhether\tmanufactured\tby\tour\tsuppliers\tor\tby\tus,\tdepends\tin\tpart\tupon\tthe\tprices\tand\navailability\tof\traw\tmaterials\tsuch\tas\tlithium,\tnickel,\tcobalt\tand/or\tother\tmetals.\tThe\tprices\tfor\tthese\tmaterials\tfluctuate\tand\ttheir\tavailable\tsupply\tmay\tbe\nunstable,\tdepending\ton\tmarket\tconditions\tand\tglobal\tdemand\tfor\tthese\tmaterials.\tFor\texample,\tas\ta\tresult\tof\tincreased\tglobal\tproduction\tof\telectric\nvehicles\tand\tenergy\tstorage\tproducts,\tsuppliers\tof\tthese\traw\tmaterials\tmay\tbe\tunable\tto\tmeet\tour\tvolume\tneeds.\tAdditionally,\tour\tsuppliers\tmay\tnot\tbe\nwilling\tor\table\tto\treliably\tmeet\tour\ttimelines\tor\tour\tcost\tand\tquality\tneeds,\twhich\tmay\trequire\tus\tto\treplace\tthem\twith\tother\tsources.\tAny\treduced\navailability\tof\tthese\tmaterials\tmay\timpact\tour\taccess\tto\tcells\tand\tour\tgrowth,\tand\tany\tincreases\tin\ttheir\tprices\tmay\treduce\tour\tprofitability\tif\twe\tcannot\nrecoup\tsuch\tcosts\tthrough\tincreased\tprices.\tMoreover,\tour\tinability\tto\tmeet\tdemand\tand\tany\tproduct\tprice\tincreases\tmay\tharm\tour\tbrand,\tgrowth,\nprospects\tand\toperating\tresults.\nOur\tfuture\tgrowth\tand\tsuccess\tare\tdependent\tupon\tconsumers’\tdemand\tfor\telectric\tvehicles\tand\tspecifically\tour\tvehicles\tin\tan\nautomotive\tindustry\tthat\tis\tgenerally\tcompetitive,\tcyclical\tand\tvolatile.\nThough\twe\tcontinue\tto\tsee\tincreased\tinterest\tand\tadoption\tof\telectric\tvehicles,\tif\tthe\tmarket\tfor\telectric\tvehicles\tin\tgeneral\tand\tTesla\tvehicles\tin\nparticular\tdoes\tnot\tdevelop\tas\twe\texpect,\tdevelops\tmore\tslowly\tthan\twe\texpect,\tor\tif\tdemand\tfor\tour\tvehicles\tdecreases\tin\tour\tmarkets\tor\tour\tvehicles\ncompete\twith\teach\tother,\tour\tbusiness,\tprospects,\tfinancial\tcondition\tand\toperating\tresults\tmay\tbe\tharmed.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 18,
"lines": {
"from": 1,
"to": 16
}
}
}
},
{
"pageContent": "In\taddition,\telectric\tvehicles\tstill\tconstitute\ta\tsmall\tpercentage\tof\toverall\tvehicle\tsales.\tAs\ta\tresult,\tthe\tmarket\tfor\tour\tvehicles\tcould\tbe\tnegatively\naffected\tby\tnumerous\tfactors,\tsuch\tas:\n•perceptions\tabout\telectric\tvehicle\tfeatures,\tquality,\tsafety,\tperformance\tand\tcost;\n•perceptions\tabout\tthe\tlimited\trange\tover\twhich\telectric\tvehicles\tmay\tbe\tdriven\ton\ta\tsingle\tbattery\tcharge,\tand\taccess\tto\tcharging\tfacilities;\n•competition,\tincluding\tfrom\tother\ttypes\tof\talternative\tfuel\tvehicles,\tplug-in\thybrid\telectric\tvehicles\tand\thigh\tfuel-economy\tinternal\tcombustion\nengine\tvehicles;\n•volatility\tin\tthe\tcost\tof\toil,\tgasoline\tand\tenergy;\n•government\tregulations\tand\teconomic\tincentives\tand\tconditions;\tand\n•concerns\tabout\tour\tfuture\tviability.\nThe\ttarget\tdemographics\tfor\tour\tvehicles\tare\thighly\tcompetitive.\tSales\tof\tvehicles\tin\tthe\tautomotive\tindustry\ttend\tto\tbe\tcyclical\tin\tmany\tmarkets,\nwhich\tmay\texpose\tus\tto\tfurther\tvolatility.\tWe\talso\tcannot\tpredict\tthe\tduration\tor\tdirection\tof\tcurrent\tglobal\ttrends\tor\ttheir\tsustained\timpact\ton\tconsumer\ndemand.\tUltimately,\twe\tcontinue\tto\tmonitor\tmacroeconomic\tconditions\tto\tremain\tflexible\tand\tto\toptimize\tand\tevolve\tour\tbusiness\tas\tappropriate,\tand\nattempt\tto\taccurately\tproject\tdemand\tand\tinfrastructure\trequirements\tglobally\tand\tdeploy\tour\tproduction,\tworkforce\tand\tother\tresources\taccordingly.\nRising\tinterest\trates\tmay\tlead\tto\tconsumers\tto\tincreasingly\tpull\tback\tspending,\tincluding\ton\tour\tproducts,\twhich\tmay\tharm\tour\tdemand,\tbusiness\tand\noperating\tresults.\tIf\twe\texperience\tunfavorable\tglobal\tmarket\tconditions,\tor\tif\twe\tcannot\tor\tdo\tnot\tmaintain\toperations\tat\ta\tscope\tthat\tis\tcommensurate\nwith\tsuch\tconditions\tor\tare\tlater\trequired\tto\tor\tchoose\tto\tsuspend\tsuch\toperations\tagain,\tour\tbusiness,\tprospects,\tfinancial\tcondition\tand\toperating\tresults\nmay\tbe\tharmed.\nWe\tface\tstrong\tcompetition\tfor\tour\tproducts\tand\tservices\tfrom\ta\tgrowing\tlist\tof\testablished\tand\tnew\tcompetitors.",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 18,
"lines": {
"from": 17,
"to": 34
}
}
}
},
{
"pageContent": "The\tworldwide\tautomotive\tmarket\tis\thighly\tcompetitive\ttoday\tand\twe\texpect\tit\twill\tbecome\teven\tmore\tso\tin\tthe\tfuture.\tA\tsignificant\tand\tgrowing\nnumber\tof\testablished\tand\tnew\tautomobile\tmanufacturers,\tas\twell\tas\tother\tcompanies,\thave\tentered,\tor\tare\treported\tto\thave\tplans\tto\tenter,\tthe\tmarket\nfor\telectric\tand\tother\talternative\tfuel\tvehicles,\tincluding\thybrid,\tplug-in\thybrid\tand\tfully\telectric\tvehicles,\tas\twell\tas\tthe\tmarket\tfor\tself-driving\ttechnology\nand\tother\tvehicle\tapplications\tand\tsoftware\tplatforms.\tIn\tsome\tcases,\tour\tcompetitors\toffer\tor\twill\toffer\telectric\tvehicles\tin\timportant\tmarkets\tsuch\tas\nChina\tand\tEurope,\tand/or\thave\tannounced\tan\tintention\tto\tproduce\telectric\tvehicles\texclusively\tat\tsome\tpoint\tin\tthe\tfuture.\tIn\taddition,\tcertain\ngovernment\tand\teconomic\tincentives\twhich\tprovide\tbenefits\tto\tmanufacturers\twho\tassemble\tdomestically\tor\thave\tlocal\tsuppliers,\tmay\tprovide\ta\tgreater\nbenefit\tto\tour\tcompetitors,\twhich\tcould\tnegatively\timpact\tour\tprofitability.\tMany\tof\tour\tcompetitors\thave\tsignificantly\tmore\tor\tbetter-established\nresources\tthan\twe\tdo\tto\tdevote\tto\tthe\tdesign,\tdevelopment,\tmanufacturing,\tdistribution,\tpromotion,\tsale\tand\tsupport\tof\ttheir\tproducts.\tIncreased\ncompetition\tcould\tresult\tin\tour\tlower\tvehicle\tunit\tsales,\tprice\treductions,\trevenue\tshortfalls,\tloss\tof\tcustomers\tand\tloss\tof\tmarket\tshare,\twhich\tmay\tharm\nour\tbusiness,\tfinancial\tcondition\tand\toperating\tresults.\n17",
"metadata": {
"source": "./test_docs/test-tsla-10k-2023.pdf",
"pdf": {
"version": "1.10.100",
"info": {
"PDFFormatVersion": "1.4",
"IsAcroFormPresent": false,
"IsXFAPresent": false,
"Title": "",
"Creator": "wkhtmltopdf 0.12.6",
"Producer": "Qt 5.15.2",
"CreationDate": "D:20240129111114Z"
},
"metadata": null,
"totalPages": 130
},
"loc": {
"pageNumber": 18,
"lines": {
"from": 35,
"to": 45
}
}
}
},
{
"pageContent": "Table\tof\tContents\nWe\talso\tface\tcompetition\tin\tour\tenergy\tgeneration\tand\tstorage\tbusiness\tfrom\tother\tmanufacturers,\tdevelopers,\tinstallers\tand\tservice\tproviders\tof\ncompeting\tenergy\ttechnologies,\tas\twell\tas\tfrom\tlarge\tutilities.\tDecreases\tin\tthe\tretail\tor\twholesale\tprices\tof\telectricity\tfrom\tutilities\tor\tother\trenewable\nenergy\tsources\tcould\tmake\tour\tproducts\tless\tattractive\tto\tcustomers\tand\tlead\tto\tan\tincreased\trate\tof\tcustomer\tdefaults.\nRisks\tRelated\tto\tOur\tOperations\nWe\tmay\texperience\tissues\twith\tlithium-ion\tcells\tor\tother\tcomponents\tmanufactured\tat\tour\tGigafactories,\twhich\tmay\tharm\tthe\nproduction\tand\tprofitability\tof\tour\tvehicle\tand\tenergy\tstorage\tproducts.\nOur\tplan\tto\tgrow\tthe\tvolume\tand\tprofitability\tof\tour\tvehicles\tand\tenergy\tstorage\tproducts\tdepends\ton\tsignificant\tlithium-ion\tbattery\tcell\tproduction,\nincluding\tby\tour\tpartner\tPanasonic\tat\tGigafactory\tNevada.\tWe\talso\tproduce\tseveral\tvehicle\tcomponents\tat\tour\tGigafactories,\tsuch\tas\tbattery\tmodules\tand\npacks\tand\tdrive\tunits,\tand\tmanufacture\tenergy\tstorage\tproducts.\tIf\twe\tare\tunable\tto\tor\totherwise\tdo\tnot\tmaintain\tand\tgrow\tour\trespective\toperations,\tor\nif\twe\tare\tunable\tto\tdo\tso\tcost-effectively\tor\thire\tand\tretain\thighly-skilled\tpersonnel\tthere,\tour\tability\tto\tmanufacture\tour\tproducts\tprofitably\twould\tbe\nlimited,\twhich\tmay\tharm\tour\tbusiness\tand\toperating\tresults.\nFinally,\tthe\thigh\tvolumes\tof\tlithium-ion\tcells\tand\tbattery\tmodules\tand\tpacks\tmanufactured\tby\tus\tand\tby\tour\tsuppliers\tare\tstored\tand\trecycled\tat\tour\nvarious\tfacilities.\tAny\tmishandling\tof\tthese\tproducts\tmay\tcause\tdisruption\tto\tthe\toperation\tof\tsuch\tfacilities.\tWhile\twe\thave\timplemen
gitextract_1jzaved4/ ├── .dockerignore ├── .eslintrc.cjs ├── .github/ │ └── workflows/ │ └── ci.yml ├── .gitignore ├── .prettierrc ├── LICENSE ├── README.md ├── backend/ │ ├── .gitignore │ ├── __tests__/ │ │ ├── ingestion_graph/ │ │ │ └── state.test.ts │ │ └── retrieval_graph/ │ │ ├── integration.test.ts │ │ └── promptTemplate.test.ts │ ├── demo.ts │ ├── ingest-demo.ipynb │ ├── jest.config.js │ ├── langgraph.json │ ├── package.json │ ├── src/ │ │ ├── ingestion_graph/ │ │ │ ├── configuration.ts │ │ │ ├── graph.ts │ │ │ └── state.ts │ │ ├── retrieval_graph/ │ │ │ ├── configuration.ts │ │ │ ├── graph.ts │ │ │ ├── prompts.ts │ │ │ ├── state.ts │ │ │ └── utils.ts │ │ ├── sample_docs.json │ │ └── shared/ │ │ ├── configuration.ts │ │ ├── retrieval.ts │ │ ├── state.ts │ │ └── utils.ts │ └── tsconfig.json ├── frontend/ │ ├── .gitignore │ ├── __tests__/ │ │ └── api/ │ │ └── ingest/ │ │ └── route.integration.test.ts │ ├── app/ │ │ ├── api/ │ │ │ ├── chat/ │ │ │ │ └── route.ts │ │ │ └── ingest/ │ │ │ └── route.ts │ │ ├── globals.css │ │ ├── layout.tsx │ │ └── page.tsx │ ├── components/ │ │ ├── chat-message.tsx │ │ ├── example-prompts.tsx │ │ ├── file-preview.tsx │ │ ├── theme-provider.tsx │ │ └── ui/ │ │ ├── accordion.tsx │ │ ├── alert-dialog.tsx │ │ ├── alert.tsx │ │ ├── aspect-ratio.tsx │ │ ├── avatar.tsx │ │ ├── badge.tsx │ │ ├── breadcrumb.tsx │ │ ├── button.tsx │ │ ├── calendar.tsx │ │ ├── card.tsx │ │ ├── carousel.tsx │ │ ├── chart.tsx │ │ ├── checkbox.tsx │ │ ├── collapsible.tsx │ │ ├── command.tsx │ │ ├── context-menu.tsx │ │ ├── dialog.tsx │ │ ├── drawer.tsx │ │ ├── dropdown-menu.tsx │ │ ├── form.tsx │ │ ├── hover-card.tsx │ │ ├── input-otp.tsx │ │ ├── input.tsx │ │ ├── label.tsx │ │ ├── menubar.tsx │ │ ├── navigation-menu.tsx │ │ ├── pagination.tsx │ │ ├── popover.tsx │ │ ├── progress.tsx │ │ ├── radio-group.tsx │ │ ├── resizable.tsx │ │ ├── scroll-area.tsx │ │ ├── select.tsx │ │ ├── separator.tsx │ │ ├── sheet.tsx │ │ ├── sidebar.tsx │ │ ├── skeleton.tsx │ │ ├── slider.tsx │ │ ├── sonner.tsx │ │ ├── switch.tsx │ │ ├── table.tsx │ │ ├── tabs.tsx │ │ ├── textarea.tsx │ │ ├── toast.tsx │ │ ├── toaster.tsx │ │ ├── toggle-group.tsx │ │ ├── toggle.tsx │ │ ├── tooltip.tsx │ │ └── use-mobile.tsx │ ├── components.json │ ├── constants/ │ │ └── graphConfigs.ts │ ├── hooks/ │ │ ├── use-mobile.tsx │ │ └── use-toast.ts │ ├── jest.config.js │ ├── jest.setup.js │ ├── lib/ │ │ ├── langgraph-base.ts │ │ ├── langgraph-client.ts │ │ ├── langgraph-server.ts │ │ ├── pdf.ts │ │ └── utils.ts │ ├── next.config.mjs │ ├── package.json │ ├── postcss.config.mjs │ ├── styles/ │ │ └── globals.css │ ├── tailwind.config.ts │ ├── tsconfig.json │ └── types/ │ └── graphTypes.ts ├── package.json ├── scripts/ │ └── checkLanggraphPaths.js └── turbo.json
SYMBOL INDEX (112 symbols across 43 files)
FILE: backend/demo.ts
function runDemo (line 15) | async function runDemo() {
FILE: backend/src/ingestion_graph/configuration.ts
constant DEFAULT_DOCS_FILE (line 9) | const DEFAULT_DOCS_FILE = './src/sample_docs.json';
function ensureIndexConfiguration (line 30) | function ensureIndexConfiguration(
FILE: backend/src/ingestion_graph/graph.ts
function ingestDocs (line 17) | async function ingestDocs(
FILE: backend/src/ingestion_graph/state.ts
type IndexStateType (line 25) | type IndexStateType = typeof IndexStateAnnotation.State;
FILE: backend/src/retrieval_graph/configuration.ts
function ensureAgentConfiguration (line 28) | function ensureAgentConfiguration(
FILE: backend/src/retrieval_graph/graph.ts
function checkQueryType (line 15) | async function checkQueryType(
function answerQueryDirectly (line 45) | async function answerQueryDirectly(
function routeQuery (line 57) | async function routeQuery(
function retrieveDocuments (line 74) | async function retrieveDocuments(
function generateResponse (line 84) | async function generateResponse(
FILE: backend/src/retrieval_graph/prompts.ts
constant ROUTER_SYSTEM_PROMPT (line 3) | const ROUTER_SYSTEM_PROMPT = ChatPromptTemplate.fromMessages([
constant RESPONSE_SYSTEM_PROMPT (line 11) | const RESPONSE_SYSTEM_PROMPT = ChatPromptTemplate.fromMessages([
FILE: backend/src/retrieval_graph/utils.ts
function formatDoc (line 3) | function formatDoc(doc: Document): string {
function formatDocs (line 13) | function formatDocs(docs?: Document[]): string {
FILE: backend/src/shared/configuration.ts
function ensureBaseConfiguration (line 40) | function ensureBaseConfiguration(
FILE: backend/src/shared/retrieval.ts
function makeSupabaseRetriever (line 11) | async function makeSupabaseRetriever(
function makeRetriever (line 37) | async function makeRetriever(
FILE: backend/src/shared/state.ts
function reduceDocs (line 11) | function reduceDocs(
FILE: backend/src/shared/utils.ts
constant SUPPORTED_PROVIDERS (line 4) | const SUPPORTED_PROVIDERS = [
function loadChatModel (line 27) | async function loadChatModel(
FILE: frontend/app/api/chat/route.ts
function POST (line 7) | async function POST(req: Request) {
FILE: frontend/app/api/ingest/route.ts
constant MAX_FILE_SIZE (line 9) | const MAX_FILE_SIZE = 10 * 1024 * 1024;
constant ALLOWED_FILE_TYPES (line 10) | const ALLOWED_FILE_TYPES = ['application/pdf'];
function POST (line 12) | async function POST(request: NextRequest) {
FILE: frontend/app/layout.tsx
function RootLayout (line 13) | function RootLayout({
FILE: frontend/app/page.tsx
function Home (line 21) | function Home() {
FILE: frontend/components/chat-message.tsx
type ChatMessageProps (line 13) | interface ChatMessageProps {
function ChatMessage (line 21) | function ChatMessage({ message }: ChatMessageProps) {
FILE: frontend/components/example-prompts.tsx
type ExamplePromptsProps (line 3) | interface ExamplePromptsProps {
constant EXAMPLE_PROMPTS (line 7) | const EXAMPLE_PROMPTS = [
function ExamplePrompts (line 16) | function ExamplePrompts({ onPromptSelect }: ExamplePromptsProps) {
FILE: frontend/components/file-preview.tsx
type FilePreviewProps (line 4) | interface FilePreviewProps {
function FilePreview (line 9) | function FilePreview({ file, onRemove }: FilePreviewProps) {
FILE: frontend/components/theme-provider.tsx
function ThemeProvider (line 9) | function ThemeProvider({ children, ...props }: ThemeProviderProps) {
FILE: frontend/components/ui/badge.tsx
type BadgeProps (line 26) | interface BadgeProps
function Badge (line 30) | function Badge({ className, variant, ...props }: BadgeProps) {
FILE: frontend/components/ui/button.tsx
type ButtonProps (line 36) | interface ButtonProps
FILE: frontend/components/ui/calendar.tsx
type CalendarProps (line 10) | type CalendarProps = React.ComponentProps<typeof DayPicker>
function Calendar (line 12) | function Calendar({
FILE: frontend/components/ui/carousel.tsx
type CarouselApi (line 12) | type CarouselApi = UseEmblaCarouselType[1]
type UseCarouselParameters (line 13) | type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
type CarouselOptions (line 14) | type CarouselOptions = UseCarouselParameters[0]
type CarouselPlugin (line 15) | type CarouselPlugin = UseCarouselParameters[1]
type CarouselProps (line 17) | type CarouselProps = {
type CarouselContextProps (line 24) | type CarouselContextProps = {
function useCarousel (line 35) | function useCarousel() {
FILE: frontend/components/ui/chart.tsx
constant THEMES (line 9) | const THEMES = { light: "", dark: ".dark" } as const
type ChartConfig (line 11) | type ChartConfig = {
type ChartContextProps (line 21) | type ChartContextProps = {
function useChart (line 27) | function useChart() {
function getPayloadConfigFromPayload (line 320) | function getPayloadConfigFromPayload(
FILE: frontend/components/ui/form.tsx
type FormFieldContextValue (line 20) | type FormFieldContextValue<
type FormItemContextValue (line 67) | type FormItemContextValue = {
FILE: frontend/components/ui/pagination.tsx
type PaginationLinkProps (line 37) | type PaginationLinkProps = {
FILE: frontend/components/ui/sheet.tsx
type SheetContentProps (line 52) | interface SheetContentProps
FILE: frontend/components/ui/sidebar.tsx
constant SIDEBAR_COOKIE_NAME (line 22) | const SIDEBAR_COOKIE_NAME = "sidebar:state"
constant SIDEBAR_COOKIE_MAX_AGE (line 23) | const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
constant SIDEBAR_WIDTH (line 24) | const SIDEBAR_WIDTH = "16rem"
constant SIDEBAR_WIDTH_MOBILE (line 25) | const SIDEBAR_WIDTH_MOBILE = "18rem"
constant SIDEBAR_WIDTH_ICON (line 26) | const SIDEBAR_WIDTH_ICON = "3rem"
constant SIDEBAR_KEYBOARD_SHORTCUT (line 27) | const SIDEBAR_KEYBOARD_SHORTCUT = "b"
type SidebarContext (line 29) | type SidebarContext = {
function useSidebar (line 41) | function useSidebar() {
FILE: frontend/components/ui/skeleton.tsx
function Skeleton (line 3) | function Skeleton({
FILE: frontend/components/ui/sonner.tsx
type ToasterProps (line 6) | type ToasterProps = React.ComponentProps<typeof Sonner>
FILE: frontend/components/ui/toast.tsx
type ToastProps (line 115) | type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>
type ToastActionElement (line 117) | type ToastActionElement = React.ReactElement<typeof ToastAction>
FILE: frontend/components/ui/toaster.tsx
function Toaster (line 13) | function Toaster() {
FILE: frontend/components/ui/use-mobile.tsx
constant MOBILE_BREAKPOINT (line 3) | const MOBILE_BREAKPOINT = 768
function useIsMobile (line 5) | function useIsMobile() {
FILE: frontend/constants/graphConfigs.ts
type StreamConfigurables (line 3) | type StreamConfigurables = AgentConfiguration;
type IndexConfigurables (line 4) | type IndexConfigurables = IndexConfiguration;
FILE: frontend/hooks/use-mobile.tsx
constant MOBILE_BREAKPOINT (line 3) | const MOBILE_BREAKPOINT = 768
function useIsMobile (line 5) | function useIsMobile() {
FILE: frontend/hooks/use-toast.ts
constant TOAST_LIMIT (line 8) | const TOAST_LIMIT = 1;
constant TOAST_REMOVE_DELAY (line 9) | const TOAST_REMOVE_DELAY = 5000;
type ToasterToast (line 11) | type ToasterToast = ToastProps & {
function genId (line 27) | function genId() {
type ActionType (line 32) | type ActionType = typeof actionTypes;
type Action (line 34) | type Action =
type State (line 52) | interface State {
function dispatch (line 134) | function dispatch(action: Action) {
type Toast (line 141) | type Toast = Omit<ToasterToast, 'id'>;
function toast (line 143) | function toast({ ...props }: Toast) {
function useToast (line 172) | function useToast() {
FILE: frontend/lib/langgraph-base.ts
class LangGraphBase (line 8) | class LangGraphBase {
method constructor (line 11) | constructor(client: Client) {
method createThread (line 18) | async createThread(metadata?: Record<string, any>) {
method getThread (line 25) | async getThread(threadId: string): Promise<Thread> {
method searchThreads (line 32) | async searchThreads(params: {
method getThreadState (line 47) | async getThreadState<T extends Record<string, any> = Record<string, an...
method updateThreadState (line 56) | async updateThreadState(
method deleteThread (line 70) | async deleteThread(threadId: string) {
method getThreadHistory (line 77) | async getThreadHistory(threadId: string, limit: number = 10) {
method isThreadInterrupted (line 84) | isThreadInterrupted(thread: Thread): boolean {
method getThreadInterrupts (line 91) | getThreadInterrupts(thread: Thread): any[] | undefined {
method resumeThread (line 105) | async resumeThread(
FILE: frontend/lib/pdf.ts
function processPDF (line 12) | async function processPDF(file: File): Promise<Document[]> {
function bufferFile (line 44) | async function bufferFile(file: File): Promise<Buffer> {
FILE: frontend/lib/utils.ts
function cn (line 4) | function cn(...inputs: ClassValue[]) {
FILE: frontend/next.config.mjs
function mergeConfig (line 28) | function mergeConfig(nextConfig, userConfig) {
FILE: frontend/types/graphTypes.ts
type documentType (line 6) | type documentType =
type AgentState (line 12) | interface AgentState {
type RetrieveDocumentsNodeUpdates (line 25) | interface RetrieveDocumentsNodeUpdates {
type PDFDocument (line 31) | type PDFDocument = Document & {
type BaseConfiguration (line 59) | interface BaseConfiguration {
type AgentConfiguration (line 80) | interface AgentConfiguration extends BaseConfiguration {
type IndexConfiguration (line 89) | interface IndexConfiguration extends BaseConfiguration {
FILE: scripts/checkLanggraphPaths.js
function fileExists (line 6) | function fileExists(filePath) {
function isObjectExported (line 11) | function isObjectExported(filePath, objectName) {
function checkLanggraphPaths (line 25) | function checkLanggraphPaths() {
Condensed preview — 111 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,094K chars).
[
{
"path": ".dockerignore",
"chars": 17,
"preview": "node_modules\ndist"
},
{
"path": ".eslintrc.cjs",
"chars": 944,
"preview": "/* .eslintrc.cjs */\n\nmodule.exports = {\n root: true, // Ensures ESLint doesn't look beyond this folder for configuratio"
},
{
"path": ".github/workflows/ci.yml",
"chars": 1189,
"preview": "# Run formatting on all PRs\n\nname: CI\n\non:\n push:\n branches: [\"main\"]\n pull_request:\n workflow_dispatch: # Allows "
},
{
"path": ".gitignore",
"chars": 405,
"preview": "# npm\nnode_modules/\n\n# misc\n.DS_Store\n*.pem\n\n# debug\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nui-debug.log*\n\n# loc"
},
{
"path": ".prettierrc",
"chars": 89,
"preview": "{\n \"trailingComma\": \"all\",\n \"singleQuote\": true,\n \"printWidth\": 80,\n \"tabWidth\": 2\n}\n"
},
{
"path": "LICENSE",
"chars": 1089,
"preview": "MIT License\n\nCopyright (c) 2024 [Your Name or Organization Name]\n\nPermission is hereby granted, free of charge, to any p"
},
{
"path": "README.md",
"chars": 12913,
"preview": "# AI PDF Chatbot & Agent Powered by LangChain and LangGraph\n\nThis monorepo is a customizable template example of an AI c"
},
{
"path": "backend/.gitignore",
"chars": 32,
"preview": "\n# LangGraph API\n.langgraph_api\n"
},
{
"path": "backend/__tests__/ingestion_graph/state.test.ts",
"chars": 2122,
"preview": "import { Document } from '@langchain/core/documents';\nimport { reduceDocs } from '../../src/shared/state.js';\n\ndescribe("
},
{
"path": "backend/__tests__/retrieval_graph/integration.test.ts",
"chars": 9415,
"preview": "import dotenv from 'dotenv';\ndotenv.config();\n\nimport { graph } from '../../src/retrieval_graph/graph.js';\nimport { Docu"
},
{
"path": "backend/__tests__/retrieval_graph/promptTemplate.test.ts",
"chars": 1437,
"preview": "import {\n ROUTER_SYSTEM_PROMPT,\n RESPONSE_SYSTEM_PROMPT,\n} from '../../src/retrieval_graph/prompts.js';\n\ndescribe('Pro"
},
{
"path": "backend/demo.ts",
"chars": 2795,
"preview": "import { Client } from '@langchain/langgraph-sdk';\nimport { graph } from './src/retrieval_graph/graph.js';\nimport dotenv"
},
{
"path": "backend/ingest-demo.ipynb",
"chars": 36948,
"preview": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 4,\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n "
},
{
"path": "backend/jest.config.js",
"chars": 799,
"preview": "/** @type {import('ts-jest').JestConfigWithTsJest} */\nexport default {\n preset: 'ts-jest',\n testEnvironment: 'node',\n "
},
{
"path": "backend/langgraph.json",
"chars": 227,
"preview": "{\n \"node_version\": \"20\",\n \"graphs\": {\n \"ingestion_graph\": \"./src/ingestion_graph/graph.ts:graph\",\n \"retr"
},
{
"path": "backend/package.json",
"chars": 2008,
"preview": "{\n \"name\": \"backend\",\n \"version\": \"0.0.1\",\n \"description\": \"Chat with your PDF using this AI agent\",\n \"author\": \"May"
},
{
"path": "backend/src/ingestion_graph/configuration.ts",
"chars": 1391,
"preview": "import { Annotation } from '@langchain/langgraph';\nimport { RunnableConfig } from '@langchain/core/runnables';\nimport {\n"
},
{
"path": "backend/src/ingestion_graph/graph.ts",
"chars": 1679,
"preview": "/**\n * This \"graph\" simply exposes an endpoint for a user to upload docs to be indexed.\n */\n\nimport { RunnableConfig } f"
},
{
"path": "backend/src/ingestion_graph/state.ts",
"chars": 745,
"preview": "import { Annotation } from '@langchain/langgraph';\nimport { Document } from '@langchain/core/documents';\nimport { reduce"
},
{
"path": "backend/src/retrieval_graph/configuration.ts",
"chars": 1170,
"preview": "import { Annotation } from '@langchain/langgraph';\nimport { RunnableConfig } from '@langchain/core/runnables';\nimport {\n"
},
{
"path": "backend/src/retrieval_graph/graph.ts",
"chars": 4098,
"preview": "import { StateGraph, START, END } from '@langchain/langgraph';\nimport { AgentStateAnnotation } from './state.js';\nimport"
},
{
"path": "backend/src/retrieval_graph/prompts.ts",
"chars": 938,
"preview": "import { ChatPromptTemplate } from '@langchain/core/prompts';\n\nconst ROUTER_SYSTEM_PROMPT = ChatPromptTemplate.fromMessa"
},
{
"path": "backend/src/retrieval_graph/state.ts",
"chars": 764,
"preview": "import { Annotation, MessagesAnnotation } from '@langchain/langgraph';\nimport { reduceDocs } from '../shared/state.js';\n"
},
{
"path": "backend/src/retrieval_graph/utils.ts",
"chars": 630,
"preview": "import { Document } from '@langchain/core/documents';\n\nexport function formatDoc(doc: Document): string {\n const metada"
},
{
"path": "backend/src/sample_docs.json",
"chars": 681584,
"preview": "[\n {\n \"pageContent\": \"UNITED\\tSTATES\\nSECURITIES\\tAND\\tEXCHANGE\\tCOMMISSION\\nWashington,\\tD.C.\\t20549\\nFORM\\t10-K\\n("
},
{
"path": "backend/src/shared/configuration.ts",
"chars": 1724,
"preview": "/**\n * Define the configurable parameters for the agent.\n */\n\nimport { Annotation } from '@langchain/langgraph';\nimport "
},
{
"path": "backend/src/shared/retrieval.ts",
"chars": 1634,
"preview": "import { VectorStoreRetriever } from '@langchain/core/vectorstores';\nimport { OpenAIEmbeddings } from '@langchain/openai"
},
{
"path": "backend/src/shared/state.ts",
"chars": 1888,
"preview": "import { Document } from '@langchain/core/documents';\nimport { v4 as uuidv4 } from 'uuid';\n\n/**\n * Reduces the document "
},
{
"path": "backend/src/shared/utils.ts",
"chars": 1622,
"preview": "import { BaseChatModel } from '@langchain/core/language_models/chat_models';\nimport { initChatModel } from 'langchain/ch"
},
{
"path": "backend/tsconfig.json",
"chars": 719,
"preview": "{\n \"extends\": \"@tsconfig/recommended\",\n \"compilerOptions\": {\n \"target\": \"ES2021\",\n \"lib\": [\"ES2021\", \"ES2022.Obj"
},
{
"path": "frontend/.gitignore",
"chars": 323,
"preview": "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n\n# n"
},
{
"path": "frontend/__tests__/api/ingest/route.integration.test.ts",
"chars": 4789,
"preview": "import { POST } from '../../../app/api/ingest/route'; // Import the actual route handler\nimport { NextRequest } from 'ne"
},
{
"path": "frontend/app/api/chat/route.ts",
"chars": 3216,
"preview": "import { NextResponse } from 'next/server';\nimport { createServerClient } from '@/lib/langgraph-server';\nimport { retrie"
},
{
"path": "frontend/app/api/ingest/route.ts",
"chars": 2971,
"preview": "// app/api/ingest/route.ts\nimport { indexConfig } from '@/constants/graphConfigs';\nimport { langGraphServerClient } from"
},
{
"path": "frontend/app/globals.css",
"chars": 1399,
"preview": "@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\n@layer base {\n :root {\n --background: 0 0% 100%;\n --f"
},
{
"path": "frontend/app/layout.tsx",
"chars": 607,
"preview": "import type React from \"react\"\nimport type { Metadata } from \"next\"\nimport { GeistSans } from \"geist/font/sans\"\nimport {"
},
{
"path": "frontend/app/page.tsx",
"chars": 12136,
"preview": "'use client';\n\nimport type React from 'react';\n\nimport { useToast } from '@/hooks/use-toast';\nimport { useRef, useState,"
},
{
"path": "frontend/components/chat-message.tsx",
"chars": 3945,
"preview": "import { Copy } from 'lucide-react';\nimport { Button } from '@/components/ui/button';\nimport { Card, CardContent } from "
},
{
"path": "frontend/components/example-prompts.tsx",
"chars": 744,
"preview": "import { Card } from \"@/components/ui/card\"\n\ninterface ExamplePromptsProps {\n onPromptSelect: (prompt: string) => void\n"
},
{
"path": "frontend/components/file-preview.tsx",
"chars": 884,
"preview": "import { FileIcon, X } from \"lucide-react\"\nimport { Button } from \"@/components/ui/button\"\n\ninterface FilePreviewProps {"
},
{
"path": "frontend/components/theme-provider.tsx",
"chars": 292,
"preview": "'use client'\n\nimport * as React from 'react'\nimport {\n ThemeProvider as NextThemesProvider,\n type ThemeProviderProps,\n"
},
{
"path": "frontend/components/ui/accordion.tsx",
"chars": 1991,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\"\nimport { Ch"
},
{
"path": "frontend/components/ui/alert-dialog.tsx",
"chars": 4434,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as AlertDialogPrimitive from \"@radix-ui/react-alert-dialog\"\n\nimpor"
},
{
"path": "frontend/components/ui/alert.tsx",
"chars": 1584,
"preview": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/"
},
{
"path": "frontend/components/ui/aspect-ratio.tsx",
"chars": 154,
"preview": "\"use client\"\n\nimport * as AspectRatioPrimitive from \"@radix-ui/react-aspect-ratio\"\n\nconst AspectRatio = AspectRatioPrimi"
},
{
"path": "frontend/components/ui/avatar.tsx",
"chars": 1419,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as AvatarPrimitive from \"@radix-ui/react-avatar\"\n\nimport { cn } fr"
},
{
"path": "frontend/components/ui/badge.tsx",
"chars": 1128,
"preview": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/"
},
{
"path": "frontend/components/ui/breadcrumb.tsx",
"chars": 2712,
"preview": "import * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport { ChevronRight, MoreHorizontal } from "
},
{
"path": "frontend/components/ui/button.tsx",
"chars": 1901,
"preview": "import * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport { cva, type VariantProps } from \"class"
},
{
"path": "frontend/components/ui/calendar.tsx",
"chars": 2587,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport { ChevronLeft, ChevronRight } from \"lucide-react\"\nimport { DayPicker"
},
{
"path": "frontend/components/ui/card.tsx",
"chars": 1849,
"preview": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Card = React.forwardRef<\n HTMLDivElement,\n Rea"
},
{
"path": "frontend/components/ui/carousel.tsx",
"chars": 6224,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport useEmblaCarousel, {\n type UseEmblaCarouselType,\n} from \"embla-carou"
},
{
"path": "frontend/components/ui/chart.tsx",
"chars": 10480,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as RechartsPrimitive from \"recharts\"\n\nimport { cn } from \"@/lib/ut"
},
{
"path": "frontend/components/ui/checkbox.tsx",
"chars": 1070,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as CheckboxPrimitive from \"@radix-ui/react-checkbox\"\nimport { Chec"
},
{
"path": "frontend/components/ui/collapsible.tsx",
"chars": 329,
"preview": "\"use client\"\n\nimport * as CollapsiblePrimitive from \"@radix-ui/react-collapsible\"\n\nconst Collapsible = CollapsiblePrimit"
},
{
"path": "frontend/components/ui/command.tsx",
"chars": 4899,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport { type DialogProps } from \"@radix-ui/react-dialog\"\nimport { Command "
},
{
"path": "frontend/components/ui/context-menu.tsx",
"chars": 7260,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as ContextMenuPrimitive from \"@radix-ui/react-context-menu\"\nimport"
},
{
"path": "frontend/components/ui/dialog.tsx",
"chars": 3849,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\"\nimport { X } from"
},
{
"path": "frontend/components/ui/drawer.tsx",
"chars": 3021,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport { Drawer as DrawerPrimitive } from \"vaul\"\n\nimport { cn } from \"@/lib"
},
{
"path": "frontend/components/ui/dropdown-menu.tsx",
"chars": 7433,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\"\nimpo"
},
{
"path": "frontend/components/ui/form.tsx",
"chars": 4099,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { Slot } fro"
},
{
"path": "frontend/components/ui/hover-card.tsx",
"chars": 1198,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as HoverCardPrimitive from \"@radix-ui/react-hover-card\"\n\nimport { "
},
{
"path": "frontend/components/ui/input-otp.tsx",
"chars": 2168,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport { OTPInput, OTPInputContext } from \"input-otp\"\nimport { Dot } from \""
},
{
"path": "frontend/components/ui/input.tsx",
"chars": 791,
"preview": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Input = React.forwardRef<HTMLInputElement, React"
},
{
"path": "frontend/components/ui/label.tsx",
"chars": 724,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { cva, type "
},
{
"path": "frontend/components/ui/menubar.tsx",
"chars": 7988,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as MenubarPrimitive from \"@radix-ui/react-menubar\"\nimport { Check,"
},
{
"path": "frontend/components/ui/navigation-menu.tsx",
"chars": 5046,
"preview": "import * as React from \"react\"\nimport * as NavigationMenuPrimitive from \"@radix-ui/react-navigation-menu\"\nimport { cva }"
},
{
"path": "frontend/components/ui/pagination.tsx",
"chars": 2751,
"preview": "import * as React from \"react\"\nimport { ChevronLeft, ChevronRight, MoreHorizontal } from \"lucide-react\"\n\nimport { cn } f"
},
{
"path": "frontend/components/ui/popover.tsx",
"chars": 1244,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\"\n\nimport { cn } "
},
{
"path": "frontend/components/ui/progress.tsx",
"chars": 791,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as ProgressPrimitive from \"@radix-ui/react-progress\"\n\nimport { cn "
},
{
"path": "frontend/components/ui/radio-group.tsx",
"chars": 1481,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\"\nimport {"
},
{
"path": "frontend/components/ui/resizable.tsx",
"chars": 1723,
"preview": "\"use client\"\n\nimport { GripVertical } from \"lucide-react\"\nimport * as ResizablePrimitive from \"react-resizable-panels\"\n\n"
},
{
"path": "frontend/components/ui/scroll-area.tsx",
"chars": 1656,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as ScrollAreaPrimitive from \"@radix-ui/react-scroll-area\"\n\nimport "
},
{
"path": "frontend/components/ui/select.tsx",
"chars": 5629,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as SelectPrimitive from \"@radix-ui/react-select\"\nimport { Check, C"
},
{
"path": "frontend/components/ui/separator.tsx",
"chars": 770,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as SeparatorPrimitive from \"@radix-ui/react-separator\"\n\nimport { c"
},
{
"path": "frontend/components/ui/sheet.tsx",
"chars": 4281,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as SheetPrimitive from \"@radix-ui/react-dialog\"\nimport { cva, type"
},
{
"path": "frontend/components/ui/sidebar.tsx",
"chars": 23381,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport { VariantProps, cva } fr"
},
{
"path": "frontend/components/ui/skeleton.tsx",
"chars": 261,
"preview": "import { cn } from \"@/lib/utils\"\n\nfunction Skeleton({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) {"
},
{
"path": "frontend/components/ui/slider.tsx",
"chars": 1091,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as SliderPrimitive from \"@radix-ui/react-slider\"\n\nimport { cn } fr"
},
{
"path": "frontend/components/ui/sonner.tsx",
"chars": 894,
"preview": "\"use client\"\n\nimport { useTheme } from \"next-themes\"\nimport { Toaster as Sonner } from \"sonner\"\n\ntype ToasterProps = Rea"
},
{
"path": "frontend/components/ui/switch.tsx",
"chars": 1153,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as SwitchPrimitives from \"@radix-ui/react-switch\"\n\nimport { cn } f"
},
{
"path": "frontend/components/ui/table.tsx",
"chars": 2765,
"preview": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Table = React.forwardRef<\n HTMLTableElement,\n "
},
{
"path": "frontend/components/ui/tabs.tsx",
"chars": 1897,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as TabsPrimitive from \"@radix-ui/react-tabs\"\n\nimport { cn } from \""
},
{
"path": "frontend/components/ui/textarea.tsx",
"chars": 689,
"preview": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Textarea = React.forwardRef<\n HTMLTextAreaEleme"
},
{
"path": "frontend/components/ui/toast.tsx",
"chars": 4859,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as ToastPrimitives from \"@radix-ui/react-toast\"\nimport { cva, type"
},
{
"path": "frontend/components/ui/toaster.tsx",
"chars": 792,
"preview": "'use client';\n\nimport { useToast } from '@/hooks/use-toast';\nimport {\n Toast,\n ToastClose,\n ToastDescription,\n Toast"
},
{
"path": "frontend/components/ui/toggle-group.tsx",
"chars": 1753,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as ToggleGroupPrimitive from \"@radix-ui/react-toggle-group\"\nimport"
},
{
"path": "frontend/components/ui/toggle.tsx",
"chars": 1541,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as TogglePrimitive from \"@radix-ui/react-toggle\"\nimport { cva, typ"
},
{
"path": "frontend/components/ui/tooltip.tsx",
"chars": 1159,
"preview": "\"use client\"\n\nimport * as React from \"react\"\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\"\n\nimport { cn } "
},
{
"path": "frontend/components/ui/use-mobile.tsx",
"chars": 565,
"preview": "import * as React from \"react\"\n\nconst MOBILE_BREAKPOINT = 768\n\nexport function useIsMobile() {\n const [isMobile, setIsM"
},
{
"path": "frontend/components.json",
"chars": 443,
"preview": "{\n \"$schema\": \"https://ui.shadcn.com/schema.json\",\n \"style\": \"default\",\n \"rsc\": true,\n \"tsx\": true,\n \"tailwind\": {\n"
},
{
"path": "frontend/constants/graphConfigs.ts",
"chars": 496,
"preview": "import { AgentConfiguration, IndexConfiguration } from '@/types/graphTypes';\n\ntype StreamConfigurables = AgentConfigurat"
},
{
"path": "frontend/hooks/use-mobile.tsx",
"chars": 565,
"preview": "import * as React from \"react\"\n\nconst MOBILE_BREAKPOINT = 768\n\nexport function useIsMobile() {\n const [isMobile, setIsM"
},
{
"path": "frontend/hooks/use-toast.ts",
"chars": 4116,
"preview": "'use client';\n\n// Inspired by react-hot-toast library\nimport * as React from 'react';\n\nimport type { ToastActionElement,"
},
{
"path": "frontend/jest.config.js",
"chars": 614,
"preview": "const nextJest = require('next/jest');\n\nconst createJestConfig = nextJest({\n // Provide the path to your Next.js app to"
},
{
"path": "frontend/jest.setup.js",
"chars": 1033,
"preview": "// Learn more: https://github.com/testing-library/jest-dom\nimport '@testing-library/jest-dom';\nimport fetch, { Request, "
},
{
"path": "frontend/lib/langgraph-base.ts",
"chars": 2702,
"preview": "import {\n Client,\n DefaultValues,\n Thread,\n ThreadState,\n} from '@langchain/langgraph-sdk';\n\nexport class LangGraphB"
},
{
"path": "frontend/lib/langgraph-client.ts",
"chars": 739,
"preview": "import { Client } from '@langchain/langgraph-sdk';\nimport { LangGraphBase } from './langgraph-base';\n\n// Frontend client"
},
{
"path": "frontend/lib/langgraph-server.ts",
"chars": 1037,
"preview": "import { Client } from '@langchain/langgraph-sdk';\nimport { LangGraphBase } from './langgraph-base';\n\n// Server client s"
},
{
"path": "frontend/lib/pdf.ts",
"chars": 1613,
"preview": "import { PDFLoader } from '@langchain/community/document_loaders/fs/pdf';\nimport { Document } from '@langchain/core/docu"
},
{
"path": "frontend/lib/utils.ts",
"chars": 169,
"preview": "import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: C"
},
{
"path": "frontend/next.config.mjs",
"chars": 884,
"preview": "let userConfig = undefined\ntry {\n userConfig = await import('./v0-user-next.config')\n} catch (e) {\n // ignore error\n}\n"
},
{
"path": "frontend/package.json",
"chars": 3030,
"preview": "{\n \"name\": \"frontend\",\n \"version\": \"0.1.0\",\n \"description\": \"Frontend for the AI chatbot based on the book Learning L"
},
{
"path": "frontend/postcss.config.mjs",
"chars": 135,
"preview": "/** @type {import('postcss-load-config').Config} */\nconst config = {\n plugins: {\n tailwindcss: {},\n },\n};\n\nexport d"
},
{
"path": "frontend/styles/globals.css",
"chars": 2428,
"preview": "@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\nbody {\n font-family: Arial, Helvetica, sans-serif;\n}\n\n@laye"
},
{
"path": "frontend/tailwind.config.ts",
"chars": 2050,
"preview": "import type { Config } from 'tailwindcss';\n\nconst config = {\n darkMode: ['class'],\n content: [\n './pages/**/*.{ts,t"
},
{
"path": "frontend/tsconfig.json",
"chars": 595,
"preview": "{\n \"compilerOptions\": {\n \"lib\": [\"dom\", \"dom.iterable\", \"esnext\"],\n \"allowJs\": true,\n \"target\": \"ES6\",\n \"sk"
},
{
"path": "frontend/types/graphTypes.ts",
"chars": 2125,
"preview": "import { Document } from '@langchain/core/documents';\n\n/**\n * Represents the state of the retrieval graph / agent.\n */\ne"
},
{
"path": "package.json",
"chars": 666,
"preview": "{\n \"name\": \"ai-pdf-chatbot-langchain\",\n \"description\": \"AI PDF chatbot template based on the book Learning LangCha"
},
{
"path": "scripts/checkLanggraphPaths.js",
"chars": 2190,
"preview": "import fs from \"fs\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// Function to check if a file exist"
},
{
"path": "turbo.json",
"chars": 323,
"preview": "{\n \"$schema\": \"https://turbo.build/schema.json\",\n \"globalDependencies\": [\"**/.env\"],\n \"tasks\": {\n \"build\":"
}
]
About this extraction
This page contains the full source code of the mayooear/ai-pdf-chatbot-langchain GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 111 files (958.7 KB), approximately 310.2k tokens, and a symbol index with 112 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.