RJuro commited on
Commit
3026887
1 Parent(s): 5972ea6
Files changed (33) hide show
  1. .gitattributes +1 -1
  2. Dockerfile +21 -0
  3. _README.md +79 -0
  4. app/.env +1 -0
  5. app/__init__.py +0 -0
  6. app/__pycache__/__init__.cpython-311.pyc +0 -0
  7. app/__pycache__/server.cpython-311.pyc +0 -0
  8. app/server.py +39 -0
  9. app/streamlit_test.py +36 -0
  10. app/test_server.ipynb +95 -0
  11. packages/.DS_Store +0 -0
  12. packages/README.md +0 -0
  13. packages/rag-chroma/.DS_Store +0 -0
  14. packages/rag-chroma/LICENSE +21 -0
  15. packages/rag-chroma/README.md +68 -0
  16. packages/rag-chroma/poetry.lock +0 -0
  17. packages/rag-chroma/pyproject.toml +35 -0
  18. packages/rag-chroma/rag_chroma.ipynb +51 -0
  19. packages/rag-chroma/rag_chroma/.DS_Store +0 -0
  20. packages/rag-chroma/rag_chroma/.env +1 -0
  21. packages/rag-chroma/rag_chroma/__init__.py +3 -0
  22. packages/rag-chroma/rag_chroma/__pycache__/__init__.cpython-311.pyc +0 -0
  23. packages/rag-chroma/rag_chroma/__pycache__/chain.cpython-311.pyc +0 -0
  24. packages/rag-chroma/rag_chroma/chain.py +92 -0
  25. packages/rag-chroma/rag_chroma/load_files_chroma.ipynb +164 -0
  26. packages/rag-chroma/rag_chroma/test.ipynb +122 -0
  27. packages/rag-chroma/rag_chroma/vecdb/12bce733-e94f-4342-829a-6786a9f92a50/data_level0.bin +3 -0
  28. packages/rag-chroma/rag_chroma/vecdb/12bce733-e94f-4342-829a-6786a9f92a50/header.bin +3 -0
  29. packages/rag-chroma/rag_chroma/vecdb/12bce733-e94f-4342-829a-6786a9f92a50/length.bin +3 -0
  30. packages/rag-chroma/rag_chroma/vecdb/12bce733-e94f-4342-829a-6786a9f92a50/link_lists.bin +0 -0
  31. packages/rag-chroma/rag_chroma/vecdb/chroma.sqlite3 +3 -0
  32. packages/rag-chroma/tests/__init__.py +0 -0
  33. pyproject.toml +25 -0
.gitattributes CHANGED
@@ -33,4 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
- *.sqlite3 filter=lfs diff=lfs merge=lfs -text
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.sqlite3 filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ RUN pip install poetry==1.6.1
4
+
5
+ RUN poetry config virtualenvs.create false
6
+
7
+ WORKDIR /code
8
+
9
+ COPY ./pyproject.toml ./README.md ./poetry.lock* ./
10
+
11
+ COPY ./packages ./packages
12
+
13
+ RUN poetry install --no-interaction --no-ansi --no-root
14
+
15
+ COPY ./app ./app
16
+
17
+ RUN poetry install --no-interaction --no-ansi
18
+
19
+ EXPOSE 8080
20
+
21
+ CMD ["uvicorn", "app.server:app", "--host", "0.0.0.0", "--port", "7860"]
_README.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # my-app
2
+
3
+ ## Installation
4
+
5
+ Install the LangChain CLI if you haven't yet
6
+
7
+ ```bash
8
+ pip install -U langchain-cli
9
+ ```
10
+
11
+ ## Adding packages
12
+
13
+ ```bash
14
+ # adding packages from
15
+ # https://github.com/langchain-ai/langchain/tree/master/templates
16
+ langchain app add $PROJECT_NAME
17
+
18
+ # adding custom GitHub repo packages
19
+ langchain app add --repo $OWNER/$REPO
20
+ # or with whole git string (supports other git providers):
21
+ # langchain app add git+https://github.com/hwchase17/chain-of-verification
22
+
23
+ # with a custom api mount point (defaults to `/{package_name}`)
24
+ langchain app add $PROJECT_NAME --api_path=/my/custom/path/rag
25
+ ```
26
+
27
+ Note: you remove packages by their api path
28
+
29
+ ```bash
30
+ langchain app remove my/custom/path/rag
31
+ ```
32
+
33
+ ## Setup LangSmith (Optional)
34
+ LangSmith will help us trace, monitor and debug LangChain applications.
35
+ LangSmith is currently in private beta, you can sign up [here](https://smith.langchain.com/).
36
+ If you don't have access, you can skip this section
37
+
38
+
39
+ ```shell
40
+ export LANGCHAIN_TRACING_V2=true
41
+ export LANGCHAIN_API_KEY=<your-api-key>
42
+ export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
43
+ ```
44
+
45
+ ## Launch LangServe
46
+
47
+ ```bash
48
+ langchain serve
49
+ ```
50
+
51
+ ## Running in Docker
52
+
53
+ This project folder includes a Dockerfile that allows you to easily build and host your LangServe app.
54
+
55
+ ### Building the Image
56
+
57
+ To build the image, you simply:
58
+
59
+ ```shell
60
+ docker build . -t my-langserve-app
61
+ ```
62
+
63
+ If you tag your image with something other than `my-langserve-app`,
64
+ note it for use in the next step.
65
+
66
+ ### Running the Image Locally
67
+
68
+ To run the image, you'll need to include any environment variables
69
+ necessary for your application.
70
+
71
+ In the below example, we inject the `OPENAI_API_KEY` environment
72
+ variable with the value set in my local environment
73
+ (`$OPENAI_API_KEY`)
74
+
75
+ We also expose port 8080 with the `-p 8080:8080` option.
76
+
77
+ ```shell
78
+ docker run -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8080:8080 my-langserve-app
79
+ ```
app/.env ADDED
@@ -0,0 +1 @@
 
 
1
+ BACK_API_KEY=a6ab9026-0ac8-4c26-9c30-6d9837fc9013
app/__init__.py ADDED
File without changes
app/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (214 Bytes). View file
 
app/__pycache__/server.cpython-311.pyc ADDED
Binary file (1.8 kB). View file
 
app/server.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Depends, HTTPException, status, Request #added security
2
+ from fastapi.responses import RedirectResponse
3
+ from langserve import add_routes
4
+ from rag_chroma import chain as rag_chroma_chain
5
+
6
+ from dotenv import load_dotenv
7
+ load_dotenv()
8
+ # load api key from .env file
9
+ import os
10
+
11
+
12
+ app = FastAPI()
13
+
14
+ API_KEY = os.getenv("BACK_API_KEY")
15
+
16
+ async def get_api_key(request: Request):
17
+ api_key = request.headers.get('x-api-key')
18
+ if api_key != API_KEY:
19
+ raise HTTPException(
20
+ status_code=status.HTTP_401_UNAUTHORIZED,
21
+ detail="Invalid API Key"
22
+ )
23
+
24
+ @app.get("/")
25
+ async def redirect_root_to_docs():
26
+ return RedirectResponse("/docs")
27
+
28
+
29
+ # Edit this to add the chain you want to add
30
+ add_routes(app, rag_chroma_chain,
31
+ path="/rag-chroma",
32
+ #playground_type='chat',
33
+ dependencies=[Depends(get_api_key)]
34
+ )
35
+
36
+ if __name__ == "__main__":
37
+ import uvicorn
38
+
39
+ uvicorn.run(app, host="0.0.0.0", port=8000)
app/streamlit_test.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ from langserve.client import RemoteRunnable
4
+ from httpx import HTTPStatusError
5
+ from dotenv import load_dotenv
6
+
7
+ # Load the environment variable
8
+ load_dotenv()
9
+
10
+ # Get the API key from environment variables
11
+ token = os.environ.get("BACK_API_KEY")
12
+
13
+ # Initialize the RemoteRunnable with your API endpoint and headers
14
+ rag_app = RemoteRunnable("http://127.0.0.1:8000/rag-chroma/", headers={"x-api-key": f"{token}"})
15
+
16
+ # Streamlit app
17
+ def main():
18
+ # Title of the app
19
+ st.title("Question Answering App")
20
+
21
+ # User input
22
+ question = st.text_input("Type your question here:")
23
+
24
+ # Button to send the question
25
+ if st.button("Get Answer"):
26
+ try:
27
+ # Use the RemoteRunnable to send the question and get the answer
28
+ answer = rag_app.invoke(question)
29
+ # Display the answer
30
+ st.success(answer)
31
+ except HTTPStatusError as e:
32
+ # Handle potential errors from the API call
33
+ st.error(f"Failed to get an answer. Error: {e}")
34
+
35
+ if __name__ == "__main__":
36
+ main()
app/test_server.ipynb ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "data": {
10
+ "text/plain": [
11
+ "True"
12
+ ]
13
+ },
14
+ "execution_count": 1,
15
+ "metadata": {},
16
+ "output_type": "execute_result"
17
+ }
18
+ ],
19
+ "source": [
20
+ "import streamlit as st\n",
21
+ "import os\n",
22
+ "from langserve.client import RemoteRunnable\n",
23
+ "from httpx import HTTPStatusError\n",
24
+ "from dotenv import load_dotenv\n",
25
+ "load_dotenv()"
26
+ ]
27
+ },
28
+ {
29
+ "cell_type": "code",
30
+ "execution_count": 2,
31
+ "metadata": {},
32
+ "outputs": [],
33
+ "source": [
34
+ "token = os.environ.get(\"BACK_API_KEY\")"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "code",
39
+ "execution_count": 3,
40
+ "metadata": {},
41
+ "outputs": [],
42
+ "source": [
43
+ "rag_app = RemoteRunnable(\"http://127.0.0.1:8000/rag-chroma/\", headers={\"x-api-key\": f\"{token}\"})"
44
+ ]
45
+ },
46
+ {
47
+ "cell_type": "code",
48
+ "execution_count": 5,
49
+ "metadata": {},
50
+ "outputs": [
51
+ {
52
+ "data": {
53
+ "text/plain": [
54
+ "'\\nAnswer: The speakers do not provide specific details about GPT-5. They mention that it is not yet developed and that there are challenges and bottlenecks to overcome before its creation. They also discuss that it will require a bigger computer and a new secret, and that it is a result of multiplying 200 medium-sized things together into one giant thing. They also mention that there is a lot of distributed constant innovation happening on the technical side.'"
55
+ ]
56
+ },
57
+ "execution_count": 5,
58
+ "metadata": {},
59
+ "output_type": "execute_result"
60
+ }
61
+ ],
62
+ "source": [
63
+ "rag_app.invoke(\"What do they say about GPT-5?\")"
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "code",
68
+ "execution_count": null,
69
+ "metadata": {},
70
+ "outputs": [],
71
+ "source": []
72
+ }
73
+ ],
74
+ "metadata": {
75
+ "kernelspec": {
76
+ "display_name": "langcorn",
77
+ "language": "python",
78
+ "name": "python3"
79
+ },
80
+ "language_info": {
81
+ "codemirror_mode": {
82
+ "name": "ipython",
83
+ "version": 3
84
+ },
85
+ "file_extension": ".py",
86
+ "mimetype": "text/x-python",
87
+ "name": "python",
88
+ "nbconvert_exporter": "python",
89
+ "pygments_lexer": "ipython3",
90
+ "version": "3.11.5"
91
+ }
92
+ },
93
+ "nbformat": 4,
94
+ "nbformat_minor": 2
95
+ }
packages/.DS_Store ADDED
Binary file (6.15 kB). View file
 
packages/README.md ADDED
File without changes
packages/rag-chroma/.DS_Store ADDED
Binary file (6.15 kB). View file
 
packages/rag-chroma/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 LangChain, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
packages/rag-chroma/README.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # rag-chroma
3
+
4
+ This template performs RAG using Chroma and OpenAI.
5
+
6
+ The vectorstore is created in `chain.py` and by default indexes a [popular blog posts on Agents](https://lilianweng.github.io/posts/2023-06-23-agent/) for question-answering.
7
+
8
+ ## Environment Setup
9
+
10
+ Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.
11
+
12
+ ## Usage
13
+
14
+ To use this package, you should first have the LangChain CLI installed:
15
+
16
+ ```shell
17
+ pip install -U langchain-cli
18
+ ```
19
+
20
+ To create a new LangChain project and install this as the only package, you can do:
21
+
22
+ ```shell
23
+ langchain app new my-app --package rag-chroma
24
+ ```
25
+
26
+ If you want to add this to an existing project, you can just run:
27
+
28
+ ```shell
29
+ langchain app add rag-chroma
30
+ ```
31
+
32
+ And add the following code to your `server.py` file:
33
+ ```python
34
+ from rag_chroma import chain as rag_chroma_chain
35
+
36
+ add_routes(app, rag_chroma_chain, path="/rag-chroma")
37
+ ```
38
+
39
+ (Optional) Let's now configure LangSmith.
40
+ LangSmith will help us trace, monitor and debug LangChain applications.
41
+ LangSmith is currently in private beta, you can sign up [here](https://smith.langchain.com/).
42
+ If you don't have access, you can skip this section
43
+
44
+ ```shell
45
+ export LANGCHAIN_TRACING_V2=true
46
+ export LANGCHAIN_API_KEY=<your-api-key>
47
+ export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
48
+ ```
49
+
50
+ If you are inside this directory, then you can spin up a LangServe instance directly by:
51
+
52
+ ```shell
53
+ langchain serve
54
+ ```
55
+
56
+ This will start the FastAPI app with a server is running locally at
57
+ [http://localhost:8000](http://localhost:8000)
58
+
59
+ We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
60
+ We can access the playground at [http://127.0.0.1:8000/rag-chroma/playground](http://127.0.0.1:8000/rag-chroma/playground)
61
+
62
+ We can access the template from code with:
63
+
64
+ ```python
65
+ from langserve.client import RemoteRunnable
66
+
67
+ runnable = RemoteRunnable("http://localhost:8000/rag-chroma")
68
+ ```
packages/rag-chroma/poetry.lock ADDED
The diff for this file is too large to render. See raw diff
 
packages/rag-chroma/pyproject.toml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.poetry]
2
+ name = "rag-chroma"
3
+ version = "0.1.0"
4
+ description = "RAG using Chroma"
5
+ authors = [
6
+ "Erick Friis <erick@langchain.dev>",
7
+ ]
8
+ readme = "README.md"
9
+
10
+ [tool.poetry.dependencies]
11
+ python = ">=3.8.1,<4.0"
12
+ langchain = "^0.1"
13
+ openai = "<2"
14
+ tiktoken = ">=0.5.1"
15
+ chromadb = ">=0.4.14"
16
+ langchain-text-splitters = ">=0.0.1,<0.1"
17
+
18
+ [tool.poetry.group.dev.dependencies]
19
+ langchain-cli = ">=0.0.21"
20
+
21
+ [tool.langserve]
22
+ export_module = "rag_chroma"
23
+ export_attr = "chain"
24
+
25
+ [tool.templates-hub]
26
+ use-case = "rag"
27
+ author = "LangChain"
28
+ integrations = ["OpenAI", "Chroma"]
29
+ tags = ["vectordbs"]
30
+
31
+ [build-system]
32
+ requires = [
33
+ "poetry-core",
34
+ ]
35
+ build-backend = "poetry.core.masonry.api"
packages/rag-chroma/rag_chroma.ipynb ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "681a5d1e",
6
+ "metadata": {},
7
+ "source": [
8
+ "## Run Template\n",
9
+ "\n",
10
+ "In `server.py`, set -\n",
11
+ "```\n",
12
+ "add_routes(app, chain_rag_conv, path=\"/rag-chroma\")\n",
13
+ "```"
14
+ ]
15
+ },
16
+ {
17
+ "cell_type": "code",
18
+ "execution_count": null,
19
+ "id": "d774be2a",
20
+ "metadata": {},
21
+ "outputs": [],
22
+ "source": [
23
+ "from langserve.client import RemoteRunnable\n",
24
+ "\n",
25
+ "rag_app = RemoteRunnable(\"http://localhost:8001/rag-chroma\")\n",
26
+ "rag_app.invoke(\"Where id Harrison work\")"
27
+ ]
28
+ }
29
+ ],
30
+ "metadata": {
31
+ "kernelspec": {
32
+ "display_name": "Python 3 (ipykernel)",
33
+ "language": "python",
34
+ "name": "python3"
35
+ },
36
+ "language_info": {
37
+ "codemirror_mode": {
38
+ "name": "ipython",
39
+ "version": 3
40
+ },
41
+ "file_extension": ".py",
42
+ "mimetype": "text/x-python",
43
+ "name": "python",
44
+ "nbconvert_exporter": "python",
45
+ "pygments_lexer": "ipython3",
46
+ "version": "3.9.16"
47
+ }
48
+ },
49
+ "nbformat": 4,
50
+ "nbformat_minor": 5
51
+ }
packages/rag-chroma/rag_chroma/.DS_Store ADDED
Binary file (6.15 kB). View file
 
packages/rag-chroma/rag_chroma/.env ADDED
@@ -0,0 +1 @@
 
 
1
+ TOGETHER_API_KEY=7091f9fb4f9db7e39170ca113c4bc9ad2405b1c8fec3772098a9f06c8c82e103
packages/rag-chroma/rag_chroma/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from rag_chroma.chain import chain
2
+
3
+ __all__ = ["chain"]
packages/rag-chroma/rag_chroma/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (282 Bytes). View file
 
packages/rag-chroma/rag_chroma/__pycache__/chain.cpython-311.pyc ADDED
Binary file (2.38 kB). View file
 
packages/rag-chroma/rag_chroma/chain.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #from langchain_community.chat_models import ChatOpenAI
2
+ from langchain_together.embeddings import TogetherEmbeddings
3
+ from langchain_together import Together
4
+ from langchain_community.vectorstores import Chroma
5
+ from langchain_core.output_parsers import StrOutputParser
6
+ from langchain_core.prompts import ChatPromptTemplate
7
+ from langchain_core.pydantic_v1 import BaseModel
8
+ from langchain_core.runnables import RunnableParallel, RunnablePassthrough
9
+
10
+ import os
11
+ from dotenv import load_dotenv
12
+ load_dotenv()
13
+ together_api_key = os.getenv("TOGETHER_API_KEY")
14
+
15
+
16
+ embeddings = TogetherEmbeddings(model="togethercomputer/m2-bert-80M-2k-retrieval")
17
+
18
+
19
+
20
+ # Example for document loading (from url), splitting, and creating vectostore
21
+
22
+ """
23
+ # Load
24
+ from langchain_community.document_loaders import WebBaseLoader
25
+ loader = WebBaseLoader("https://lilianweng.github.io/posts/2023-06-23-agent/")
26
+ data = loader.load()
27
+
28
+ # Split
29
+ from langchain_text_splitters import RecursiveCharacterTextSplitter
30
+ text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)
31
+ all_splits = text_splitter.split_documents(data)
32
+
33
+ # Add to vectorDB
34
+ vectorstore = Chroma.from_documents(documents=all_splits,
35
+ collection_name="rag-chroma",
36
+ embedding=OpenAIEmbeddings(),
37
+ )
38
+ retriever = vectorstore.as_retriever()
39
+ """
40
+
41
+ """ # Embed a single document as a test
42
+ vectorstore = Chroma.from_texts(
43
+ ["harrison worked at kensho"],
44
+ collection_name="rag-chroma",
45
+ embedding=OpenAIEmbeddings(),
46
+ )
47
+ retriever = vectorstore.as_retriever() """
48
+
49
+
50
+ # Load up vector-store
51
+ vectorstore = Chroma(persist_directory="packages/rag-chroma/rag_chroma/vecdb",
52
+ collection_name="rag-chroma",
53
+ embedding_function = embeddings)
54
+
55
+
56
+ retriever = vectorstore.as_retriever(search_type="mmr", search_kwargs={'k': 7})
57
+
58
+
59
+ # RAG prompt
60
+ template = """Answer the question based only on the following context:
61
+ {context}
62
+
63
+ Question: {question}
64
+ """
65
+ prompt = ChatPromptTemplate.from_template(template)
66
+
67
+ # LLM
68
+ model = Together(
69
+ #model="mistralai/Mistral-7B-Instruct-v0.2",
70
+ model="mistralai/Mixtral-8x7B-Instruct-v0.1",
71
+ temperature=0.7,
72
+ top_k=50,
73
+ top_p=0.7,
74
+ repetition_penalty=1,
75
+ together_api_key=together_api_key
76
+ )
77
+
78
+ # RAG chain
79
+ chain = (
80
+ RunnableParallel({"context": retriever, "question": RunnablePassthrough()})
81
+ | prompt
82
+ | model
83
+ | StrOutputParser()
84
+ )
85
+
86
+
87
+ # Add typing for input
88
+ class Question(BaseModel):
89
+ __root__: str
90
+
91
+
92
+ chain = chain.with_types(input_type=Question)
packages/rag-chroma/rag_chroma/load_files_chroma.ipynb ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Create vecdb - notebook"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": 1,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "from langchain_community.vectorstores import Chroma\n",
17
+ "from langchain_together.embeddings import TogetherEmbeddings\n",
18
+ "\n",
19
+ "\n",
20
+ "import os\n",
21
+ "from dotenv import load_dotenv\n",
22
+ "load_dotenv()\n",
23
+ "together_api_key = os.getenv(\"TOGETHER_API_KEY\")\n",
24
+ "\n",
25
+ "embeddings = TogetherEmbeddings(model=\"togethercomputer/m2-bert-80M-2k-retrieval\")\n",
26
+ "\n",
27
+ "# Load\n",
28
+ "from langchain_community.document_loaders import WebBaseLoader\n",
29
+ "loader = WebBaseLoader(\"https://lexfridman.com/sam-altman-2-transcript/\")\n",
30
+ "data = loader.load()\n",
31
+ "\n",
32
+ "# Split\n",
33
+ "from langchain_text_splitters import RecursiveCharacterTextSplitter\n",
34
+ "text_splitter = RecursiveCharacterTextSplitter(chunk_size=2000, chunk_overlap=250)\n",
35
+ "all_splits = text_splitter.split_documents(data)"
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "execution_count": 4,
41
+ "metadata": {},
42
+ "outputs": [],
43
+ "source": [
44
+ "# Add to vectorDB\n",
45
+ "vectorstore = Chroma.from_documents(persist_directory=\"vecdb_test\",\n",
46
+ " documents=all_splits, \n",
47
+ " collection_name=\"rag-chroma\",\n",
48
+ " embedding=embeddings,\n",
49
+ " )\n",
50
+ "retriever = vectorstore.as_retriever()"
51
+ ]
52
+ },
53
+ {
54
+ "cell_type": "markdown",
55
+ "metadata": {},
56
+ "source": [
57
+ "### Huggingface transformers embeddings\n",
58
+ "\n",
59
+ "more complicated but \"free\" way of creating embeddings\n",
60
+ "you will need to install\n",
61
+ "```\n",
62
+ "sentence-transformers\n",
63
+ "einops\n",
64
+ "opt_einsum\n",
65
+ "```"
66
+ ]
67
+ },
68
+ {
69
+ "cell_type": "code",
70
+ "execution_count": 7,
71
+ "metadata": {},
72
+ "outputs": [],
73
+ "source": [
74
+ "from langchain_community.embeddings import HuggingFaceEmbeddings"
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "code",
79
+ "execution_count": 8,
80
+ "metadata": {},
81
+ "outputs": [
82
+ {
83
+ "name": "stderr",
84
+ "output_type": "stream",
85
+ "text": [
86
+ "/opt/miniconda3/envs/langcorn/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
87
+ " from .autonotebook import tqdm as notebook_tqdm\n",
88
+ "No sentence-transformers model found with name togethercomputer/m2-bert-80M-2k-retrieval. Creating a new one with MEAN pooling.\n",
89
+ "You are using a model of type m2_bert to instantiate a model of type bert. This is not supported for all configurations of models and can yield errors.\n"
90
+ ]
91
+ },
92
+ {
93
+ "name": "stdout",
94
+ "output_type": "stream",
95
+ "text": [
96
+ "-- Bidirectional: True\n",
97
+ "-- Using Long Conv Residual: True\n",
98
+ "-- Hyena w: 10\n",
99
+ "-- Hyena w mod: 1\n",
100
+ "-- Hyena filter order: 128\n",
101
+ "-- Hyena filter dropout: 0.2\n",
102
+ "-- Hyena filter wd: 0.1\n",
103
+ "-- Hyena filter emb dim: 5\n",
104
+ "-- Hyena filter lr: 0.001\n",
105
+ "-- Hyena filter lr pos emb: 1e-05\n"
106
+ ]
107
+ }
108
+ ],
109
+ "source": [
110
+ "model_name = \"togethercomputer/m2-bert-80M-2k-retrieval\"\n",
111
+ "model_kwargs = {'device': 'cpu', 'trust_remote_code': True}\n",
112
+ "encode_kwargs = {'normalize_embeddings': False}\n",
113
+ "hf = HuggingFaceEmbeddings(\n",
114
+ " model_name=model_name,\n",
115
+ " model_kwargs=model_kwargs,\n",
116
+ " encode_kwargs=encode_kwargs\n",
117
+ ")"
118
+ ]
119
+ },
120
+ {
121
+ "cell_type": "code",
122
+ "execution_count": 9,
123
+ "metadata": {},
124
+ "outputs": [],
125
+ "source": [
126
+ "# Add to vectorDB\n",
127
+ "vectorstore = Chroma.from_documents(persist_directory=\"vecdb_hf_test\",\n",
128
+ " documents=all_splits, \n",
129
+ " collection_name=\"rag-chroma\",\n",
130
+ " embedding=hf,\n",
131
+ " )\n",
132
+ "retriever = vectorstore.as_retriever()"
133
+ ]
134
+ },
135
+ {
136
+ "cell_type": "code",
137
+ "execution_count": null,
138
+ "metadata": {},
139
+ "outputs": [],
140
+ "source": []
141
+ }
142
+ ],
143
+ "metadata": {
144
+ "kernelspec": {
145
+ "display_name": "langcorn",
146
+ "language": "python",
147
+ "name": "python3"
148
+ },
149
+ "language_info": {
150
+ "codemirror_mode": {
151
+ "name": "ipython",
152
+ "version": 3
153
+ },
154
+ "file_extension": ".py",
155
+ "mimetype": "text/x-python",
156
+ "name": "python",
157
+ "nbconvert_exporter": "python",
158
+ "pygments_lexer": "ipython3",
159
+ "version": "3.11.5"
160
+ }
161
+ },
162
+ "nbformat": 4,
163
+ "nbformat_minor": 2
164
+ }
packages/rag-chroma/rag_chroma/test.ipynb ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "#from langchain_community.chat_models import ChatOpenAI\n",
10
+ "from langchain_together.embeddings import TogetherEmbeddings\n",
11
+ "from langchain_together import Together\n",
12
+ "from langchain_community.vectorstores import Chroma\n",
13
+ "from langchain_core.output_parsers import StrOutputParser\n",
14
+ "from langchain_core.prompts import ChatPromptTemplate\n",
15
+ "from langchain_core.pydantic_v1 import BaseModel\n",
16
+ "from langchain_core.runnables import RunnableParallel, RunnablePassthrough\n",
17
+ "\n",
18
+ "import os\n",
19
+ "from dotenv import load_dotenv\n",
20
+ "load_dotenv()\n",
21
+ "together_api_key = os.getenv(\"TOGETHER_API_KEY\")\n",
22
+ "\n",
23
+ "\n",
24
+ "embeddings = TogetherEmbeddings(model=\"togethercomputer/m2-bert-80M-2k-retrieval\")\n",
25
+ "\n",
26
+ "\n",
27
+ "\n",
28
+ "# Example for document loading (from url), splitting, and creating vectostore\n",
29
+ "\n",
30
+ "\"\"\" \n",
31
+ "# Load\n",
32
+ "from langchain_community.document_loaders import WebBaseLoader\n",
33
+ "loader = WebBaseLoader(\"https://lilianweng.github.io/posts/2023-06-23-agent/\")\n",
34
+ "data = loader.load()\n",
35
+ "\n",
36
+ "# Split\n",
37
+ "from langchain_text_splitters import RecursiveCharacterTextSplitter\n",
38
+ "text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)\n",
39
+ "all_splits = text_splitter.split_documents(data)\n",
40
+ "\n",
41
+ "# Add to vectorDB\n",
42
+ "vectorstore = Chroma.from_documents(documents=all_splits, \n",
43
+ " collection_name=\"rag-chroma\",\n",
44
+ " embedding=OpenAIEmbeddings(),\n",
45
+ " )\n",
46
+ "retriever = vectorstore.as_retriever()\n",
47
+ "\"\"\"\n",
48
+ "\n",
49
+ "\"\"\" # Embed a single document as a test\n",
50
+ "vectorstore = Chroma.from_texts(\n",
51
+ " [\"harrison worked at kensho\"],\n",
52
+ " collection_name=\"rag-chroma\",\n",
53
+ " embedding=OpenAIEmbeddings(),\n",
54
+ ")\n",
55
+ "retriever = vectorstore.as_retriever() \"\"\"\n",
56
+ "\n",
57
+ "\n",
58
+ "# Load up vector-store\n",
59
+ "vectorstore = Chroma(persist_directory=\"vecdb\",\n",
60
+ " collection_name=\"rag-chroma\",\n",
61
+ " embedding_function = embeddings)\n",
62
+ "\n",
63
+ "\n",
64
+ "retriever = vectorstore.as_retriever(search_type=\"mmr\", search_kwargs={'k': 7})\n"
65
+ ]
66
+ },
67
+ {
68
+ "cell_type": "code",
69
+ "execution_count": 2,
70
+ "metadata": {},
71
+ "outputs": [
72
+ {
73
+ "data": {
74
+ "text/plain": [
75
+ "[Document(page_content='(00:35:28) \\nI remember when I started first watching Sora videos and I would see a person walk in front of something for a few seconds and occlude it and then walk away and the same thing was still there. I was like, “Oh, this is pretty good.” Or there’s examples where the underlying physics looks so well represented over a lot of steps in a sequence, it’s like, “|Oh, this is quite impressive.” But fundamentally, these models are just getting better and that will keep happening. If you look at the trajectory from DALL·E 1 to 2 to 3 to Sora, there are a lot of people that were dunked on each version saying it can’t do this, it can’t do that and look at it now.\\n\\n\\nLex Fridman\\n(00:36:04) \\nWell, the thing you just mentioned is the occlusions is basically modeling the physics of the three-dimensional physics of the world sufficiently well to capture those kinds of things.\\n\\n\\nSam Altman\\n(00:36:17) \\nWell…\\n\\n\\nLex Fridman\\n(00:36:18) \\nOr yeah, maybe you can tell me, in order to deal with occlusions, what does the world model need to?\\n\\n\\nSam Altman\\n(00:36:24) \\nYeah. So what I would say is it’s doing something to deal with occlusions really well. What I represent that it has a great underlying 3D model of the world, it’s a little bit more of a stretch.\\n\\n\\nLex Fridman\\n(00:36:33) \\nBut can you get there through just these kinds of two-dimensional training data approaches?\\n\\n\\nSam Altman\\n(00:36:39) \\nIt looks like this approach is going to go surprisingly far. I don’t want to speculate too much about what limits it will surmount and which it won’t, but…\\n\\n\\nLex Fridman\\n(00:36:46) \\nWhat are some interesting limitations of the system that you’ve seen? I mean there’s been some fun ones you’ve posted.\\n\\n\\nSam Altman\\n(00:36:52) \\nThere’s all kinds of fun. I mean, cat’s sprouting an extra limit at random points in a video. Pick what you want, but there’s still a lot of problem, there’s a lot of weaknesses.', metadata={'language': 'en-US', 'source': 'https://lexfridman.com/sam-altman-2-transcript/', 'title': 'Transcript for Sam Altman: OpenAI, GPT-5, Sora, Board Saga, Elon Musk, Ilya, Power & AGI | Lex Fridman Podcast #419 - Lex Fridman'}),\n",
76
+ " Document(page_content='Sam Altman\\n(01:37:22) \\nMaybe. Maybe we need to go invent more technology and measure more things first.\\n\\n\\nLex Fridman\\n(01:37:28) \\nOh, I see. It just doesn’t have enough data. It’s just if it keeps-\\n\\n\\nSam Altman\\n(01:37:31) \\nI mean, maybe it says, “You want to know the answer to this question about physics, I need you to build this machine and make these five measurements, and tell me that.”\\n\\n\\nLex Fridman\\n(01:37:39) \\nYeah, “What the hell do you want from me? I need the machine first, and I’ll help you deal with the data from that machine.” Maybe it’ll help you build a machine.\\n\\n\\nSam Altman\\n(01:37:47) \\nMaybe. Maybe.\\n\\n\\nLex Fridman\\n(01:37:49) \\nAnd on the mathematical side, maybe prove some things. Are you interested in that side of things, too? The formalized exploration of ideas?\\n\\n\\nSam Altman\\n(01:37:56) \\nMm-hmm.\\n\\n\\nLex Fridman\\n(01:37:59) \\nWhoever builds AGI first gets a lot of power. Do you trust yourself with that much power?\\n\\n\\nSam Altman\\n(01:38:14) \\nLook, I’ll just be very honest with this answer. I was going to say, and I still believe this, that it is important that I nor any other one person have total control over OpenAI or over AGI. And I think you want a robust governance system. I can point out a whole bunch of things about all of our board drama from last year about how I didn’t fight it initially, and was just like, “Yeah. That’s the will of the board, even though I think it’s a really bad decision.” And then later, I clearly did fight it, and I can explain the nuance and why I think it was okay for me to fight it later. But as many people have observed, although the board had the legal ability to fire me, in practice, it didn’t quite work. And that is its own kind of governance failure.', metadata={'language': 'en-US', 'source': 'https://lexfridman.com/sam-altman-2-transcript/', 'title': 'Transcript for Sam Altman: OpenAI, GPT-5, Sora, Board Saga, Elon Musk, Ilya, Power & AGI | Lex Fridman Podcast #419 - Lex Fridman'}),\n",
77
+ " Document(page_content='Sam Altman\\n(00:38:44) \\nYeah.\\n\\n\\nLex Fridman\\n(00:38:45) \\nAnd then the question is, how much data is there on the internet that could be used in this that is conducive to this kind of self supervised way if only we knew the details of the self supervised. Have you considered opening it up a little more details?\\n\\n\\nSam Altman\\n(00:39:02) \\nWe have. You mean for source specifically?\\n\\n\\nLex Fridman\\n(00:39:04) \\nSource specifically. Because it’s so interesting that can the same magic of LLMs now start moving towards visual data and what does that take to do that?\\n\\n\\nSam Altman\\n(00:39:18) \\nI mean it looks to me like yes, but we have more work to do.\\n\\n\\nLex Fridman\\n(00:39:22) \\nSure. What are the dangers? Why are you concerned about releasing the system? What are some possible dangers of this?\\n\\n\\nSam Altman\\n(00:39:29) \\nI mean frankly speaking, one thing we have to do before releasing the system is just get it to work at a level of efficiency that will deliver the scale people are going to want from this so that I don’t want to downplay that. And there’s still a ton ton of work to do there. But you can imagine issues with deepfakes, misinformation. We try to be a thoughtful company about what we put out into the world and it doesn’t take much thought to think about the ways this can go badly.\\n\\n\\nLex Fridman\\n(00:40:05) \\nThere’s a lot of tough questions here, you’re dealing in a very tough space. Do you think training AI should be or is fair use under copyright law?', metadata={'language': 'en-US', 'source': 'https://lexfridman.com/sam-altman-2-transcript/', 'title': 'Transcript for Sam Altman: OpenAI, GPT-5, Sora, Board Saga, Elon Musk, Ilya, Power & AGI | Lex Fridman Podcast #419 - Lex Fridman'}),\n",
78
+ " Document(page_content='Sam Altman\\n(01:01:34) \\nI suspect that’s a reasonable intuition.\\n\\n\\nLex Fridman\\n(01:01:37) \\nInteresting. So it’s not possible once the GPT gets like GPT-7, would just instantaneously be able to see, “Here’s the proof of Fermat’s Theorem”?\\n\\n\\nSam Altman\\n(01:01:49) \\nIt seems to me like you want to be able to allocate more compute to harder problems. It seems to me that if you ask a system like that, “Prove Fermat’s Last Theorem,” versus, “What’s today’s date?,” unless it already knew and and had memorized the answer to the proof, assuming it’s got to go figure that out, seems like that will take more compute.\\n\\n\\nLex Fridman\\n(01:02:20) \\nBut can it look like basically an LLM talking to itself, that kind of thing?\\n\\n\\nSam Altman\\n(01:02:25) \\nMaybe. I mean, there’s a lot of things that you could imagine working. What the right or the best way to do that will be, we don’t know.\\n\\nQ*\\n\\nLex Fridman\\n(01:02:37) \\nThis does make me think of the mysterious lore behind Q*. What’s this mysterious Q* project? Is it also in the same nuclear facility?\\n\\n\\nSam Altman\\n(01:02:50) \\nThere is no nuclear facility.\\n\\n\\nLex Fridman\\n(01:02:52) \\nMm-hmm. That’s what a person with a nuclear facility always says.\\n\\n\\nSam Altman\\n(01:02:54) \\nI would love to have a secret nuclear facility. There isn’t one.\\n\\n\\nLex Fridman\\n(01:02:59) \\nAll right.\\n\\n\\nSam Altman\\n(01:03:00) \\nMaybe someday.\\n\\n\\nLex Fridman\\n(01:03:01) \\nSomeday? All right. One can dream.\\n\\n\\nSam Altman\\n(01:03:05) \\nOpenAI is not a good company at keeping secrets. It would be nice. We’re like, been plagued by a lot of leaks, and it would be nice if we were able to have something like that.\\n\\n\\nLex Fridman\\n(01:03:14) \\nCan you speak to what Q* is?\\n\\n\\nSam Altman\\n(01:03:16) \\nWe are not ready to talk about that.\\n\\n\\nLex Fridman\\n(01:03:17) \\nSee, but an answer like that means there’s something to talk about. It’s very mysterious, Sam.', metadata={'language': 'en-US', 'source': 'https://lexfridman.com/sam-altman-2-transcript/', 'title': 'Transcript for Sam Altman: OpenAI, GPT-5, Sora, Board Saga, Elon Musk, Ilya, Power & AGI | Lex Fridman Podcast #419 - Lex Fridman'}),\n",
79
+ " Document(page_content='Sam Altman\\n(01:30:55) \\nChanges the skillset. How much it changes the predisposition, I’m not sure.\\n\\n\\nLex Fridman\\n(01:30:59) \\nWell, the same kind of puzzle solving, all that kind of stuff.\\n\\n\\nSam Altman\\n(01:30:59) \\nMaybe.\\n\\n\\nLex Fridman\\n(01:31:02) \\nProgramming is hard. It’s like how get that last 1% to close the gap? How hard is that?\\n\\n\\nSam Altman\\n(01:31:09) \\nYeah, I think with most other cases, the best practitioners of the craft will use multiple tools. And they’ll do some work in natural language, and when they need to go write C for something, they’ll do that.\\n\\n\\nLex Fridman\\n(01:31:20) \\nWill we see humanoid robots or humanoid robot brains from OpenAI at some point?\\n\\n\\nSam Altman\\n(01:31:28) \\nAt some point.\\n\\n\\nLex Fridman\\n(01:31:29) \\nHow important is embodied AI to you?\\n\\n\\nSam Altman\\n(01:31:32) \\nI think it’s depressing if we have AGI and the only way to get things done in the physical world is to make a human go do it. So I really hope that as part of this transition, as this phase change, we also get humanoid robots or some sort of physical world robots.\\n\\n\\nLex Fridman\\n(01:31:51) \\nI mean, OpenAI has some history and quite a bit of history working in robotics, but it hasn’t quite done in terms of ethics-\\n\\n\\nSam Altman\\n(01:31:59) \\nWe’re a small company. We have to really focus. And also, robots were hard for the wrong reason at the time, but we will return to robots in some way at some point.\\n\\n\\nLex Fridman\\n(01:32:11) \\nThat sounds both inspiring and menacing.\\n\\n\\nSam Altman\\n(01:32:14) \\nWhy?\\n\\n\\nLex Fridman\\n(01:32:15) \\nBecause immediately, we will return to robots. It’s like in Terminator-\\n\\n\\nSam Altman\\n(01:32:20) \\nWe will return to work on developing robots. We will not turn ourselves into robots, of course.\\n\\nAGI\\n\\nLex Fridman\\n(01:32:24) \\nYeah. When do you think we, you and we as humanity will build AGI?', metadata={'language': 'en-US', 'source': 'https://lexfridman.com/sam-altman-2-transcript/', 'title': 'Transcript for Sam Altman: OpenAI, GPT-5, Sora, Board Saga, Elon Musk, Ilya, Power & AGI | Lex Fridman Podcast #419 - Lex Fridman'}),\n",
80
+ " Document(page_content='Lex Fridman\\n(00:50:01) \\nHow does the context window of going from 8K to 128K tokens compare from GPT-4 to GPT-4 Turbo?\\n\\n\\nSam Altman\\n(00:50:13) \\nMost people don’t need all the way to 128 most of the time. Although if we dream into the distant future, we’ll have way distant future, we’ll have context length of several billion. You will feed in all of your information, all of your history over time and it’ll just get to know you better and better and that’ll be great. For now, the way people use these models, they’re not doing that. People sometimes post in a paper or a significant fraction of a code repository, whatever, but most usage of the models is not using the long context most of the time.\\n\\n\\nLex Fridman\\n(00:50:50) \\nI like that this is your “I have a dream” speech. One day you’ll be judged by the full context of your character or of your whole lifetime. That’s interesting. So that’s part of the expansion that you’re hoping for, is a greater and greater context.\\n\\n\\nSam Altman\\n(00:51:06) \\nI saw this internet clip once, I’m going to get the numbers wrong, but it was like Bill Gates talking about the amount of memory on some early computer, maybe it was 64K, maybe 640K, something like that. Most of it was used for the screen buffer. He just couldn’t seem genuine. He just couldn’t imagine that the world would eventually need gigabytes of memory in a computer or terabytes of memory in a computer. And you always do, or you always do just need to follow the exponential of technology and we will find out how to use better technology. So I can’t really imagine what it’s like right now for context links to go out to the billion someday. And they might not literally go there, but effectively it’ll feel like that. But I know we’ll use it and really not want to go back once we have it.\\n\\n\\nLex Fridman\\n(00:51:56) \\nYeah, even saying billions 10 years from now might seem dumb because it’ll be trillions upon trillions.\\n\\n\\nSam Altman\\n(00:52:04) \\nSure.', metadata={'language': 'en-US', 'source': 'https://lexfridman.com/sam-altman-2-transcript/', 'title': 'Transcript for Sam Altman: OpenAI, GPT-5, Sora, Board Saga, Elon Musk, Ilya, Power & AGI | Lex Fridman Podcast #419 - Lex Fridman'}),\n",
81
+ " Document(page_content='Lex Fridman\\n(01:12:57) \\nOh, like we want to stop this from-\\n\\n\\nSam Altman\\n(01:13:00) \\nMaybe.\\n\\n\\nLex Fridman\\n(01:13:03) \\nHow do you decrease the theatrical nature of it? I’m already starting to hear rumblings, because I do talk to people on both sides of the political spectrum, hear rumblings where it’s going to be politicized. AI is going to be politicized, which really worries me, because then it’s like maybe the right is against AI and the left is for AI because it’s going to help the people, or whatever the narrative and the formulation is, that really worries me. And then the theatrical nature of it can be leveraged fully. How do you fight that?\\n\\n\\nSam Altman\\n(01:13:38) \\nI think it will get caught up in left versus right wars. I don’t know exactly what that’s going to look like, but I think that’s just what happens with anything of consequence, unfortunately. What I meant more about theatrical risks is AI’s going to have, I believe, tremendously more good consequences than bad ones, but it is going to have bad ones, and there’ll be some bad ones that are bad but not theatrical. A lot more people have died of air pollution than nuclear reactors, for example. But most people worry more about living next to a nuclear reactor than a coal plant. But something about the way we’re wired is that although there’s many different kinds of risks we have to confront, the ones that make a good climax scene of a movie carry much more weight with us than the ones that are very bad over a long period of time but on a slow burn.\\n\\n\\nLex Fridman\\n(01:14:36) \\nWell, that’s why truth matters, and hopefully AI can help us see the truth of things, to have balance, to understand what are the actual risks, what are the actual dangers of things in the world. What are the pros and cons of the competition in the space and competing with Google, Meta, xAI, and others?', metadata={'language': 'en-US', 'source': 'https://lexfridman.com/sam-altman-2-transcript/', 'title': 'Transcript for Sam Altman: OpenAI, GPT-5, Sora, Board Saga, Elon Musk, Ilya, Power & AGI | Lex Fridman Podcast #419 - Lex Fridman'})]"
82
+ ]
83
+ },
84
+ "execution_count": 2,
85
+ "metadata": {},
86
+ "output_type": "execute_result"
87
+ }
88
+ ],
89
+ "source": [
90
+ "retriever.invoke('GPT-5')"
91
+ ]
92
+ },
93
+ {
94
+ "cell_type": "code",
95
+ "execution_count": null,
96
+ "metadata": {},
97
+ "outputs": [],
98
+ "source": []
99
+ }
100
+ ],
101
+ "metadata": {
102
+ "kernelspec": {
103
+ "display_name": "langcorn",
104
+ "language": "python",
105
+ "name": "python3"
106
+ },
107
+ "language_info": {
108
+ "codemirror_mode": {
109
+ "name": "ipython",
110
+ "version": 3
111
+ },
112
+ "file_extension": ".py",
113
+ "mimetype": "text/x-python",
114
+ "name": "python",
115
+ "nbconvert_exporter": "python",
116
+ "pygments_lexer": "ipython3",
117
+ "version": "3.11.5"
118
+ }
119
+ },
120
+ "nbformat": 4,
121
+ "nbformat_minor": 2
122
+ }
packages/rag-chroma/rag_chroma/vecdb/12bce733-e94f-4342-829a-6786a9f92a50/data_level0.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a13e72541800c513c73dccea69f79e39cf4baef4fa23f7e117c0d6b0f5f99670
3
+ size 3212000
packages/rag-chroma/rag_chroma/vecdb/12bce733-e94f-4342-829a-6786a9f92a50/header.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ec6df10978b056a10062ed99efeef2702fa4a1301fad702b53dd2517103c746
3
+ size 100
packages/rag-chroma/rag_chroma/vecdb/12bce733-e94f-4342-829a-6786a9f92a50/length.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc19b1997119425765295aeab72d76faa6927d4f83985d328c26f20468d6cc76
3
+ size 4000
packages/rag-chroma/rag_chroma/vecdb/12bce733-e94f-4342-829a-6786a9f92a50/link_lists.bin ADDED
File without changes
packages/rag-chroma/rag_chroma/vecdb/chroma.sqlite3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:058452996d2a4d5e9b7024ef66bd7f398e9a50fc943b671258681034fb911624
3
+ size 1376256
packages/rag-chroma/tests/__init__.py ADDED
File without changes
pyproject.toml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.poetry]
2
+ name = "my-app"
3
+ version = "0.1.0"
4
+ description = ""
5
+ authors = ["Your Name <you@example.com>"]
6
+ readme = "README.md"
7
+ packages = [
8
+ { include = "app" },
9
+ ]
10
+
11
+ [tool.poetry.dependencies]
12
+ python = "^3.11"
13
+ uvicorn = "^0.23.2"
14
+ langserve = {extras = ["server"], version = ">=0.0.30"}
15
+ pydantic = "2.6.0"
16
+ rag-chroma = {path = "packages/rag-chroma", develop = true}
17
+ python-dotenv = "1"
18
+ langchain-together = "0.0.2.post1"
19
+
20
+ [tool.poetry.group.dev.dependencies]
21
+ langchain-cli = ">=0.0.15"
22
+
23
+ [build-system]
24
+ requires = ["poetry-core"]
25
+ build-backend = "poetry.core.masonry.api"