From eaea4e2e8ccb154bb8bd91dcffeea28f4c9ed90e Mon Sep 17 00:00:00 2001
From: molgoo <140925388+molgoo@users.noreply.github.com>
Date: Tue, 15 Aug 2023 00:19:35 -0400
Subject: [PATCH 1/4] Created using Colaboratory
---
..._the_Most_of_your_Colab_Subscription.ipynb | 259 ++++++++++++++++++
1 file changed, 259 insertions(+)
create mode 100644 Making_the_Most_of_your_Colab_Subscription.ipynb
diff --git a/Making_the_Most_of_your_Colab_Subscription.ipynb b/Making_the_Most_of_your_Colab_Subscription.ipynb
new file mode 100644
index 00000000..950cca9e
--- /dev/null
+++ b/Making_the_Most_of_your_Colab_Subscription.ipynb
@@ -0,0 +1,259 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "SKQ4bH7qMGrA"
+ },
+ "source": [
+ "# Making the Most of your Colab Subscription\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "QMMqmdiYMkvi"
+ },
+ "source": [
+ "## Faster GPUs\n",
+ "\n",
+ "Users who have purchased one of Colab's paid plans have access to premium GPUs. You can upgrade your notebook's GPU settings in `Runtime > Change runtime type` in the menu to enable Premium accelerator. Subject to availability, selecting a premium GPU may grant you access to a V100 or A100 Nvidia GPU.\n",
+ "\n",
+ "The free of charge version of Colab grants access to Nvidia's T4 GPUs subject to quota restrictions and availability.\n",
+ "\n",
+ "You can see what GPU you've been assigned at any time by executing the following cell. If the execution result of running the code cell below is \"Not connected to a GPU\", you can change the runtime by going to `Runtime > Change runtime type` in the menu to enable a GPU accelerator, and then re-execute the code cell.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "23TOba33L4qf"
+ },
+ "outputs": [],
+ "source": [
+ "gpu_info = !nvidia-smi\n",
+ "gpu_info = '\\n'.join(gpu_info)\n",
+ "if gpu_info.find('failed') >= 0:\n",
+ " print('Not connected to a GPU')\n",
+ "else:\n",
+ " print(gpu_info)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from google.colab import drive\n",
+ "drive.mount('/content/drive')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "flUoqVkOVxJr",
+ "outputId": "9262468b-8025-4781-8b68-2b25de35b704"
+ },
+ "execution_count": 4,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Mounted at /content/drive\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "!git clone . https://github.com/molgoo/ask-multiple-pdfs"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "boGOeQKSXWJH",
+ "outputId": "a177c19b-df5e-4b28-ddef-6ff6fa5e0593"
+ },
+ "execution_count": 9,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "fatal: repository '.' does not exist\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "Sa-IrJS1aRVJ"
+ },
+ "source": [
+ "In order to use a GPU with your notebook, select the `Runtime > Change runtime type` menu, and then set the hardware accelerator dropdown to GPU."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "65MSuHKqNeBZ"
+ },
+ "source": [
+ "## More memory\n",
+ "\n",
+ "Users who have purchased one of Colab's paid plans have access to high-memory VMs when they are available.\n",
+ "\n",
+ "\n",
+ "\n",
+ "You can see how much memory you have available at any time by running the following code cell. If the execution result of running the code cell below is \"Not using a high-RAM runtime\", then you can enable a high-RAM runtime via `Runtime > Change runtime type` in the menu. Then select High-RAM in the Runtime shape dropdown. After, re-execute the code cell.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "V1G82GuO-tez"
+ },
+ "outputs": [],
+ "source": [
+ "from psutil import virtual_memory\n",
+ "ram_gb = virtual_memory().total / 1e9\n",
+ "print('Your runtime has {:.1f} gigabytes of available RAM\\n'.format(ram_gb))\n",
+ "\n",
+ "if ram_gb < 20:\n",
+ " print('Not using a high-RAM runtime')\n",
+ "else:\n",
+ " print('You are using a high-RAM runtime!')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "BJW8Qi-pPpep"
+ },
+ "source": [
+ "## Longer runtimes\n",
+ "\n",
+ "All Colab runtimes are reset after some period of time (which is faster if the runtime isn't executing code). Colab Pro and Pro+ users have access to longer runtimes than those who use Colab free of charge.\n",
+ "\n",
+ "## Background execution\n",
+ "\n",
+ "Colab Pro+ users have access to background execution, where notebooks will continue executing even after you've closed a browser tab. This is always enabled in Pro+ runtimes as long as you have compute units available.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "uLlTRcMM_h0k"
+ },
+ "source": [
+ "## Relaxing resource limits in Colab Pro\n",
+ "\n",
+ "Your resources are not unlimited in Colab. To make the most of Colab, avoid using resources when you don't need them. For example, only use a GPU when required and close Colab tabs when finished.\n",
+ "\n",
+ "\n",
+ "\n",
+ "If you encounter limitations, you can relax those limitations by purchasing more compute units via Pay As You Go. Anyone can purchase compute units via [Pay As You Go](https://colab.research.google.com/signup); no subscription is required."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "mm8FzEidvPs6"
+ },
+ "source": [
+ "## Send us feedback!\n",
+ "\n",
+ "If you have any feedback for us, please let us know. The best way to send feedback is by using the Help > 'Send feedback...' menu. If you encounter usage limits in Colab Pro consider subscribing to Pro+.\n",
+ "\n",
+ "If you encounter errors or other issues with billing (payments) for Colab Pro, Pro+, or Pay As You Go, please email [colab-billing@google.com](mailto:colab-billing@google.com)."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "qB3bdLe8jkAa"
+ },
+ "source": [
+ "## More Resources\n",
+ "\n",
+ "### Working with Notebooks in Colab\n",
+ "- [Overview of Colaboratory](/notebooks/basic_features_overview.ipynb)\n",
+ "- [Guide to Markdown](/notebooks/markdown_guide.ipynb)\n",
+ "- [Importing libraries and installing dependencies](/notebooks/snippets/importing_libraries.ipynb)\n",
+ "- [Saving and loading notebooks in GitHub](https://colab.research.google.com/github/googlecolab/colabtools/blob/master/notebooks/colab-github-demo.ipynb)\n",
+ "- [Interactive forms](/notebooks/forms.ipynb)\n",
+ "- [Interactive widgets](/notebooks/widgets.ipynb)\n",
+ "\n",
+ "\n",
+ "### Working with Data\n",
+ "- [Loading data: Drive, Sheets, and Google Cloud Storage](/notebooks/io.ipynb)\n",
+ "- [Charts: visualizing data](/notebooks/charts.ipynb)\n",
+ "- [Getting started with BigQuery](/notebooks/bigquery.ipynb)\n",
+ "\n",
+ "### Machine Learning Crash Course\n",
+ "These are a few of the notebooks from Google's online Machine Learning course. See the [full course website](https://developers.google.com/machine-learning/crash-course/) for more.\n",
+ "- [Intro to Pandas DataFrame](https://colab.research.google.com/github/google/eng-edu/blob/main/ml/cc/exercises/pandas_dataframe_ultraquick_tutorial.ipynb)\n",
+ "- [Linear regression with tf.keras using synthetic data](https://colab.research.google.com/github/google/eng-edu/blob/main/ml/cc/exercises/linear_regression_with_synthetic_data.ipynb)\n",
+ "\n",
+ "\n",
+ "\n",
+ "### Using Accelerated Hardware\n",
+ "- [TensorFlow with GPUs](/notebooks/gpu.ipynb)\n",
+ "- [TensorFlow with TPUs](/notebooks/tpu.ipynb)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "RFm2S0Gijqo8"
+ },
+ "source": [
+ "\n",
+ "\n",
+ "## Machine Learning Examples\n",
+ "\n",
+ "To see end-to-end examples of the interactive machine learning analyses that Colaboratory makes possible, check out these tutorials using models from [TensorFlow Hub](https://tfhub.dev).\n",
+ "\n",
+ "A few featured examples:\n",
+ "\n",
+ "- [Retraining an Image Classifier](https://tensorflow.org/hub/tutorials/tf2_image_retraining): Build a Keras model on top of a pre-trained image classifier to distinguish flowers.\n",
+ "- [Text Classification](https://tensorflow.org/hub/tutorials/tf2_text_classification): Classify IMDB movie reviews as either *positive* or *negative*.\n",
+ "- [Style Transfer](https://tensorflow.org/hub/tutorials/tf2_arbitrary_image_stylization): Use deep learning to transfer style between images.\n",
+ "- [Multilingual Universal Sentence Encoder Q&A](https://tensorflow.org/hub/tutorials/retrieval_with_tf_hub_universal_encoder_qa): Use a machine learning model to answer questions from the SQuAD dataset.\n",
+ "- [Video Interpolation](https://tensorflow.org/hub/tutorials/tweening_conv3d): Predict what happened in a video between the first and the last frame.\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "colab": {
+ "name": "Making the Most of your Colab Subscription",
+ "provenance": [],
+ "history_visible": true,
+ "gpuType": "V100",
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "name": "python3"
+ },
+ "accelerator": "GPU"
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
\ No newline at end of file
From 18a80f91cbbbfbe93acea38415904dc0cb565b4b Mon Sep 17 00:00:00 2001
From: molgoo <140925388+molgoo@users.noreply.github.com>
Date: Tue, 15 Aug 2023 19:55:27 -0400
Subject: [PATCH 2/4] Update app.py
From colab
---
app.py | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/app.py b/app.py
index cde7c608..c22cfc30 100644
--- a/app.py
+++ b/app.py
@@ -1,3 +1,14 @@
+# !git clone https://github.com/alejandro-ao/ask-multiple-pdfs
+# !pip install -r ask-multiple-pdfs/requirements.txt
+# !streamlit run app.py (how to rin this app)
+# %load app.py in order to modify
+print ('hello')
+import os
+os.environ['OPENAI_API_KEY'] = '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'
+#with open('app.py', 'r+') as f: The next 3 lines load it to a colab cell
+# code_content = f.read()
+#print(code_content)
+import ipdb
import streamlit as st
from dotenv import load_dotenv
from PyPDF2 import PdfReader
@@ -66,6 +77,7 @@ def handle_userinput(user_question):
def main():
load_dotenv()
+ ipdb.set_trace()
st.set_page_config(page_title="Chat with multiple PDFs",
page_icon=":books:")
st.write(css, unsafe_allow_html=True)
@@ -99,6 +111,7 @@ def main():
st.session_state.conversation = get_conversation_chain(
vectorstore)
-
if __name__ == '__main__':
+ ipdb.set_trace()
main()
+ ipdb.set_trace()
From f7de90cfb1b32d880706f397985107622171012f Mon Sep 17 00:00:00 2001
From: molgoo <140925388+molgoo@users.noreply.github.com>
Date: Wed, 16 Aug 2023 01:56:53 +0000
Subject: [PATCH 3/4] sss
---
.env.example | 4 ++--
app.py | 7 ++-----
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/.env.example b/.env.example
index 8f8ccc65..2de1363b 100644
--- a/.env.example
+++ b/.env.example
@@ -1,2 +1,2 @@
-OPENAI_API_KEY=
-HUGGINGFACEHUB_API_TOKEN=
+OPENAI_API_KEY='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'
+HUGGINGFACEHUB_API_TOKEN='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'
diff --git a/app.py b/app.py
index c22cfc30..a67a4bf5 100644
--- a/app.py
+++ b/app.py
@@ -1,14 +1,14 @@
+import ipdb
# !git clone https://github.com/alejandro-ao/ask-multiple-pdfs
# !pip install -r ask-multiple-pdfs/requirements.txt
# !streamlit run app.py (how to rin this app)
# %load app.py in order to modify
-print ('hello')
import os
os.environ['OPENAI_API_KEY'] = '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'
#with open('app.py', 'r+') as f: The next 3 lines load it to a colab cell
# code_content = f.read()
#print(code_content)
-import ipdb
+
import streamlit as st
from dotenv import load_dotenv
from PyPDF2 import PdfReader
@@ -77,7 +77,6 @@ def handle_userinput(user_question):
def main():
load_dotenv()
- ipdb.set_trace()
st.set_page_config(page_title="Chat with multiple PDFs",
page_icon=":books:")
st.write(css, unsafe_allow_html=True)
@@ -112,6 +111,4 @@ def main():
vectorstore)
if __name__ == '__main__':
- ipdb.set_trace()
main()
- ipdb.set_trace()
From 739382ef4c75646898ba3834f37fe2b2682e3954 Mon Sep 17 00:00:00 2001
From: molgoo <140925388+molgoo@users.noreply.github.com>
Date: Wed, 16 Aug 2023 17:47:50 +0000
Subject: [PATCH 4/4] test
---
.env.example | 2 --
app.py | 10 ++++++----
2 files changed, 6 insertions(+), 6 deletions(-)
delete mode 100644 .env.example
diff --git a/.env.example b/.env.example
deleted file mode 100644
index 2de1363b..00000000
--- a/.env.example
+++ /dev/null
@@ -1,2 +0,0 @@
-OPENAI_API_KEY='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'
-HUGGINGFACEHUB_API_TOKEN='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'
diff --git a/app.py b/app.py
index a67a4bf5..c707340e 100644
--- a/app.py
+++ b/app.py
@@ -1,14 +1,16 @@
-import ipdb
+# import ipdb
# !git clone https://github.com/alejandro-ao/ask-multiple-pdfs
+# export PATH="/home/codespace/.local/lib/python3.10/site-packages/bin:$PATH"
# !pip install -r ask-multiple-pdfs/requirements.txt
# !streamlit run app.py (how to rin this app)
# %load app.py in order to modify
import os
-os.environ['OPENAI_API_KEY'] = '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'
+os.environ['OPENAI_API_KEY'] = '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'
#with open('app.py', 'r+') as f: The next 3 lines load it to a colab cell
# code_content = f.read()
#print(code_content)
-
+import langchain
+langchain.verbose = False
import streamlit as st
from dotenv import load_dotenv
from PyPDF2 import PdfReader
@@ -20,7 +22,7 @@
from langchain.chains import ConversationalRetrievalChain
from htmlTemplates import css, bot_template, user_template
from langchain.llms import HuggingFaceHub
-
+#OPENAI_API_KEY="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"
def get_pdf_text(pdf_docs):
text = ""
for pdf in pdf_docs: