Spaces:
Sleeping
Sleeping
anmolsahai
commited on
Commit
•
f1155da
1
Parent(s):
3b863e1
ript
Browse files- app.py +0 -5
- langchain_pipeline.py +9 -5
- requirements.txt +3 -3
app.py
CHANGED
@@ -8,11 +8,6 @@ from docx.shared import RGBColor
|
|
8 |
import re
|
9 |
import subprocess
|
10 |
import os
|
11 |
-
import json
|
12 |
-
|
13 |
-
# Load Google Cloud credentials from the file
|
14 |
-
credentials_path = "/mnt/data/Composure IAM Admin.json"
|
15 |
-
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credentials_path
|
16 |
|
17 |
def pdf_to_text_with_layout(pdf_file):
|
18 |
doc = fitz.open(stream=pdf_file.read(), filetype="pdf")
|
|
|
8 |
import re
|
9 |
import subprocess
|
10 |
import os
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def pdf_to_text_with_layout(pdf_file):
|
13 |
doc = fitz.open(stream=pdf_file.read(), filetype="pdf")
|
langchain_pipeline.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import os
|
2 |
import requests
|
|
|
|
|
3 |
from pdfminer import high_level
|
4 |
from langchain_astradb import AstraDBVectorStore
|
5 |
from langchain_core.prompts import PromptTemplate
|
@@ -7,12 +9,14 @@ from langchain_openai import OpenAIEmbeddings
|
|
7 |
from langchain_anthropic import ChatAnthropic
|
8 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
9 |
import base64
|
10 |
-
import
|
11 |
|
12 |
-
# Load Google Cloud credentials from the
|
13 |
-
|
14 |
-
|
15 |
-
credentials = json.
|
|
|
|
|
16 |
|
17 |
def get_access_token():
|
18 |
# Request an access token using the service account credentials
|
|
|
1 |
import os
|
2 |
import requests
|
3 |
+
import json
|
4 |
+
import time
|
5 |
from pdfminer import high_level
|
6 |
from langchain_astradb import AstraDBVectorStore
|
7 |
from langchain_core.prompts import PromptTemplate
|
|
|
9 |
from langchain_anthropic import ChatAnthropic
|
10 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
11 |
import base64
|
12 |
+
import jwt # Add PyJWT to your requirements
|
13 |
|
14 |
+
# Load Google Cloud credentials from the environment variable
|
15 |
+
credentials_json = os.getenv('GOOGLE_APPLICATION_CREDENTIALS_JSON')
|
16 |
+
if credentials_json:
|
17 |
+
credentials = json.loads(credentials_json)
|
18 |
+
else:
|
19 |
+
raise ValueError("GOOGLE_APPLICATION_CREDENTIALS_JSON environment variable not set")
|
20 |
|
21 |
def get_access_token():
|
22 |
# Request an access token using the service account credentials
|
requirements.txt
CHANGED
@@ -4,11 +4,11 @@ python-docx
|
|
4 |
google-auth
|
5 |
google-auth-oauthlib
|
6 |
google-auth-httplib2
|
7 |
-
|
8 |
-
google-cloud-aiplatform
|
9 |
langchain-core
|
10 |
langchain-astradb
|
11 |
langchain-openai
|
12 |
langchain-anthropic
|
13 |
langchain-google-genai
|
14 |
-
docxcompose
|
|
|
|
4 |
google-auth
|
5 |
google-auth-oauthlib
|
6 |
google-auth-httplib2
|
7 |
+
requests
|
|
|
8 |
langchain-core
|
9 |
langchain-astradb
|
10 |
langchain-openai
|
11 |
langchain-anthropic
|
12 |
langchain-google-genai
|
13 |
+
docxcompose
|
14 |
+
pyjwt
|