From 99c0e9fedcd735dc16b1bff5276433ec27b4e8bd Mon Sep 17 00:00:00 2001 From: Jeff Huber Date: Thu, 14 Dec 2023 17:19:37 -0800 Subject: [PATCH] Gemini (#1520) This adds a Google Gemini embedding function and an RAG chat example TODO - [x] JS support - [x] Docs PR --- chromadb/utils/embedding_functions.py | 64 +- clients/js/examples/node/app.js | 13 +- clients/js/examples/node/package.json | 1 + clients/js/examples/node/yarn.lock | 116 ++- .../GoogleGeminiEmbeddingFunction.ts | 69 ++ clients/js/src/index.ts | 1 + examples/gemini/README.md | 53 ++ .../documents/state_of_the_union_2022.txt | 723 ++++++++++++++++++ .../documents/state_of_the_union_2023.txt | 667 ++++++++++++++++ examples/gemini/load_data.py | 106 +++ examples/gemini/main.py | 143 ++++ examples/gemini/requirements.txt | 3 + 12 files changed, 1944 insertions(+), 15 deletions(-) create mode 100644 clients/js/src/embeddings/GoogleGeminiEmbeddingFunction.ts create mode 100644 examples/gemini/README.md create mode 100644 examples/gemini/documents/state_of_the_union_2022.txt create mode 100644 examples/gemini/documents/state_of_the_union_2023.txt create mode 100644 examples/gemini/load_data.py create mode 100644 examples/gemini/main.py create mode 100644 examples/gemini/requirements.txt diff --git a/chromadb/utils/embedding_functions.py b/chromadb/utils/embedding_functions.py index d5e575c7dda..05a4d03887f 100644 --- a/chromadb/utils/embedding_functions.py +++ b/chromadb/utils/embedding_functions.py @@ -144,13 +144,11 @@ def __init__( api_key=api_key, api_version=api_version, azure_endpoint=api_base, - default_headers=default_headers + default_headers=default_headers, ).embeddings else: self._client = openai.OpenAI( - api_key=api_key, - base_url=api_base, - default_headers=default_headers + api_key=api_key, base_url=api_base, default_headers=default_headers ).embeddings else: self._client = openai.Embedding @@ -209,7 +207,9 @@ def __call__(self, input: Documents) -> Embeddings: # Call Cohere Embedding API for each document. return [ embeddings - for embeddings in self._client.embed(texts=input, model=self._model_name, input_type="search_document") + for embeddings in self._client.embed( + texts=input, model=self._model_name, input_type="search_document" + ) ] @@ -260,9 +260,7 @@ class JinaEmbeddingFunction(EmbeddingFunction[Documents]): It requires an API key and a model name. The default model name is "jina-embeddings-v2-base-en". """ - def __init__( - self, api_key: str, model_name: str = "jina-embeddings-v2-base-en" - ): + def __init__(self, api_key: str, model_name: str = "jina-embeddings-v2-base-en"): """ Initialize the JinaEmbeddingFunction. @@ -271,9 +269,11 @@ def __init__( model_name (str, optional): The name of the model to use for text embeddings. Defaults to "jina-embeddings-v2-base-en". """ self._model_name = model_name - self._api_url = 'https://api.jina.ai/v1/embeddings' + self._api_url = "https://api.jina.ai/v1/embeddings" self._session = requests.Session() - self._session.headers.update({"Authorization": f"Bearer {api_key}", "Accept-Encoding": "identity"}) + self._session.headers.update( + {"Authorization": f"Bearer {api_key}", "Accept-Encoding": "identity"} + ) def __call__(self, input: Documents) -> Embeddings: """ @@ -552,6 +552,50 @@ def __call__(self, input: Documents) -> Embeddings: ] +class GoogleGenerativeAiEmbeddingFunction(EmbeddingFunction[Documents]): + """To use this EmbeddingFunction, you must have the google.generativeai Python package installed and have a Google API key.""" + + """Use RETRIEVAL_DOCUMENT for the task_type for embedding, and RETRIEVAL_QUERY for the task_type for retrieval.""" + + def __init__( + self, + api_key: str, + model_name: str = "models/embedding-001", + task_type: str = "RETRIEVAL_DOCUMENT", + ): + if not api_key: + raise ValueError("Please provide a Google API key.") + + if not model_name: + raise ValueError("Please provide the model name.") + + try: + import google.generativeai as genai + except ImportError: + raise ValueError( + "The Google Generative AI python package is not installed. Please install it with `pip install google-generativeai`" + ) + + genai.configure(api_key=api_key) + self._genai = genai + self._model_name = model_name + self._task_type = task_type + self._task_title = None + if self._task_type is "RETRIEVAL_DOCUMENT": + self._task_title = "Embedding of single string" + + def __call__(self, input: Documents) -> Embeddings: + return [ + self._genai.embed_content( + model=self._model_name, + content=text, + task_type=self._task_type, + title=self._task_title, + )["embedding"] + for text in input + ] + + class GoogleVertexEmbeddingFunction(EmbeddingFunction[Documents]): # Follow API Quickstart for Google Vertex AI # https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/api-quickstart diff --git a/clients/js/examples/node/app.js b/clients/js/examples/node/app.js index 25c4459d9f7..0b153aaae35 100644 --- a/clients/js/examples/node/app.js +++ b/clients/js/examples/node/app.js @@ -3,19 +3,17 @@ var path = require("path"); var express = require("express"); var chroma = require("chromadb"); -var openai = require("openai"); var app = express(); app.get("/", async (req, res) => { const cc = new chroma.ChromaClient({ path: "http://localhost:8000" }); await cc.reset(); - const openAIembedder = new chroma.OpenAIEmbeddingFunction("key") - const cohereAIEmbedder = new chroma.OpenAIEmbeddingFunction({ openai_api_key: "API_KEY" }); + const google = new chroma.GoogleGenerativeAiEmbeddingFunction({ googleApiKey:"" }); const collection = await cc.createCollection({ name: "test-from-js", - embeddingFunction: cohereAIEmbedder, + embeddingFunction: google, }); await collection.add({ @@ -29,6 +27,13 @@ app.get("/", async (req, res) => { let count = await collection.count(); console.log("count", count); + const googleQuery = new chroma.GoogleGenerativeAiEmbeddingFunction({ googleApiKey:"", taskType: 'RETRIEVAL_QUERY' }); + + const queryCollection = await cc.getCollection({ + name: "test-from-js", + embeddingFunction: googleQuery, + }); + const query = await collection.query({ queryTexts: ["doc1"], nResults: 1 diff --git a/clients/js/examples/node/package.json b/clients/js/examples/node/package.json index 50f4b23149b..03821cfd2fd 100644 --- a/clients/js/examples/node/package.json +++ b/clients/js/examples/node/package.json @@ -12,6 +12,7 @@ "author": "", "license": "ISC", "dependencies": { + "@google/generative-ai": "^0.1.1", "chromadb": "file:../..", "cohere-ai": "^5.0.2", "express": "^4.18.2", diff --git a/clients/js/examples/node/yarn.lock b/clients/js/examples/node/yarn.lock index 0036e682b93..9fb2312c5b8 100644 --- a/clients/js/examples/node/yarn.lock +++ b/clients/js/examples/node/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@google/generative-ai@^0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@google/generative-ai/-/generative-ai-0.1.1.tgz#ecf0cd832620527f0e35c3aecc17c058d8ba52b8" + integrity sha512-cbzKa8mT9YkTrT4XUuENIuvlqiJjwDgcD2Ks4L99Az9dWLgdXn8xnETEAZLOpqzoGx+1PuATZqlUnVRAeLbMgA== + accepts@~1.3.8: version "1.3.8" resolved "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz" @@ -10,6 +15,18 @@ accepts@~1.3.8: mime-types "~2.1.34" negotiator "0.6.3" +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^4.0.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + array-flatten@1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz" @@ -59,13 +76,37 @@ call-bind@^1.0.0: get-intrinsic "^1.0.2" "chromadb@file:../..": - version "1.5.0" + version "1.7.1-beta2" + dependencies: + cliui "^8.0.1" + isomorphic-fetch "^3.0.0" + +cliui@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" + integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.1" + wrap-ansi "^7.0.0" cohere-ai@^5.0.2: version "5.0.2" resolved "https://registry.npmjs.org/cohere-ai/-/cohere-ai-5.0.2.tgz" integrity sha512-Svt8VC20/GgwCBF2kHYZI3JZkfqEoG6wCbTT6tohNK8x/aBFyMxlBUYEF0gRGXH1055vQpBjj5ewHF8LpnSSOA== +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + combined-stream@^1.0.8: version "1.0.8" resolved "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz" @@ -122,6 +163,11 @@ ee-first@1.1.1: resolved "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + encodeurl@~1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz" @@ -265,6 +311,19 @@ ipaddr.js@1.9.1: resolved "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz" integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +isomorphic-fetch@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz#0267b005049046d2421207215d45d6a262b8b8b4" + integrity sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA== + dependencies: + node-fetch "^2.6.1" + whatwg-fetch "^3.4.1" + media-typer@0.3.0: version "0.3.0" resolved "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz" @@ -312,6 +371,13 @@ negotiator@0.6.3: resolved "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz" integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== +node-fetch@^2.6.1: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + object-inspect@^1.9.0: version "1.12.3" resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz" @@ -430,11 +496,32 @@ statuses@2.0.1: resolved "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz" integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== +string-width@^4.1.0, string-width@^4.2.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + toidentifier@1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + type-is@~1.6.18: version "1.6.18" resolved "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz" @@ -457,3 +544,30 @@ vary@~1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +whatwg-fetch@^3.4.1: + version "3.6.20" + resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz#580ce6d791facec91d37c72890995a0b48d31c70" + integrity sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg== + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" diff --git a/clients/js/src/embeddings/GoogleGeminiEmbeddingFunction.ts b/clients/js/src/embeddings/GoogleGeminiEmbeddingFunction.ts new file mode 100644 index 00000000000..a1ab2abe995 --- /dev/null +++ b/clients/js/src/embeddings/GoogleGeminiEmbeddingFunction.ts @@ -0,0 +1,69 @@ +import { IEmbeddingFunction } from "./IEmbeddingFunction"; + +let googleGenAiApi: any; + +export class GoogleGenerativeAiEmbeddingFunction implements IEmbeddingFunction { + private api_key: string; + private model: string; + private googleGenAiApi?: any; + private taskType: string; + + constructor({ googleApiKey, model, taskType }: { googleApiKey: string, model?: string, taskType?: string }) { + // we used to construct the client here, but we need to async import the types + // for the openai npm package, and the constructor can not be async + this.api_key = googleApiKey; + this.model = model || "embedding-001"; + this.taskType = taskType || "RETRIEVAL_DOCUMENT"; + } + + private async loadClient() { + if(this.googleGenAiApi) return; + try { + // eslint-disable-next-line global-require,import/no-extraneous-dependencies + const { googleGenAi } = await GoogleGenerativeAiEmbeddingFunction.import(); + googleGenAiApi = googleGenAi; + // googleGenAiApi.init(this.api_key); + googleGenAiApi = new googleGenAiApi(this.api_key); + } catch (_a) { + // @ts-ignore + if (_a.code === 'MODULE_NOT_FOUND') { + throw new Error("Please install the @google/generative-ai package to use the GoogleGenerativeAiEmbeddingFunction, `npm install -S @google/generative-ai`"); + } + throw _a; // Re-throw other errors + } + this.googleGenAiApi = googleGenAiApi; + } + + public async generate(texts: string[]) { + + await this.loadClient(); + const model = this.googleGenAiApi.getGenerativeModel({ model: this.model}); + const response = await model.batchEmbedContents({ + requests: texts.map((t) => ({ + content: { parts: [{ text: t }] }, + taskType: this.taskType, + })), + }); + const embeddings = response.embeddings.map((e: any) => e.values); + + return embeddings; + } + + /** @ignore */ + static async import(): Promise<{ + // @ts-ignore + googleGenAi: typeof import("@google/generative-ai"); + }> { + try { + // @ts-ignore + const { GoogleGenerativeAI } = await import("@google/generative-ai"); + const googleGenAi = GoogleGenerativeAI; + return { googleGenAi }; + } catch (e) { + throw new Error( + "Please install @google/generative-ai as a dependency with, e.g. `yarn add @google/generative-ai`" + ); + } + } + +} diff --git a/clients/js/src/index.ts b/clients/js/src/index.ts index 4cda2b9b549..ec605c93a0d 100644 --- a/clients/js/src/index.ts +++ b/clients/js/src/index.ts @@ -4,6 +4,7 @@ export { Collection } from './Collection'; export { IEmbeddingFunction } from './embeddings/IEmbeddingFunction'; export { OpenAIEmbeddingFunction } from './embeddings/OpenAIEmbeddingFunction'; export { CohereEmbeddingFunction } from './embeddings/CohereEmbeddingFunction'; +export { GoogleGenerativeAiEmbeddingFunction } from './embeddings/GoogleGeminiEmbeddingFunction'; export { IncludeEnum, GetParams, diff --git a/examples/gemini/README.md b/examples/gemini/README.md new file mode 100644 index 00000000000..20865f5ec56 --- /dev/null +++ b/examples/gemini/README.md @@ -0,0 +1,53 @@ +# Chat with your documents + +This folder contains a (very) minimal, self-contained example of how to make an application to chat with your documents, using Chroma and Google Gemini's API. +It uses the 2022 and 2023 U.S state of the union addresses as example documents. + +## How it works + +The basic flow is as follows: + +0. The text documents in the `documents` folder are loaded line by line, then embedded and stored in a Chroma collection. + +1. When the user submits a question, it gets embedded using the same model as the documents, and the lines most relevant to the query are retrieved by Chroma. +2. The user-submitted question is passed to Google Gemini's API, along with the extra context retrieved by Chroma. The Google Gemini API generates generates a response. +3. The response is displayed to the user, along with the lines used as extra context. + +## Running the example + +You will need an Google API key to run this demo. + +Install dependencies and run the example: + +```bash +# Install dependencies +pip install -r requirements.txt + +# Load the example documents into Chroma +python load_data.py + +# Run the chatbot +python main.py +``` + +Example output: + +``` +Query: What was said about the pandemic? + +Thinking... + +Based on the given context, several points were made about the pandemic. First, it is described as punishing, indicating the severity and impact it had on various aspects of life. It is mentioned that schools were closed and everything was being shut down in response to the COVID crisis, suggesting the significant measures taken to combat the virus. + +The context then shifts to discussing the progress made in the fight against the pandemic itself. While no specific details are provided, it is implied that there has been progress, though the extent of it is unclear. + +Additionally, it is stated that children were already facing struggles before the pandemic, such as bullying, violence, trauma, and the negative effects of social media. This suggests that these issues were likely exacerbated by the pandemic. + +The context then mentions a spike in violent crime in 2020, which is attributed to the first year of the pandemic. This implies that there was an increase in violent crime during that time period, but the underlying causes or specific details are not provided. + +Lastly, it is mentioned that the pandemic also disrupted global supply chains. Again, no specific details are given, but this suggests that the pandemic had negative effects on the movement and availability of goods and resources at a global level. + +In conclusion, based on the provided context, it is stated that the pandemic has been punishing and has resulted in the closure of schools and the shutdown of various activities. Progress is mentioned in fighting against the pandemic, though the specifics are not given. The pandemic is also said to have worsened pre-existing issues such as bullying and violence among children, and disrupted global supply chains. +``` + +You can replace the example text documents in the `documents` folder with your own documents, and the chatbot will use those instead. diff --git a/examples/gemini/documents/state_of_the_union_2022.txt b/examples/gemini/documents/state_of_the_union_2022.txt new file mode 100644 index 00000000000..7cb2a02c313 --- /dev/null +++ b/examples/gemini/documents/state_of_the_union_2022.txt @@ -0,0 +1,723 @@ +Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. + +Last year COVID-19 kept us apart. This year we are finally together again. + +Tonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. + +With a duty to one another to the American people to the Constitution. + +And with an unwavering resolve that freedom will always triumph over tyranny. + +Six days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. + +He thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. + +He met the Ukrainian people. + +From President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world. + +Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. + +In this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the United States is here tonight. + +Let each of us here tonight in this Chamber send an unmistakable signal to Ukraine and to the world. + +Please rise if you are able and show that, Yes, we the United States of America stand with the Ukrainian people. + +Throughout our history we’ve learned this lesson when dictators do not pay a price for their aggression they cause more chaos. + +They keep moving. + +And the costs and the threats to America and the world keep rising. + +That’s why the NATO Alliance was created to secure peace and stability in Europe after World War 2. + +The United States is a member along with 29 other nations. + +It matters. American diplomacy matters. American resolve matters. + +Putin’s latest attack on Ukraine was premeditated and unprovoked. + +He rejected repeated efforts at diplomacy. + +He thought the West and NATO wouldn’t respond. And he thought he could divide us at home. Putin was wrong. We were ready. Here is what we did. + +We prepared extensively and carefully. + +We spent months building a coalition of other freedom-loving nations from Europe and the Americas to Asia and Africa to confront Putin. + +I spent countless hours unifying our European allies. We shared with the world in advance what we knew Putin was planning and precisely how he would try to falsely justify his aggression. + +We countered Russia’s lies with truth. + +And now that he has acted the free world is holding him accountable. + +Along with twenty-seven members of the European Union including France, Germany, Italy, as well as countries like the United Kingdom, Canada, Japan, Korea, Australia, New Zealand, and many others, even Switzerland. + +We are inflicting pain on Russia and supporting the people of Ukraine. Putin is now isolated from the world more than ever. + +Together with our allies –we are right now enforcing powerful economic sanctions. + +We are cutting off Russia’s largest banks from the international financial system. + +Preventing Russia’s central bank from defending the Russian Ruble making Putin’s $630 Billion “war fund” worthless. + +We are choking off Russia’s access to technology that will sap its economic strength and weaken its military for years to come. + +Tonight I say to the Russian oligarchs and corrupt leaders who have bilked billions of dollars off this violent regime no more. + +The U.S. Department of Justice is assembling a dedicated task force to go after the crimes of Russian oligarchs. + +We are joining with our European allies to find and seize your yachts your luxury apartments your private jets. We are coming for your ill-begotten gains. + +And tonight I am announcing that we will join our allies in closing off American air space to all Russian flights – further isolating Russia – and adding an additional squeeze –on their economy. The Ruble has lost 30% of its value. + +The Russian stock market has lost 40% of its value and trading remains suspended. Russia’s economy is reeling and Putin alone is to blame. + +Together with our allies we are providing support to the Ukrainians in their fight for freedom. Military assistance. Economic assistance. Humanitarian assistance. + +We are giving more than $1 Billion in direct assistance to Ukraine. + +And we will continue to aid the Ukrainian people as they defend their country and to help ease their suffering. + +Let me be clear, our forces are not engaged and will not engage in conflict with Russian forces in Ukraine. + +Our forces are not going to Europe to fight in Ukraine, but to defend our NATO Allies – in the event that Putin decides to keep moving west. + +For that purpose we’ve mobilized American ground forces, air squadrons, and ship deployments to protect NATO countries including Poland, Romania, Latvia, Lithuania, and Estonia. + +As I have made crystal clear the United States and our Allies will defend every inch of territory of NATO countries with the full force of our collective power. + +And we remain clear-eyed. The Ukrainians are fighting back with pure courage. But the next few days weeks, months, will be hard on them. + +Putin has unleashed violence and chaos. But while he may make gains on the battlefield – he will pay a continuing high price over the long run. + +And a proud Ukrainian people, who have known 30 years of independence, have repeatedly shown that they will not tolerate anyone who tries to take their country backwards. + +To all Americans, I will be honest with you, as I’ve always promised. A Russian dictator, invading a foreign country, has costs around the world. + +And I’m taking robust action to make sure the pain of our sanctions is targeted at Russia’s economy. And I will use every tool at our disposal to protect American businesses and consumers. + +Tonight, I can announce that the United States has worked with 30 other countries to release 60 Million barrels of oil from reserves around the world. + +America will lead that effort, releasing 30 Million barrels from our own Strategic Petroleum Reserve. And we stand ready to do more if necessary, unified with our allies. + +These steps will help blunt gas prices here at home. And I know the news about what’s happening can seem alarming. + +But I want you to know that we are going to be okay. + +When the history of this era is written Putin’s war on Ukraine will have left Russia weaker and the rest of the world stronger. + +While it shouldn’t have taken something so terrible for people around the world to see what’s at stake now everyone sees it clearly. + +We see the unity among leaders of nations and a more unified Europe a more unified West. And we see unity among the people who are gathering in cities in large crowds around the world even in Russia to demonstrate their support for Ukraine. + +In the battle between democracy and autocracy, democracies are rising to the moment, and the world is clearly choosing the side of peace and security. + +This is a real test. It’s going to take time. So let us continue to draw inspiration from the iron will of the Ukrainian people. + +To our fellow Ukrainian Americans who forge a deep bond that connects our two nations we stand with you. + +Putin may circle Kyiv with tanks, but he will never gain the hearts and souls of the Ukrainian people. + +He will never extinguish their love of freedom. He will never weaken the resolve of the free world. + +We meet tonight in an America that has lived through two of the hardest years this nation has ever faced. + +The pandemic has been punishing. + +And so many families are living paycheck to paycheck, struggling to keep up with the rising cost of food, gas, housing, and so much more. + +I understand. + +I remember when my Dad had to leave our home in Scranton, Pennsylvania to find work. I grew up in a family where if the price of food went up, you felt it. + +That’s why one of the first things I did as President was fight to pass the American Rescue Plan. + +Because people were hurting. We needed to act, and we did. + +Few pieces of legislation have done more in a critical moment in our history to lift us out of crisis. + +It fueled our efforts to vaccinate the nation and combat COVID-19. It delivered immediate economic relief for tens of millions of Americans. + +Helped put food on their table, keep a roof over their heads, and cut the cost of health insurance. + +And as my Dad used to say, it gave people a little breathing room. + +And unlike the $2 Trillion tax cut passed in the previous administration that benefitted the top 1% of Americans, the American Rescue Plan helped working people—and left no one behind. + +And it worked. It created jobs. Lots of jobs. + +In fact—our economy created over 6.5 Million new jobs just last year, more jobs created in one year +than ever before in the history of America. + +Our economy grew at a rate of 5.7% last year, the strongest growth in nearly 40 years, the first step in bringing fundamental change to an economy that hasn’t worked for the working people of this nation for too long. + +For the past 40 years we were told that if we gave tax breaks to those at the very top, the benefits would trickle down to everyone else. + +But that trickle-down theory led to weaker economic growth, lower wages, bigger deficits, and the widest gap between those at the top and everyone else in nearly a century. + +Vice President Harris and I ran for office with a new economic vision for America. + +Invest in America. Educate Americans. Grow the workforce. Build the economy from the bottom up +and the middle out, not from the top down. + +Because we know that when the middle class grows, the poor have a ladder up and the wealthy do very well. + +America used to have the best roads, bridges, and airports on Earth. + +Now our infrastructure is ranked 13th in the world. + +We won’t be able to compete for the jobs of the 21st Century if we don’t fix that. + +That’s why it was so important to pass the Bipartisan Infrastructure Law—the most sweeping investment to rebuild America in history. + +This was a bipartisan effort, and I want to thank the members of both parties who worked to make it happen. + +We’re done talking about infrastructure weeks. + +We’re going to have an infrastructure decade. + +It is going to transform America and put us on a path to win the economic competition of the 21st Century that we face with the rest of the world—particularly with China. + +As I’ve told Xi Jinping, it is never a good bet to bet against the American people. + +We’ll create good jobs for millions of Americans, modernizing roads, airports, ports, and waterways all across America. + +And we’ll do it all to withstand the devastating effects of the climate crisis and promote environmental justice. + +We’ll build a national network of 500,000 electric vehicle charging stations, begin to replace poisonous lead pipes—so every child—and every American—has clean water to drink at home and at school, provide affordable high-speed internet for every American—urban, suburban, rural, and tribal communities. + +4,000 projects have already been announced. + +And tonight, I’m announcing that this year we will start fixing over 65,000 miles of highway and 1,500 bridges in disrepair. + +When we use taxpayer dollars to rebuild America – we are going to Buy American: buy American products to support American jobs. + +The federal government spends about $600 Billion a year to keep the country safe and secure. + +There’s been a law on the books for almost a century +to make sure taxpayers’ dollars support American jobs and businesses. + +Every Administration says they’ll do it, but we are actually doing it. + +We will buy American to make sure everything from the deck of an aircraft carrier to the steel on highway guardrails are made in America. + +But to compete for the best jobs of the future, we also need to level the playing field with China and other competitors. + +That’s why it is so important to pass the Bipartisan Innovation Act sitting in Congress that will make record investments in emerging technologies and American manufacturing. + +Let me give you one example of why it’s so important to pass it. + +If you travel 20 miles east of Columbus, Ohio, you’ll find 1,000 empty acres of land. + +It won’t look like much, but if you stop and look closely, you’ll see a “Field of dreams,” the ground on which America’s future will be built. + +This is where Intel, the American company that helped build Silicon Valley, is going to build its $20 billion semiconductor “mega site”. + +Up to eight state-of-the-art factories in one place. 10,000 new good-paying jobs. + +Some of the most sophisticated manufacturing in the world to make computer chips the size of a fingertip that power the world and our everyday lives. + +Smartphones. The Internet. Technology we have yet to invent. + +But that’s just the beginning. + +Intel’s CEO, Pat Gelsinger, who is here tonight, told me they are ready to increase their investment from +$20 billion to $100 billion. + +That would be one of the biggest investments in manufacturing in American history. + +And all they’re waiting for is for you to pass this bill. + +So let’s not wait any longer. Send it to my desk. I’ll sign it. + +And we will really take off. + +And Intel is not alone. + +There’s something happening in America. + +Just look around and you’ll see an amazing story. + +The rebirth of the pride that comes from stamping products “Made In America.” The revitalization of American manufacturing. + +Companies are choosing to build new factories here, when just a few years ago, they would have built them overseas. + +That’s what is happening. Ford is investing $11 billion to build electric vehicles, creating 11,000 jobs across the country. + +GM is making the largest investment in its history—$7 billion to build electric vehicles, creating 4,000 jobs in Michigan. + +All told, we created 369,000 new manufacturing jobs in America just last year. + +Powered by people I’ve met like JoJo Burgess, from generations of union steelworkers from Pittsburgh, who’s here with us tonight. + +As Ohio Senator Sherrod Brown says, “It’s time to bury the label “Rust Belt.” + +It’s time. + +But with all the bright spots in our economy, record job growth and higher wages, too many families are struggling to keep up with the bills. + +Inflation is robbing them of the gains they might otherwise feel. + +I get it. That’s why my top priority is getting prices under control. + +Look, our economy roared back faster than most predicted, but the pandemic meant that businesses had a hard time hiring enough workers to keep up production in their factories. + +The pandemic also disrupted global supply chains. + +When factories close, it takes longer to make goods and get them from the warehouse to the store, and prices go up. + +Look at cars. + +Last year, there weren’t enough semiconductors to make all the cars that people wanted to buy. + +And guess what, prices of automobiles went up. + +So—we have a choice. + +One way to fight inflation is to drive down wages and make Americans poorer. + +I have a better plan to fight inflation. + +Lower your costs, not your wages. + +Make more cars and semiconductors in America. + +More infrastructure and innovation in America. + +More goods moving faster and cheaper in America. + +More jobs where you can earn a good living in America. + +And instead of relying on foreign supply chains, let’s make it in America. + +Economists call it “increasing the productive capacity of our economy.” + +I call it building a better America. + +My plan to fight inflation will lower your costs and lower the deficit. + +17 Nobel laureates in economics say my plan will ease long-term inflationary pressures. Top business leaders and most Americans support my plan. And here’s the plan: + +First – cut the cost of prescription drugs. Just look at insulin. One in ten Americans has diabetes. In Virginia, I met a 13-year-old boy named Joshua Davis. + +He and his Dad both have Type 1 diabetes, which means they need insulin every day. Insulin costs about $10 a vial to make. + +But drug companies charge families like Joshua and his Dad up to 30 times more. I spoke with Joshua’s mom. + +Imagine what it’s like to look at your child who needs insulin and have no idea how you’re going to pay for it. + +What it does to your dignity, your ability to look your child in the eye, to be the parent you expect to be. + +Joshua is here with us tonight. Yesterday was his birthday. Happy birthday, buddy. + +For Joshua, and for the 200,000 other young people with Type 1 diabetes, let’s cap the cost of insulin at $35 a month so everyone can afford it. + +Drug companies will still do very well. And while we’re at it let Medicare negotiate lower prices for prescription drugs, like the VA already does. + +Look, the American Rescue Plan is helping millions of families on Affordable Care Act plans save $2,400 a year on their health care premiums. Let’s close the coverage gap and make those savings permanent. + +Second – cut energy costs for families an average of $500 a year by combatting climate change. + +Let’s provide investments and tax credits to weatherize your homes and businesses to be energy efficient and you get a tax credit; double America’s clean energy production in solar, wind, and so much more; lower the price of electric vehicles, saving you another $80 a month because you’ll never have to pay at the gas pump again. + +Third – cut the cost of child care. Many families pay up to $14,000 a year for child care per child. + +Middle-class and working families shouldn’t have to pay more than 7% of their income for care of young children. + +My plan will cut the cost in half for most families and help parents, including millions of women, who left the workforce during the pandemic because they couldn’t afford child care, to be able to get back to work. + +My plan doesn’t stop there. It also includes home and long-term care. More affordable housing. And Pre-K for every 3- and 4-year-old. + +All of these will lower costs. + +And under my plan, nobody earning less than $400,000 a year will pay an additional penny in new taxes. Nobody. + +The one thing all Americans agree on is that the tax system is not fair. We have to fix it. + +I’m not looking to punish anyone. But let’s make sure corporations and the wealthiest Americans start paying their fair share. + +Just last year, 55 Fortune 500 corporations earned $40 billion in profits and paid zero dollars in federal income tax. + +That’s simply not fair. That’s why I’ve proposed a 15% minimum tax rate for corporations. + +We got more than 130 countries to agree on a global minimum tax rate so companies can’t get out of paying their taxes at home by shipping jobs and factories overseas. + +That’s why I’ve proposed closing loopholes so the very wealthy don’t pay a lower tax rate than a teacher or a firefighter. + +So that’s my plan. It will grow the economy and lower costs for families. + +So what are we waiting for? Let’s get this done. And while you’re at it, confirm my nominees to the Federal Reserve, which plays a critical role in fighting inflation. + +My plan will not only lower costs to give families a fair shot, it will lower the deficit. + +The previous Administration not only ballooned the deficit with tax cuts for the very wealthy and corporations, it undermined the watchdogs whose job was to keep pandemic relief funds from being wasted. + +But in my administration, the watchdogs have been welcomed back. + +We’re going after the criminals who stole billions in relief money meant for small businesses and millions of Americans. + +And tonight, I’m announcing that the Justice Department will name a chief prosecutor for pandemic fraud. + +By the end of this year, the deficit will be down to less than half what it was before I took office. + +The only president ever to cut the deficit by more than one trillion dollars in a single year. + +Lowering your costs also means demanding more competition. + +I’m a capitalist, but capitalism without competition isn’t capitalism. + +It’s exploitation—and it drives up prices. + +When corporations don’t have to compete, their profits go up, your prices go up, and small businesses and family farmers and ranchers go under. + +We see it happening with ocean carriers moving goods in and out of America. + +During the pandemic, these foreign-owned companies raised prices by as much as 1,000% and made record profits. + +Tonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. + +And as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. + +That ends on my watch. + +Medicare is going to set higher standards for nursing homes and make sure your loved ones get the care they deserve and expect. + +We’ll also cut costs and keep the economy going strong by giving workers a fair shot, provide more training and apprenticeships, hire them based on their skills not degrees. + +Let’s pass the Paycheck Fairness Act and paid leave. + +Raise the minimum wage to $15 an hour and extend the Child Tax Credit, so no one has to raise a family in poverty. + +Let’s increase Pell Grants and increase our historic support of HBCUs, and invest in what Jill—our First Lady who teaches full-time—calls America’s best-kept secret: community colleges. + +And let’s pass the PRO Act when a majority of workers want to form a union—they shouldn’t be stopped. + +When we invest in our workers, when we build the economy from the bottom up and the middle out together, we can do something we haven’t done in a long time: build a better America. + +For more than two years, COVID-19 has impacted every decision in our lives and the life of the nation. + +And I know you’re tired, frustrated, and exhausted. + +But I also know this. + +Because of the progress we’ve made, because of your resilience and the tools we have, tonight I can say +we are moving forward safely, back to more normal routines. + +We’ve reached a new moment in the fight against COVID-19, with severe cases down to a level not seen since last July. + +Just a few days ago, the Centers for Disease Control and Prevention—the CDC—issued new mask guidelines. + +Under these new guidelines, most Americans in most of the country can now be mask free. + +And based on the projections, more of the country will reach that point across the next couple of weeks. + +Thanks to the progress we have made this past year, COVID-19 need no longer control our lives. + +I know some are talking about “living with COVID-19”. Tonight – I say that we will never just accept living with COVID-19. + +We will continue to combat the virus as we do other diseases. And because this is a virus that mutates and spreads, we will stay on guard. + +Here are four common sense steps as we move forward safely. + +First, stay protected with vaccines and treatments. We know how incredibly effective vaccines are. If you’re vaccinated and boosted you have the highest degree of protection. + +We will never give up on vaccinating more Americans. Now, I know parents with kids under 5 are eager to see a vaccine authorized for their children. + +The scientists are working hard to get that done and we’ll be ready with plenty of vaccines when they do. + +We’re also ready with anti-viral treatments. If you get COVID-19, the Pfizer pill reduces your chances of ending up in the hospital by 90%. + +We’ve ordered more of these pills than anyone in the world. And Pfizer is working overtime to get us 1 Million pills this month and more than double that next month. + +And we’re launching the “Test to Treat” initiative so people can get tested at a pharmacy, and if they’re positive, receive antiviral pills on the spot at no cost. + +If you’re immunocompromised or have some other vulnerability, we have treatments and free high-quality masks. + +We’re leaving no one behind or ignoring anyone’s needs as we move forward. + +And on testing, we have made hundreds of millions of tests available for you to order for free. + +Even if you already ordered free tests tonight, I am announcing that you can order more from covidtests.gov starting next week. + +Second – we must prepare for new variants. Over the past year, we’ve gotten much better at detecting new variants. + +If necessary, we’ll be able to deploy new vaccines within 100 days instead of many more months or years. + +And, if Congress provides the funds we need, we’ll have new stockpiles of tests, masks, and pills ready if needed. + +I cannot promise a new variant won’t come. But I can promise you we’ll do everything within our power to be ready if it does. + +Third – we can end the shutdown of schools and businesses. We have the tools we need. + +It’s time for Americans to get back to work and fill our great downtowns again. People working from home can feel safe to begin to return to the office. + +We’re doing that here in the federal government. The vast majority of federal workers will once again work in person. + +Our schools are open. Let’s keep it that way. Our kids need to be in school. + +And with 75% of adult Americans fully vaccinated and hospitalizations down by 77%, most Americans can remove their masks, return to work, stay in the classroom, and move forward safely. + +We achieved this because we provided free vaccines, treatments, tests, and masks. + +Of course, continuing this costs money. + +I will soon send Congress a request. + +The vast majority of Americans have used these tools and may want to again, so I expect Congress to pass it quickly. + +Fourth, we will continue vaccinating the world. + +We’ve sent 475 Million vaccine doses to 112 countries, more than any other nation. + +And we won’t stop. + +We have lost so much to COVID-19. Time with one another. And worst of all, so much loss of life. + +Let’s use this moment to reset. Let’s stop looking at COVID-19 as a partisan dividing line and see it for what it is: A God-awful disease. + +Let’s stop seeing each other as enemies, and start seeing each other for who we really are: Fellow Americans. + +We can’t change how divided we’ve been. But we can change how we move forward—on COVID-19 and other issues we must face together. + +I recently visited the New York City Police Department days after the funerals of Officer Wilbert Mora and his partner, Officer Jason Rivera. + +They were responding to a 9-1-1 call when a man shot and killed them with a stolen gun. + +Officer Mora was 27 years old. + +Officer Rivera was 22. + +Both Dominican Americans who’d grown up on the same streets they later chose to patrol as police officers. + +I spoke with their families and told them that we are forever in debt for their sacrifice, and we will carry on their mission to restore the trust and safety every community deserves. + +I’ve worked on these issues a long time. + +I know what works: Investing in crime preventionand community police officers who’ll walk the beat, who’ll know the neighborhood, and who can restore trust and safety. + +So let’s not abandon our streets. Or choose between safety and equal justice. + +Let’s come together to protect our communities, restore trust, and hold law enforcement accountable. + +That’s why the Justice Department required body cameras, banned chokeholds, and restricted no-knock warrants for its officers. + +That’s why the American Rescue Plan provided $350 Billion that cities, states, and counties can use to hire more police and invest in proven strategies like community violence interruption—trusted messengers breaking the cycle of violence and trauma and giving young people hope. + +We should all agree: The answer is not to Defund the police. The answer is to FUND the police with the resources and training they need to protect our communities. + +I ask Democrats and Republicans alike: Pass my budget and keep our neighborhoods safe. + +And I will keep doing everything in my power to crack down on gun trafficking and ghost guns you can buy online and make at home—they have no serial numbers and can’t be traced. + +And I ask Congress to pass proven measures to reduce gun violence. Pass universal background checks. Why should anyone on a terrorist list be able to purchase a weapon? + +Ban assault weapons and high-capacity magazines. + +Repeal the liability shield that makes gun manufacturers the only industry in America that can’t be sued. + +These laws don’t infringe on the Second Amendment. They save lives. + +The most fundamental right in America is the right to vote – and to have it counted. And it’s under assault. + +In state after state, new laws have been passed, not only to suppress the vote, but to subvert entire elections. + +We cannot let this happen. + +Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. + +Tonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service. + +One of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court. + +And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence. + +A former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by Democrats and Republicans. + +And if we are to advance liberty and justice, we need to secure the Border and fix the immigration system. + +We can do both. At our border, we’ve installed new technology like cutting-edge scanners to better detect drug smuggling. + +We’ve set up joint patrols with Mexico and Guatemala to catch more human traffickers. + +We’re putting in place dedicated immigration judges so families fleeing persecution and violence can have their cases heard faster. + +We’re securing commitments and supporting partners in South and Central America to host more refugees and secure their own borders. + +We can do all this while keeping lit the torch of liberty that has led generations of immigrants to this land—my forefathers and so many of yours. + +Provide a pathway to citizenship for Dreamers, those on temporary status, farm workers, and essential workers. + +Revise our laws so businesses have the workers they need and families don’t wait decades to reunite. + +It’s not only the right thing to do—it’s the economically smart thing to do. + +That’s why immigration reform is supported by everyone from labor unions to religious leaders to the U.S. Chamber of Commerce. + +Let’s get it done once and for all. + +Advancing liberty and justice also requires protecting the rights of women. + +The constitutional right affirmed in Roe v. Wade—standing precedent for half a century—is under attack as never before. + +If we want to go forward—not backward—we must protect access to health care. Preserve a woman’s right to choose. And let’s continue to advance maternal health care in America. + +And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. + +As I said last year, especially to our younger transgender Americans, I will always have your back as your President, so you can be yourself and reach your God-given potential. + +While it often appears that we never agree, that isn’t true. I signed 80 bipartisan bills into law last year. From preventing government shutdowns to protecting Asian-Americans from still-too-common hate crimes to reforming military justice. + +And soon, we’ll strengthen the Violence Against Women Act that I first wrote three decades ago. It is important for us to show the nation that we can come together and do big things. + +So tonight I’m offering a Unity Agenda for the Nation. Four big things we can do together. + +First, beat the opioid epidemic. + +There is so much we can do. Increase funding for prevention, treatment, harm reduction, and recovery. + +Get rid of outdated rules that stop doctors from prescribing treatments. And stop the flow of illicit drugs by working with state and local law enforcement to go after traffickers. + +If you’re suffering from addiction, know you are not alone. I believe in recovery, and I celebrate the 23 million Americans in recovery. + +Second, let’s take on mental health. Especially among our children, whose lives and education have been turned upside down. + +The American Rescue Plan gave schools money to hire teachers and help students make up for lost learning. + +I urge every parent to make sure your school does just that. And we can all play a part—sign up to be a tutor or a mentor. + +Children were also struggling before the pandemic. Bullying, violence, trauma, and the harms of social media. + +As Frances Haugen, who is here with us tonight, has shown, we must hold social media platforms accountable for the national experiment they’re conducting on our children for profit. + +It’s time to strengthen privacy protections, ban targeted advertising to children, demand tech companies stop collecting personal data on our children. + +And let’s get all Americans the mental health services they need. More people they can turn to for help, and full parity between physical and mental health care. + +Third, support our veterans. + +Veterans are the best of us. + +I’ve always believed that we have a sacred obligation to equip all those we send to war and care for them and their families when they come home. + +My administration is providing assistance with job training and housing, and now helping lower-income veterans get VA care debt-free. + +Our troops in Iraq and Afghanistan faced many dangers. + +One was stationed at bases and breathing in toxic smoke from “burn pits” that incinerated wastes of war—medical and hazard material, jet fuel, and more. + +When they came home, many of the world’s fittest and best trained warriors were never the same. + +Headaches. Numbness. Dizziness. + +A cancer that would put them in a flag-draped coffin. + +I know. + +One of those soldiers was my son Major Beau Biden. + +We don’t know for sure if a burn pit was the cause of his brain cancer, or the diseases of so many of our troops. + +But I’m committed to finding out everything we can. + +Committed to military families like Danielle Robinson from Ohio. + +The widow of Sergeant First Class Heath Robinson. + +He was born a soldier. Army National Guard. Combat medic in Kosovo and Iraq. + +Stationed near Baghdad, just yards from burn pits the size of football fields. + +Heath’s widow Danielle is here with us tonight. They loved going to Ohio State football games. He loved building Legos with their daughter. + +But cancer from prolonged exposure to burn pits ravaged Heath’s lungs and body. + +Danielle says Heath was a fighter to the very end. + +He didn’t know how to stop fighting, and neither did she. + +Through her pain she found purpose to demand we do better. + +Tonight, Danielle—we are. + +The VA is pioneering new ways of linking toxic exposures to diseases, already helping more veterans get benefits. + +And tonight, I’m announcing we’re expanding eligibility to veterans suffering from nine respiratory cancers. + +I’m also calling on Congress: pass a law to make sure veterans devastated by toxic exposures in Iraq and Afghanistan finally get the benefits and comprehensive health care they deserve. + +And fourth, let’s end cancer as we know it. + +This is personal to me and Jill, to Kamala, and to so many of you. + +Cancer is the #2 cause of death in America–second only to heart disease. + +Last month, I announced our plan to supercharge +the Cancer Moonshot that President Obama asked me to lead six years ago. + +Our goal is to cut the cancer death rate by at least 50% over the next 25 years, turn more cancers from death sentences into treatable diseases. + +More support for patients and families. + +To get there, I call on Congress to fund ARPA-H, the Advanced Research Projects Agency for Health. + +It’s based on DARPA—the Defense Department project that led to the Internet, GPS, and so much more. + +ARPA-H will have a singular purpose—to drive breakthroughs in cancer, Alzheimer’s, diabetes, and more. + +A unity agenda for the nation. + +We can do this. + +My fellow Americans—tonight , we have gathered in a sacred space—the citadel of our democracy. + +In this Capitol, generation after generation, Americans have debated great questions amid great strife, and have done great things. + +We have fought for freedom, expanded liberty, defeated totalitarianism and terror. + +And built the strongest, freest, and most prosperous nation the world has ever known. + +Now is the hour. + +Our moment of responsibility. + +Our test of resolve and conscience, of history itself. + +It is in this moment that our character is formed. Our purpose is found. Our future is forged. + +Well I know this nation. + +We will meet the test. + +To protect freedom and liberty, to expand fairness and opportunity. + +We will save democracy. + +As hard as these times have been, I am more optimistic about America today than I have been my whole life. + +Because I see the future that is within our grasp. + +Because I know there is simply nothing beyond our capacity. + +We are the only nation on Earth that has always turned every crisis we have faced into an opportunity. + +The only nation that can be defined by a single word: possibilities. + +So on this night, in our 245th year as a nation, I have come to report on the State of the Union. + +And my report is this: the State of the Union is strong—because you, the American people, are strong. + +We are stronger today than we were a year ago. + +And we will be stronger a year from now than we are today. + +Now is our moment to meet and overcome the challenges of our time. + +And we will, as one people. + +One America. + +The United States of America. + +May God bless you all. May God protect our troops. diff --git a/examples/gemini/documents/state_of_the_union_2023.txt b/examples/gemini/documents/state_of_the_union_2023.txt new file mode 100644 index 00000000000..a2ad0b30506 --- /dev/null +++ b/examples/gemini/documents/state_of_the_union_2023.txt @@ -0,0 +1,667 @@ +Mr. Speaker, Madam Vice President, our First Lady and Second Gentleman — good to see you guys up there — members of Congress — + +And, by the way, Chief Justice, I may need a court order. She gets to go to the game tomorr- — next week. I have to stay home. We got to work something out here. + +Members of the Cabinet, leaders of our military, Chief Justice, Associate Justices, and retired Justices of the Supreme Court, and to you, my fellow Americans: + +You know, I start tonight by congratulating the 118th Congress and the new Speaker of the House, Kevin McCarthy. + +Speaker, I don’t want to ruin your reputation, but I look forward to working with you. + +And I want to congratulate the new Leader of the House Democrats, the first African American Minority Leader in history, Hakeem Jeffries. + +He won despite the fact I campaigned for him. + +Congratulations to the longest-serving Leader in the history of the United States Senate, Mitch McConnell. Where are you, Mitch? + +And congratulations to Chuck Schumer, another — you know, another term as Senate Minority [Majority] Leader. You know, I think you — only this time you have a slightly bigger majority, Mr. Leader. And you’re the Majority Leader. About that much bigger? Yeah. + +Well, I tell you what — I want to give specolec- — special recognition to someone who I think is going to be considered the greatest Speaker in the history of the House of Representatives: Nancy Pelosi. + +Folks, the story of America is a story of progress and resilience, of always moving forward, of never, ever giving up. It’s a story unique among all nations. + +We’re the only country that has emerged from every crisis we’ve ever entered stronger than we got into it. + +Look, folks, that’s what we’re doing again. + +Two years ago, the economy was reeling. I stand here tonight, after we’ve created, with the help of many people in this room, 12 million new jobs — more jobs created in two years than any President has created in four years — because of you all, because of the American people. + +Two years ago — and two years ago, COVID had shut down — our businesses were closed, our schools were robbed of so much. And today, COVID no longer controls our lives. + +And two years ago, our democracy faced its greatest threat since the Civil War. And today, though bruised, our democracy remains unbowed and unbroken. + +As we gather here tonight, we’re writing the next chapter in the great American story — a story of progress and resilience. + +When world leaders ask me to define America — and they do, believe it or not — I say I can define it in one word, and I mean this: possibilities. We don’t think anything is beyond our capacity. Everything is a possibility. + +You know, we’re often told that Democrats and Republicans can’t work together. But over the past two years, we proved the cynics and naysayers wrong. + +Yes, we disagreed plenty. And yes, there were times when Democrats went alone. + +But time and again, Democrats and Republicans came together. Came together to defend a stronger and safer Europe. You came together to pass one in a gen- — one-in-a-generation — once-in-a-generation infrastructure law building bridges connecting our nation and our people. We came together to pass one the most significant law ever helping victims exposed to toxic burn pits. And, in fact — it’s important. + +And, in fact, I signed over 300 bipartisan pieces of legislation since becoming President, from reauthorizing the Violence Against Women Act to the Electoral Count Reform Act, the Respect for Marriage Act that protects the right to marry the person you love. + +And to my Republican friends, if we could work together in the last Congress, there’s no reason we can’t work together and find consensus on important things in this Congress as well. + +I think — folks, you all are just as informed as I am, but I think the people sent us a clear message: Fighting for the sake of fighting, power for the sake of power, conflict for the sake of conflict gets us nowhere. + +That’s always been my vision of our country, and I know it’s many of yours: to restore the soul of this nation; to rebuild the backbone of America, America’s middle class; and to unite the country. + +That’s always been my vision for the country. To restore the soul of the nation. To rebuild the backbone of America - the middle class. To unite the country. + +We’ve been sent here to finish the job, in my view. + +For decades, the middle class has been hollowed out in more than — and not in one administration, but for a long time. Too many good-paying manufacturing jobs moved overseas. Factories closed down. Once-thriving cities and towns that many of you represent became shadows of what they used to be. And along the way, something else we lost: pride, our sense of self-worth. + +I ran for President to fundamentally change things. To make sure the economy works for everyone so we can all feel that pride in what we do. To build an economy from the bottom up and the middle out, not from the top down. Because when the middle class does well, the poor have a ladder up and the wealthy still do very well. We all do well. + +I know a lot of you always kid me for always quoting my dad. But my dad used to say, “Joey, a job is about a lot more than a paycheck.” He really would say this. “It’s about a lot more than a paycheck. It’s about your dignity. It’s about respect. It’s about being able to look your kid in the eye and say, ‘Honey, it’s going to be okay’ and mean it.” + +Well, folks, so let’s look at the results. We’re not finished yet, by any stretch of the imagination. But unemployment rate is at 3.4 percent –- a 50-year low. And near record — and near record unemployment — near record unemployment for Black and Hispanic workers. + +We’ve already created, with your help, 800,000 good-paying manufacturing jobs — the fastest growth in 40 years. + +And where is it written — where is it written that America can’t lead the world in manufacturing? And I don’t know where that’s written. + +For too many decades, we imported projects and exported jobs. Now, thanks to what you’ve all done, we’re exporting American products and creating American jobs. + +Folks, inflation — inflation has been a global problem because the pandemic dirup- — disrupted our supply chains, and Putin’s unfair and brutal war in Ukraine disrupted ener- — energy supplied as well as food supplies, blocking all that grain in Ukraine. + +But we’re better positioned than any country on Earth right now. But we have more to do. + +But here at home, inflation is coming down. Here at home, gas prices are down $1.50 from their peak. + +Food inflation is coming down — not fast enough, but coming down. + +Inflation has fallen every month for the last six months, while take-home pay has gone up. + +Additionally, over the last two years, a record 10 million Americans applied to start new businesses. Ten million. + +And, by the way, every time — every time someone starts a small business, it’s an act of hope. + +And, Madam Vice President, I want to thank you for leading that effort to ensure that small businesses have access to capital and the historic laws we enacted that are going to just come into being. + +Standing here last year, I shared with you a story of American genius and possibilities. + +Semiconductors — small computer chips the size of a fingerprint that power everything from cellphones to automobiles and so much more. These chips were invented in America. Let’s get that straight: They were invented in America. + +And we used to make 40 percent of the world’s chips. In the last several decades, we lost our edge. We’re down to only producing 10 percent. + +We all saw what happened during the pandemic when chip factories shut down overseas. + +Today’s automobiles need 3,000 chips — each of those automobiles — but American automobiles [automakers] couldn’t make enough cars because there weren’t enough chips. + +Car prices went up. People got laid off. So did everything from refrigerators to cellphones. + +We can never let that happen again. + +That’s why — that’s why we came together to pass the bipartisan CHIPS and Science Act. + +Folks, I know I’ve been criticized for saying this, but I’m not changing my view. We’re going to make sure the supply chain for America begins in America — the supply chain begins in America. + +And we’ve already created — we’ve already created 800,000 new manufacturing jobs without this law, before the law kicks in. + +With this new law, we’re going to create hundreds of thousands of new jobs across the country. And I mean all across the country, throughout — not just the coast, but through the middle of the country as well. + +That’s going to come from companies that have announced more than $300 billion in investments in American manufacturing over the next few years. + +Outside of Columbus, Ohio, Intel is building semiconductor factories on a thousand acres — literally a field of dreams. + +It’s going to create 10,000 jobs, that one investment; 7,000 construction jobs; 3,000 jobs in those factories once they’re finished. They call them factors. Jobs paying an average of $130,000 a year, and many do not require a college degree. + +Jobs — because we worked together, these jobs where people don’t have to leave home to search for opportunity. + +And it’s just getting started. + +Think about the new homes, the small businesses, the big — the medium-sized businesses. So much more that’s going to be needed to support those three thou- — those 3,000 permanent jobs and the factories that are going to be built. + +Talk to mayors and governors, Democrats and Republicans, and they’ll tell you what this means for their communities. + +We’re seeing these fields of dreams transform the Heartland. But to maintain the strongest economy in the world, we need the best infrastructure in the world. + +And, folks, as you all know, we used to be number one in the world in infrastructure. We’ve sunk to 13th in the world. The United States of America — 13th in the world in infrastructure, modern infrastructure. + +But now we’re coming back because we came together and passed the Bipartisan Infrastructure Law — the largest investment in infrastructure since President Eisenhower’s Interstate Highway System. + +Folks, already we’ve funded over 20,000 projects, including major airports from Boston to Atlanta to Portland — projects that are going to put thousands of people to work rebuilding our highways, our bridges, our railroads, our tunnels, ports, airports, clean water, high-speed Internet all across America — urban, rural, Tribal. + +And, folks, we’re just getting started. We’re just getting started. + +And I mean this sincerely: I want to thank my Republican friends who voted for the law. And my Republican friends who voted against it as well — but I’m still — I still get asked to fund the projects in those districts as well, but don’t worry. I promised I’d be a President for all Americans. We’ll fund these projects. And I’ll see you at the groundbreaking. + +Look, this law — this law will further unite all of America. + +Projects like the Brent Spence Bridge in Kentucky over the Ohio River. Built 60 years ago. Badly in need of repairs. One of the nation’s most congested freight routes, carrying $2 billion worth of freight every single day across the Ohio River. + +And, folks, we’ve been talking about fixing it for decades, but we’re really finally going to get it done. + +I went there last month with Democrats and Republicans in — from both states — to deliver a commitment of $1.6 billion for this project. + +And while I was there, I met a young woman named Saria, who’s here tonight. I don’t know where Saria is. Is she up in the box? I don’t know. Saria, how are you? + +Well, Saria — for 30 years — for 30 years — I learned — she told me she’d been a proud member of the Iron workers Local 44, known as — — known as the “Cowboys in the Sky” — — the folks who built — who built Cincinnati’s skyline. + +Saria said she can’t wait to be 10 stories above the Ohio River building that new bridge. God bless her. That’s pride. + +And that’s what we’re also building — we’re building back pride. + +Look, we’re also replacing poisonous lead pipes that go into 10 million homes in America, 400,000 schools and childcare centers so every child in America — every child in American can drink the water, instead of having permanent damage to their brain. + +Look, we’re making sure — — we’re making sure that every community — every community in America has access to affordable, high-speed Internet. + +No parent should have to drive by a McDonald’s parking lot to help their — do their homework online with their kids, which many — thousands were doing across the country. + +And when we do these projects — and, again, I get criticized about this, but I make no excuses for it — we’re going to buy American. We’re going to buy American. + +Folks — — and it’s totally — it’s totally consistent with international trade rules. Buy American has been the law since 1933. But for too long, past administrations — Democrat and Republican — have fought to get around it. Not anymore. + +Tonight, I’m also announcing new standards to require all construction materials used in federal infra- — infrastructure projects to be made in America. Made in America. I mean it. Lumber, glass, drywall, fiber-optic cable. + +And on my watch, American roads, bridges, and American highways are going to be made with American products as well. + +Folks, my economic plan is about investing in places and people that have been forgotten. So many of you listening tonight, I know you feel it. So many of you felt like you’ve just simply been forgotten. Amid the economic upheaval of the past four decades, too many people have been left behind and treated like they’re invisible. + +Maybe that’s you, watching from home. You remember the jobs that went away. You remember them, don’t you? + +The folks at home remember them. You wonder whether the path even exists anymore for your children to get ahead without having to move away. + +Well, that’s why — I get that. That’s why we’re building an economy where no one is left behind. + +Jobs are coming back, pride is coming back because of choices we made in the last several years. + +You know, this is, in my view, a blue-collar blueprint to rebuild America and make a real difference in your lives at home. + +For example, too many of you lay in bed at night, like my dad did, staring at the ceiling, wondering what in God’s name happens if yo- — if your spouse gets cancer or your child gets deadly ill or if something happens to you. What are you going — are you going to have the money to pay for those medical bills? Are you going to have to sell the house or try to get a second mortgage on it? + +I get it. I get it. + +With the Inflation Reduction Act that I signed into law, we’re taking on powerful interests to bring healthcare costs down so you can sleep better at night with more security. + +You know, we pay more for prescription drugs than any nation in the world. Let me say it again: We pay more for prescription drugs than any major nation on Earth. + +For example, 1 in 10 Americans has diabetes. Many of you in this chamber do and in the audience. But every day, millions need insulin to control their diabetes so they can literally stay alive. Insulin has been around for over 100 years. The guy who invented it didn’t even patent it because he wanted it to be available for everyone. + +It costs the drug companies roughly $10 a vial to make that insulin. Package it and all, you may get up to $13. But Big Pharma has been unfairly charging people hundreds of dollars — $4- to $500 a month — making rec- — record profits. Not anymore. Not anymore. + +So — so many things that we did are only now coming to fruition. We said we were doing this and we said we’d pass the law to do it, but people didn’t know because the law didn’t take effect until January 1 of this year. + +We capped the cost of insulin at $35 a month for seniors on Medicare. But people are just finding out. I’m sure you’re getting the same calls I’m getting. + +We capped insulin for seniors at $35 per month. It’s time to do it for everyone. + +Look, there are millions of other Americans who do not — are not on Medicare, including 200,000 young people with Type 1 diabetes who need these insulin — need this insulin to stay alive. + +Let’s finish the job this time. Let’s cap the cost of insulin for everybody at $35. + +Folks — and Big Pharma is still going to do very well, I promise you all. I promise you they’re going to do very well. + +This law also — this law also caps — and it won’t even go into effect until 2025. It costs [caps] out-of-pocket drug costs for seniors on Medicare at a maximum of $2,000 a year. You don’t have to pay more than $2,000 a year, no matter how much your drug costs are. Because you know why? You all know it. + +Many of you, like many of my family, have cancer. You know the drugs can range from $10-, $11-, $14-, $15,000 for the cancer drugs. + +And if drug prices rise faster than inflation, drug companies are going to have to pay Medicare back the difference. + +And we’re finally — we’re finally giving Medicare the power to negotiate drug prices. + +Bringing down — bringing down prescription drug costs doesn’t just save seniors money, it cuts the federal deficit by billions of dollars — — by hundreds of billions of dollars because these prescription drugs are drugs purchased by Medicare to make — keep their commitment to the seniors. + +Well, guess what? Instead of paying 4- or 500 bucks a month, you’re paying 15. That’s a lot of savings for the federal government. + +And, by the way, why wouldn’t we want that? + +Now, some members here are threatening — and I know it’s not an official party position, so I’m not going to exaggerate — but threatening to repeal the Inflation Reduction Act. + +As my coach — that’s okay. That’s fair. As my football coach used to say, “Lots of luck in your senior year.” + +Make no mistake, if you try anything to raise the cost of prescription drugs, I will veto it. + +And, look, I’m pleased to say that more Americans health — have health insurance now than ever in history. A record 16 million people are enrolled in the Affordable Care Act. + +And thanks — thanks to the law I signed last year, saving — millions are saving $800 a year on their premiums. + +And, by the way, that law was written — and the benefit expires in 2025. So, my plea to some of you, at least in this audience: Let’s finish the job and make those savings permanent. Expand coverage on Medicaid. + +Look, the Inflation Reduction Act is also the most significant investment ever in climate change — ever. Lowering utility bills, creating American jobs, leading the world to a clean energy future. + +I visited the devastating aftermath of record floods, droughts, storms, and wildfires from Arizona to New Mexico to all the way up to the Canadian border. + +More timber has been burned that I’ve observed from helicopters than the entire state of Missouri. And we don’t have global warming? Not a problem. + +In addition to emergency recovery from Puerto Rico to Florida to Idaho, we’re rebuilding for the long term. + +New electric grids that are able to weather major storms and not — prevent those fire — forest fires. Roads and water systems to withstand the next big flood. Clean energy to cut pollution and create jobs in communities often left behind. + +We’re going to build 500,000 electric vehicle charging stations, installed across the country by tens of thousands of IBEW workers. + +And we’re helping families save more than $1,000 a year with tax credits to purchase of electric vehicles and efficient — and efficient appliances — energy-efficient appliances. + +Historic conservation efforts to be responsible stewards of our land. + +Let’s face reality. The climate crisis doesn’t care if you’re in a red or a blue state. It’s an existential threat. + +We have an obligation not to ourselves, but to our children and grandchildren to confront it. + +I’m proud of how the — how America, at last, is stepping up to the challenge. We’re still going to need oil and gas for a while, but guess what — — no, we do — but there’s so much more to do. We got to finish the job. + +And we pay for these investments in our future by finally making the wealthiest and biggest corporations begin to pay their fair share. Just begin. + +Look, I’m a capitalist. I’m a capitalist. But pay your fair share. + +I think a lot of you at home — a lot of you at home agree with me and many people that you know: The tax system is not fair. It is not fair. + +Look, the idea that in 2020, 55 of the largest corporations in America, the Fortune 500, made $40 billion in profits and paid zero in federal taxes? Zero. + +Folks, it’s simply not fair. + +But now, because of the law I signed, billion-dollar companies have to pay a minimum of 15 percent. God love them. Fifteen percent. That’s less than a nurse pays. + +Let me be crystal clear. I said at the very beginning: Under my plans, as long as I’m President, nobody earning less than $400,000 will pay an additional penny in taxes. Nobody. Not one penny. + +But let’s finish the job. There’s more to do. + +We have to reward work, not just wealth. Pass my proposal for the billionaire minimum tax. You know, there’s a thousand billionaires in America — it’s up from about 600 at the beginning of my term — but no billionaire should be paying a lower tax rate than a school teacher or a firefighter. No, I mean it. Think about it. + +We made every wealthy corporation pay a minimum tax. It’s time to do the same for billionaires. + +I mean, look, I know you all aren’t enthusiastic about that, but think about it. Think about it. + +Have you noticed — Big Oil just reported its profits. Record profits. Last year, they made $200 billion in the midst of a global energy crisis. I think it’s outrageous. + +Why? They invested too little of that profit to increase domestic production. And when I talked to a couple of them, they say, “We were afraid you were going to shut down all the oil wells and all the oil refineries anyway, so why should we invest in them?” I said, “We’re going to need oil for at least another decade, and that’s going to exceed…” — and beyond that. We’re going to need it. Production. + +If they had, in fact, invested in the production to keep gas prices down — instead they used the record profits to buy back their own stock, rewarding their CEOs and shareholders. + +Corporations ought to do the right thing. + +That’s why I propose we quadruple the tax on corporate stock buybacks and encourage long- — — long-term investments. They’ll still make considerable profit. + +Let’s finish the job and close the loopholes that allow the very wealthy to avoid paying their taxes. + +Instead of cutting the number of audits for wealthy taxpayers, I just signed a law to reduce the deficit by $114 billion by cracking down on wealthy tax cheats. That’s being fiscally responsible. + +In the last two years, my administration has cut the deficit by more than $1.7 trillion –- the largest deficit reduction in American history. + +Under the previous administration, the American deficit went up four years in a row. + +Because of those record deficits, no President added more to the national debt in any four years than my predecessor. + +Nearly 25 percent of the entire national debt that took over 200 years to accumulate was added by just one administration alone — the last one. They’re the facts. Check it out. Check it out. + +How did Congress respond to that debt? They did the right thing. They lifted the debt ceiling three times without preconditions or crisis. They paid the American bill to prevent an economic disaster of the country. + +So, tonight I’m asking the Congress to follow suit. Let us commit here tonight that the full faith and credit of the United States of America will never, ever be questioned. + +So my — many of — some of my Republican friends want to take the economy hostage — I get it — unless I agree to their economic plans. All of you at home should know what those plans are. + +Instead of making the wealthy pay their fair share, some Republicans — some Republicans want Medicare and Social Security to sunset. I’m not saying it’s a majority — + +Let me give you — + +Anybody who doubts it, contact my office. I’ll give you a copy. I’ll give you a copy of the proposal. + +That means Congress doesn’t vote — + +Well, I’m glad to see — no, I tell you, I enjoy conversion. + +You know, it means if Congress doesn’t keep the programs the way they are, they’d go away. + +Other Republicans say — I’m not saying it’s a majority of you. I don’t even think it’s a significant — + +— but it’s being proposed by individuals. + +I’m not — politely not naming them, but it’s being proposed by some of you. + +Look, folks, the idea is that we’re not going to be — we’re not going to be moved into being threatened to default on the debt if we don’t respond. + +Folks — so, folks, as we all apparently agree, Social Security and Medicare is off the — off the books now, right? They’re not to be touched? + +All right. All right. We got unanimity! Social Security and Medicare are a lifeline for millions of seniors. Americans have to pay into them from the very first paycheck they’ve started. + +So, tonight, let’s all agree — and we apparently are — let’s stand up for seniors. Stand up and show them we will not cut Social Security. We will not cut Medicare. + +President Biden wants to strengthen social security and medicare. House Republicans are threatening to cut them. + +Those benefits belong to the American people. They earned it. And if anyone tries to cut Social Security — which apparently no one is going to do — and if anyone tries to cut Medicare, I’ll stop them. I’ll veto it. + +And, look, I’m not going to allow them to take away — be taken away. Not today. Not tomorrow. Not ever. + +But apparently, it’s not going to be a problem. + +Next month, when I offer my fiscal plan, I ask my Republican friends to lay down their plan as well. I really mean it. Let’s sit down together and discuss our mutual plans together. Let’s do that. + +I can tell you, the plan I’m going to show you is going to cut the deficit by another $2 trillion. And it won’t cut a single bit of Medicare or Social Security. + +In fact, we’re going to extend the Medicare Trust Fund at least two decades, because that’s going to be the next argument: how do we make — keep it solvent. Right? + +Well, I will not raise taxes on anyone making under 400 grand. But we’ll pay for it the way we talked about tonight: by making sure that the wealthy and big corporations pay their fair share. + +Look — look, look, here’s — here’s the deal. They aren’t just taking advantage of the tax code, they’re taking advantage of you, the American consumer. + +Here’s my message to all of you out there: I have your back. We’re already preventing Americans who are [from] receiving surprise medical bills, stopping 1 billion dollar [1 million] surprise bills per month so far. + +We’re protecting seniors’ life savings by cracking down on nursing homes that commit fraud, endanger patient safety, or prescribe drugs that are not needed. + +Millions of Americans can now save thousands of dollars because they can finally get a hearing aid over the counter without a prescription. + +Look, capitalism without competition is not capitalism. It’s extortion. It’s exploitation. + +Last year, I cracked down, with the help of many of you, on foreign shipping companies that were making you pay higher prices for every good coming into the country. + +I signed a bipartisan bill that cut shipping costs by 90 percent, helping American farmers, businessmen, and consumers. + +Let’s finish the job. Pass the bipartisan legislation to strengthen and — to strengthen antitrust enforcement and forbeg — and prevent big online platforms from giving their own products an unfair advantage. + +My administration is also taking on junk fees, those hidden surcharges too many companies use to make you pay more. + +For example, we’re making airlines show you the full ticket price upfront, refund your money if your flight is cancelled or delayed. We’ve reduced exorbitant bank overdrafts by saving consumers more than $1 billion a year. + +We’re cutting credit card late fees by 75 percent, from $30 to $8. + +Look, junk fees may not matter to the very wealthy, but they matter to most other folks in homes like the one I grew up in, like many of you did. They add up to hundreds of dollars a month. They make it harder for you to pay your bills or afford that family trip. + +I know how unfair it feels when a company overcharges you and gets away with it. Not anymore. + +We’ve written a bill to stop it all. It’s called the Junk Fee Prevention Act. We’re going to ban surprise resort fees that hotels charge on your bill. Those fees can cost you up to $90 a night at hotels that aren’t even resorts. + +It’s time to end excessive serve fees for concert tickets. Pass the Junk Fee Prevention Act. + +We — the idea that cable, Internet, and cellphone companies can charge you $200 or more if you decide to switch to another provider. Give me a break. + +We can stop service fees on tickets to concerts and sporting events and make companies disclose all the fees upfront. + +And we’ll prohibit airlines from charging $50 roundtrip for a family just to be able to sit together. Baggage fees are bad enough. Airlines can’t treat your child like a piece of baggage. + +Americans are tired of being — we’re tired of being played for suckers. + +So pass — pass the Junk Fee Prevention Act so companies stop ripping us off. + +For too long, workers have been getting stiffed, but not anymore. We’re going to be — we’re beginning to restore the dignity of work. + +For example, I — I should have known this, but I didn’t until two years ago: Thirty million workers have to sign non-compete agreements for the jobs they take. Thirty million. So a cashier at a burger place can’t walk across town and take the same job at another burger place and make a few bucks more. + +It just changed. Well, they just changed it because we exposed it. That was part of the deal, guys. Look it up. But not anymore. + +We’re banning those agreements so companies have to compete for workers and pay them what they’re worth. + +And I must tell you, this is bound to get a response from my friends on my left, with the right. + +I’m so sick and tired of companies breaking the law by preventing workers from organizing. Pass the PRO Act! Because businesses have a right — workers have a right to form a union. And let’s guarantee all workers have a living wage. + +Let’s make sure working parents can afford to raise a family with sick days, paid family and medical leave, affordable childcare. That’s going to enable millions of more people to go and stay at work. + +And let’s restore the full Child Tax Credit — — which gave tens of millions of parents some breathing room and cut child poverty in half to the lowest level in history. + +And, by the way, when we do all of these things, we increase productivity, we increase economic growth. + +So let’s finish the job and get more families access to affordable, quality housing. + +Let’s get seniors who want to stay in their homes the care they need to do so. Let’s give more breathing room to millions of family caregivers looking after their loved ones. + +Pass my plan so we get seniors and people with disabilities the home care services they need — — and support the workers who are doing God’s work. + +These plans are fully paid for, and we can afford to do them. + +Restoring the dignity of work means making education an affordable ticket to the middle class. + +You know, when we made public education — 12 years of it — universal in the last century, we made the best-educated, best-paid — we became the best-education, best-paid nation in the world. + +But the rest of the world has caught up. It has caught up. + +Jill, my wife, who teaches full-time, has an expression. I hope I get it right, kid. “Any nation that out-educates is going to out-compete us.” Any nation that out-educates is going to out-compete us. + +Folks, we all know 12 years of education is not enough to win the economic competition of the 21st century. If we want to have the best-educated workforce, let’s finish the job by providing access to preschool for three and four years old. Studies show that children who go to preschool are nearly 50 percent more likely to finish high school and go on to earn a two- or four-year degree, no matter their background they came from. + +Let’s give public school teachers a raise. + +We’re making progress by reducing student debt, increasing Pell Grants for working and middle-class families. + +Let’s finish the job and connect students to career opportunities starting in high school, provide access to two years of community college — the best career training in America, in addition to being a pathway to a four-year degree. + +Let’s offer every American a path to a good career, whether they go to college or not. + +And, folks — folks, in the midst of the COVID crisis, when schools were closed and we were shutting down everything, let’s recognize how far we came in the fight against the pandemic itself. + +While the virus is not gone, thanks to the resilience of the American people and the ingenuity of medicine, we’ve broken the COVID grip on us. + +COVID deaths are down by 90 percent. We’ve saved millions of lives and opened up our country — we opened our country back up. And soon, we’ll end the public health emergency. + +But — that’s called a public health emergency. + +But we’ll remember the toll and pain that’s never going to go away. More than a million Americans lost their lives to COVID. A million. Families grieving. Children orphaned. Empty chairs at the dining room table constantly reminding you that she used to sit there. Remembering them, we remain vigilant. + +We still need to monitor dozens of variants and support new vaccines and treatments. So Congress needs to fund these efforts and keep America safe. + +And as we emerge from this crisis stronger, we’re also — got to double down prosecuting criminals who stole relief money meant to keep workers and small businesses afloat. + +Before I came to office, you remember, during that campaign, the big issue was about inspector generals who would protect taxpayers’ dollars, who were sidelined. They were fired. Many people said, “We don’t need them.” And fraud became rampant. + +Last year, I told you the watchdogs are back. Since then — since then, we’ve recovered billions of taxpayers’ dollars. + +Now let’s triple the anti-fraud strike force going after these criminals, double the statute of limitations on these crimes, and crack down on identity fraud by criminal syndicates stealing billions of dollars — billions of dollars from the American people. + +And the data shows that for every dollar we put into fighting fraud, the taxpayer will get back at least 10 times as much. It matters. It matters. + +Look, COVID left its scars, like the spike in violent crime in 2020 — the first year of the pandemic. We have an obligation to make sure all people are safe. + +Public safety depends on public trust, as all of us know. But too often, that trust is violated. + +Joining us tonight are the parents of Tyre Nichols — welcome — who had to bury Tyre last week. + +As many of you personally know, there’s no words to describe the heartache or grief of losing a child. But imagine — imagine if you lost that child at the hands of the law. Imagine having to worry whether your son or daughter came home from walking down the street or playing in the park or just driving a car. + +Most of us in here have never had to have “the talk” — “the talk” — that brown and Black parents have had to have with their children. + +Beau, Hunter, Ashley — my children — I never had to have the talk with them. I never had to tell them, “If a police officer pulls you over, turn your interior lights on right away. Don’t reach for your license. Keep your hands on the steering wheel.” + +Imagine having to worry like that every single time your kid got in a car. + +Here’s what Tyre’s mother shared with me when I spoke to her, when I asked her how she finds the courage to carry on and speak out. With the faith of God, she said her son was, quote, “a beautiful soul” and “something good will come of this.” + +Imagine how much courage and character that takes. + +It’s up to us, to all of us. We all want the same thing: neighborhoods free of violence, law enfircement [sic] — law enforcement who earns the community’s trust. Just as every cop, when they pin on that badge in the morning, has a right to be able to go home at night, so does everybody else out there. Our children have a right to come home safely. + +Equal protection under the law is a covenant we have with each other in America. + +We know police officers put their lives on the line every single night and day. And we know we ask them, in many cases, to do too much — to be counselors, social workers, psychologists — responding to drug overdoses, mental health crises, and so much more. In one sense, we ask much too much of them. + +I know most cops and their families are good, decent, honorable people — the vast majority. And they risk — and they risk their lives every time they put that shield on. + +But what happened to Tyre in Memphis happens too often. We have to do better. Give law enforcement the real training they need. Hold them to higher standards. Help them to succeed in keeping them safe. + +We also need more first responders and professionals to address the growing mental health, substance abuse challenges. More resources to reduce violent crime and gun crime. More community intervention programs. More investments in housing, education, and job training. All this can help prevent violence in the first place. + +And when police officers or police departments violate the public trust, they must be held accountable. + +With the support — with the support of families of victims, civil rights groups, and law enforcement, I signed an executive order for all federal officers, banning chokeholds, restricting no-knock warrants, and other key elements of the George Floyd Act. + +Let’s commit ourselves to make the words of Tyler’s [Tyre’s] mom true: Something good must come from this. Something good. + +And all of us — all of us — folks, it’s difficult, but it’s simple: All of us in the cha- — in this chamber, we need to rise to this moment. We can’t turn away. Let’s do what we know in our hearts that we need to do. Let’s come together to finish the job on police reform. Do something. Do something. + +Ban assault weapons. + +That was the plea of parents who lost their children in Uvalde — I met with every one of them — “Do something about gun violence.” Thank God — thank God we did, passing the most sweeping gun safety law in three decades. + +That includes things like — that the majority of responsible gun owners already support: enhanced background checks for 18- to 21 years old, red-flag laws keeping guns out of the hands of people who are a danger to themselves and others. + +But we know our work is not done. Joining us tonight is Brandon Tsay, a 26-year-old hero. + +Brandon put his college dreams on hold — to be at his mom’s side — his mom’s side when she was dying from cancer. And Brandon — Brandon now works at the dance studio started by his grandparents. + +And two weeks ago, during the Lunar New Year celebrations, he heard the studio door close, and he saw a man standing there pointing a semi-automatic pistol at him. He thought he was going to die, but he thought about the people inside. + +In that instant, he found the courage to act and wrestled the semi-automatic pistol away from the gunman who had already killed 11 people in another dance studio. Eleven. + +He saved lives. It’s time we do the same. + +Ban assault weapons now! Ban them now! Once and for all. + +I led the fight to do that in 1994. And in 10 years that ban was law, mass shootings went down. After we let it expire in a Republican administration, mass shootings tripled. + +Let’s finish the job and ban these assault weapons. + +And let’s also come together on immigration. Make it a bipartisan issue once again. + +We know — we now have a record number of personnel working to secure the border, arresting 8,000 human smugglers, seizing over 23,000 pounds of fentanyl in just the last several months. + +We’ve launched a new border plan last month. Unlawful migration from Cuba, Haiti, Nicaragua, and Venezuela has come down 97 percent as a consequence of that. + +But American border problems won’t be fixed until Congress acts. If we don’t pass my comprehensive immigration reform, at least pass my plan to provide the equipment and officers to secure the border — and a pathway to citizenship for DREAMers, those on temporary status, farmworkers, essential workers. + +Here in the People’s House, it’s our duty to protect all the people’s rights and freedoms. Congress must restore the right and — + +Congress must restore the right that was taken away in Roe v. Wade — and protect Roe v. Wade. Give every woman the constitutional right. + +The Vice President and I are doing everything to protect access to reproductive healthcare and safeguard patient safety. But already, more than a dozen states are enforcing extreme abortion bans. + +Make no mistake about it: If Congress passes a national ban, I will veto it. + +It’s time to pass the Equality Act. + +But let’s also pass — let’s also pass the bipartisan Equality Act to ensure LBG- — LGBTQ Americans, especially transgender young people, can live with safety and dignity. + +Our strength — our strength is not just the example of our power, but the power of our example. Let’s remember, the world is watching. + +I spoke from this chamber one year ago, just days after Vladimir Putin unleashed his brutal attack against Ukraine, a murderous assault, evoking images of death and destruction Europe suffered in World War Two. + +Putin’s invasion has been a test for the ages — a test for America, a test for the world. Would we stand for the most basic of principles? Would we stand for sovereignty? Would we stand for the right of people to live free of tyranny? Would we stand for the defense of democracy? For such defense matters to us because it keeps peace and prevents open season on would-be aggressors that threatens our prosperity. + +One year later, we know the answer. Yes, we would. And we did. We did. + +And together, we did what America always does at our best. We led. We united NATO. We built a global coalition. We stood against Putin’s aggression. We stood with the Ukrainian people. + +Tonight, we’re once again joined by Ukrainians’ Ambassador to the United States. She represents not her — just her nation but the courage of her people. Ambassador is — our Ambassador is here, united in our — we’re united in our support of your country. + +Will you stand so we can all take a look at you? Thank you. Because we’re going to stand with you as long as it takes. + +Our nation is working for more freedom, more dignity, and more — more peace, not just in Europe, but everywhere. + +Before I came to office, the story was about how the People’s Republic of China was increasing its power and America was failing in the world. Not anymore. + +We made clear and I made clear in my personal conversations, which have been many, with President Xi that we seek competition, not conflict. But I will make no apologies that we’re investing and — to make America stronger. + +Investing in American innovation and industries that will define the future that China intends to be dominating. + +Investing in our alliances and working with our allies to protect advanced technologies so they will not be used against us. + +Modernizing our military to safeguard stability and determine — deter aggression. + +Today, we’re in the strongest position in decades to compete with China or anyone else in the world. Anyone else in the world. + +And I’m committed — I’m committed to work with China where we can advance American interests and benefit the world. But make no mistake about it: As we made clear last week, if China threatens our sovereignty, we will act to protect our country. And we did. + +Look, let’s be clear: Winning the competition should unite all of us. + +We face serious challenges across the world. But in the past two years, democracies have become stronger, not weaker. Autocracies have grown weaker, not stronger. + +Name me a world leader who’d change places with Xi Jinping. Name me one. Name me one. + +America is rallying the world to meet those challenges — from climate to global health to food insecurity to terrorism to territorial aggression. + +Allies are stepping up, spending more, and doing more. Look, the bridges we’re forming between partners in the Pacific and those in the Atlantic. And those who bet against America are learning how wrong they are. It’s never, ever been a good bet to bet against America. Never. + +Well — + +When I came to office, most assured that bipartisanship — assumed — was impossible. But I never believed it. That’s why a year ago, I offered a Unity Agenda to the nation as I stood here. + +We made real progress together. + +We passed the law making it easier for doctors to prescribe effective treatments for opioid addiction. + +We passed the gun safety law, making historic investments in mental health. + +We launched the ARPA-H drive for breakthroughs in the fight against cancer, Alzheimer’s, and diabetes, and so much more. + +We passed the Heath Robinson PACT Act, named after the late Iraq War veteran whose story about exposure to toxic burn pits I shared here last year. + +And I understand something about those burn pits. + +But there is so much more to do. And we can do it together. + +Joining us tonight is a father named Doug from Newton, New Hampshire. He wrote Jill, my wife, a letter — and me as well — about his courageous daughter, Courtney. A contagious laugh. His sister’s best friend — her sister’s best friend. + +He shared a story all too familiar to millions of Americans and many of you in the audience. Courtney discovered pills in high school. It spiraled into addiction and eventually death from a fentanyl overdose. She was just 20 years old. + +Describing the last eight years without her, Doug said, “There is no worse pain.” Yet, their family has turned pain into purpose, working to end the stigma and change laws. He told us he wants to “start a journey towards American recovery.” + +Doug, we’re with you. Fentanyl is killing more than 70,000 Americans a year. Big — + +Big — you got it. + +So let’s launch a major surge to stop fentanyl production and the sale and trafficking. With more drug detection machines, inspection cargo, stop pills and powder at the border. Working with couriers, like FedEx, to inspect more packages for drugs. Strong penalties to crack down on fentanyl trafficking. + +Second, let’s do more on mental health, especially for our children. When millions of young people are struggling with bullying, violence, trauma, we owe them greater access to mental health care at their schools. + +We must finally hold social media companies accountable for experimenting they’re doing — running [on] children for profit. + +And it’s time to pass bipartisan legislation to stop Big Tech from collecting personal data on kids and teenagers online, ban targeted advertising to children, and impose stricter limits on the personal data that companies collect on all of us. + +Third, let’s do more to keep this nation’s one fully sacred obligation: to equip those we send into harm’s way and care for them and their families when they come home. + +Job training, job placement for veterans and their spouses as they come to — return to civilian life. Helping veterans to afford their rent, because no one should be homeless in America, especially someone who served the country. + +Denis McDoungin [sic] — Denis McDonough is here, of the VA. We had our first real discussion when I asked him to take the job. I’m glad he did. We were losing up to 25 veterans a day on suicide. Now we’re losing 17 a day to the silent scourge of suicide. Seventeen veterans a day are committing suicide, more than all the people being killed in the wars. + +Folks, VA — VA is doing everything it can, including expanding mental health screening, proven programs that recruits veterans to help other veterans understand what they’re going through, get them the help they need. We got to do more. + +And fourth, last year, Jill and I reignited the Cancer Moonshot that I was able to start with, and President Obama asked me to lead our administration on this issue. + +Our goal is to cut the cancer death rates at least by 50 percent in the next 25 years, turn more cancers from death sentences to treatable diseases, provide more support for patients and their families. + +It’s personal to so many of us — so many of us in this audience. + +Joining us are Maurice and Kandice, an Irishman and a daughter of immigrants from Panama. They met and fell in love in New York City and got married in the same chapel as Jill and I got married in New York City. Kindred spirits. + +He wrote us a letter about his little daughter, Ava. And I saw her just before I came over. She was just a year old when she was diagnosed with a rare kidney disease — cancer. After 26 blood transfusions, 11 rounds of radiation, 8 rounds of cheno [sic] — chemo, 1 kidney removed, given a 5 percent survival rate. + +He wrote how, in the darkest moments, he thought, “If she goes, I can’t stay.” + +Many of you have been through that as well. Jill and I understand that, like so many of you. + +And he read Jill’s book describing our family’s cancer journey and how we tried to steal moments of joy where we could with Beau. + +For them, that glimmer of joy was the half-smile of their baby girl. It meant everything to them. They never gave up hope, and little Ava never gave up hope. She turns four next month. + +They just found out Ava is beating the odds and is on her way to being cured of cancer. And she’s watching from the White House tonight, if she’s not asleep already. + +For the lives we can save — for the lives we can save and the lives we have lost, let this be a truly American moment that rallies the country and the world together and prove that we can still do big things. + +Twenty years ago, under the leadership of President Bush and countless advocates and champions, he undertook a bipartisan effort through PEPFAR to transform the global fight against HIV/AIDS. It’s been a huge success. He thought big. He thought large. He moved! + +I believe we can do the same thing with cancer. Let’s end cancer as we know it and cure some cancers once and for all. + +Folks, there’s one reason why we’ve been able to do all of these things: our democracy itself. It’s the most fundamental thing of all. With democracy, everything is possible. Without it, nothing is. + +Over the last few years, our democracy has been threatened and attacked, put at risk — put to the test in this very room on January the 6th. + +And then, just a few months ago, an unhinged Big Lie assailant unleashed a political violence at the home of the then-Speaker of the House of Representatives, using the very same language the insurrectionists used as they stalked these halls and chanted on January 6th. + +Here tonight, in this chamber, is the man who bears the scars of that brutal attack but is as tough and as strong and as resilient as they get: my friend, Paul Pelosi. Paul, stand up. + +But such a heinous act should have never happened. We must all speak out. There is no place for political violence in America. + +We have to protect the right to vote, not suppress the — that fundamental right. Honor the results of our elections, not subvert the will of the people. We have to uphold the rule of the law and restore trust in our institutions of democracy. And we must give hate and extremism in any form no safe harbor. + +Democracy must not be a partisan issue. It’s an American issue. + +Every generation of Americans have faced a moment where they have been called to protect our democracy, defend it, stand up for it. And this is our moment. + +My fellow Americans, we meet tonight at an inflection point, one of those moments that only a few generations ever face, where the direction we now take is going to decide the course of this nation for decades to come. + +We’re not bystanders of history. We’re not powerless before the forces that confront us. It’s within our power of We the People. + +We’re facing the test of our time. We have to be the nation we’ve always been at our best: optimistic, hopeful, forward-looking. A nation that embraces light over dark, hope over fear, unity over division, stability over chaos. + +We have to see each other not as enemies, but as fellow Americans. We’re a good people. The only nation in the world built on an idea — the only one. Other nations are defined by geography, ethnicity, but we’re the only nation based on an idea that all of us, every one of us, is created equal in the image of God. A nation that stands as a beacon to the world. A nation in a new age of possibilities. + +So I have come to fulfil my constitutional obligation to report on the state of the Union. And here is my — my report: Because the soul of this nation is strong, because the backboken [sic] — backbone of this nation is strong, because the people of this nation are strong, the state of the Union is strong. + +Because the soul of this nation is strong. Because the backbone of this nation is strong. Because the people of this nation are strong. The State of the Union is Strong. + +I’m not new to this place. I stand here tonight having served as long as about any one of you who have ever served here. But I’ve never been more optimistic about our future — about the future of America. + +We just have to remember who we are. We’re the United States of America. And there’s nothing — nothing beyond our capacity if we do it together. + +God bless you all. And may God protect our troops. Thank you. diff --git a/examples/gemini/load_data.py b/examples/gemini/load_data.py new file mode 100644 index 00000000000..8e14b4b3b36 --- /dev/null +++ b/examples/gemini/load_data.py @@ -0,0 +1,106 @@ +import os +import argparse + +from tqdm import tqdm + +import chromadb +from chromadb.utils import embedding_functions +import google.generativeai as genai + + +def main( + documents_directory: str = "documents", + collection_name: str = "documents_collection", + persist_directory: str = ".", +) -> None: + # Read all files in the data directory + documents = [] + metadatas = [] + files = os.listdir(documents_directory) + for filename in files: + with open(f"{documents_directory}/{filename}", "r") as file: + for line_number, line in enumerate( + tqdm((file.readlines()), desc=f"Reading {filename}"), 1 + ): + # Strip whitespace and append the line to the documents list + line = line.strip() + # Skip empty lines + if len(line) == 0: + continue + documents.append(line) + metadatas.append({"filename": filename, "line_number": line_number}) + + # Instantiate a persistent chroma client in the persist_directory. + # Learn more at docs.trychroma.com + client = chromadb.PersistentClient(path=persist_directory) + + google_api_key = None + if "GOOGLE_API_KEY" not in os.environ: + gapikey = input("Please enter your Google API Key: ") + genai.configure(api_key=gapikey) + google_api_key = gapikey + else: + google_api_key = os.environ["GOOGLE_API_KEY"] + + # create embedding function + embedding_function = embedding_functions.GoogleGenerativeAIEmbeddingFunction(api_key=google_api_key) + + # If the collection already exists, we just return it. This allows us to add more + # data to an existing collection. + collection = client.get_or_create_collection( + name=collection_name, embedding_function=embedding_function + ) + + # Create ids from the current count + count = collection.count() + print(f"Collection already contains {count} documents") + ids = [str(i) for i in range(count, count + len(documents))] + + # Load the documents in batches of 100 + for i in tqdm( + range(0, len(documents), 100), desc="Adding documents", unit_scale=100 + ): + collection.add( + ids=ids[i : i + 100], + documents=documents[i : i + 100], + metadatas=metadatas[i : i + 100], # type: ignore + ) + + new_count = collection.count() + print(f"Added {new_count - count} documents") + + +if __name__ == "__main__": + # Read the data directory, collection name, and persist directory + parser = argparse.ArgumentParser( + description="Load documents from a directory into a Chroma collection" + ) + + # Add arguments + parser.add_argument( + "--data_directory", + type=str, + default="documents", + help="The directory where your text files are stored", + ) + parser.add_argument( + "--collection_name", + type=str, + default="documents_collection", + help="The name of the Chroma collection", + ) + parser.add_argument( + "--persist_directory", + type=str, + default="chroma_storage", + help="The directory where you want to store the Chroma collection", + ) + + # Parse arguments + args = parser.parse_args() + + main( + documents_directory=args.data_directory, + collection_name=args.collection_name, + persist_directory=args.persist_directory, + ) diff --git a/examples/gemini/main.py b/examples/gemini/main.py new file mode 100644 index 00000000000..7de0d08a7e1 --- /dev/null +++ b/examples/gemini/main.py @@ -0,0 +1,143 @@ +import argparse +import os +from typing import List, Dict + +import google.generativeai as genai +import chromadb +from chromadb.utils import embedding_functions + +model = genai.GenerativeModel("gemini-pro") + + +def build_prompt(query: str, context: List[str]) -> str: + """ + Builds a prompt for the LLM. # + + This function builds a prompt for the LLM. It takes the original query, + and the returned context, and asks the model to answer the question based only + on what's in the context, not what's in its weights. + + Args: + query (str): The original query. + context (List[str]): The context of the query, returned by embedding search. + + Returns: + A prompt for the LLM (str). + """ + + base_prompt = { + "content": "I am going to ask you a question, which I would like you to answer" + " based only on the provided context, and not any other information." + " If there is not enough information in the context to answer the question," + ' say "I am not sure", then try to make a guess.' + " Break your answer up into nicely readable paragraphs.", + } + user_prompt = { + "content": f" The question is '{query}'. Here is all the context you have:" + f'{(" ").join(context)}', + } + + # combine the prompts to output a single prompt string + system = f"{base_prompt['content']} {user_prompt['content']}" + + return system + + +def get_gemini_response(query: str, context: List[str]) -> str: + """ + Queries the Gemini API to get a response to the question. + + Args: + query (str): The original query. + context (List[str]): The context of the query, returned by embedding search. + + Returns: + A response to the question. + """ + + response = model.generate_content(build_prompt(query, context)) + + return response.text + + +def main( + collection_name: str = "documents_collection", persist_directory: str = "." +) -> None: + # Check if the GOOGLE_API_KEY environment variable is set. Prompt the user to set it if not. + google_api_key = None + if "GOOGLE_API_KEY" not in os.environ: + gapikey = input("Please enter your Google API Key: ") + genai.configure(api_key=gapikey) + google_api_key = gapikey + else: + google_api_key = os.environ["GOOGLE_API_KEY"] + + # Instantiate a persistent chroma client in the persist_directory. + # This will automatically load any previously saved collections. + # Learn more at docs.trychroma.com + client = chromadb.PersistentClient(path=persist_directory) + + # create embedding function + embedding_function = embedding_functions.GoogleGenerativeAIEmbeddingFunction(api_key=google_api_key, task_type="RETRIEVAL_QUERY") + + # Get the collection. + collection = client.get_collection( + name=collection_name, embedding_function=embedding_function + ) + + # We use a simple input loop. + while True: + # Get the user's query + query = input("Query: ") + if len(query) == 0: + print("Please enter a question. Ctrl+C to Quit.\n") + continue + print("\nThinking...\n") + + # Query the collection to get the 5 most relevant results + results = collection.query( + query_texts=[query], n_results=5, include=["documents", "metadatas"] + ) + + sources = "\n".join( + [ + f"{result['filename']}: line {result['line_number']}" + for result in results["metadatas"][0] # type: ignore + ] + ) + + # Get the response from Gemini + response = get_gemini_response(query, results["documents"][0]) # type: ignore + + # Output, with sources + print(response) + print("\n") + print(f"Source documents:\n{sources}") + print("\n") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Load documents from a directory into a Chroma collection" + ) + + parser.add_argument( + "--persist_directory", + type=str, + default="chroma_storage", + help="The directory where you want to store the Chroma collection", + ) + parser.add_argument( + "--collection_name", + type=str, + default="documents_collection", + help="The name of the Chroma collection", + ) + + # Parse arguments + args = parser.parse_args() + + main( + collection_name=args.collection_name, + persist_directory=args.persist_directory, + ) diff --git a/examples/gemini/requirements.txt b/examples/gemini/requirements.txt new file mode 100644 index 00000000000..f7c6d44b357 --- /dev/null +++ b/examples/gemini/requirements.txt @@ -0,0 +1,3 @@ +chromadb>=0.4.18 +google.generativeai +tqdm