Spaces:
Paused
Paused
hanoch.rahimi@gmail commited on
Commit ·
45a7d81
1
Parent(s): 039a1fd
env variables fix
Browse files- .dockerignore +1 -2
- Dockerfile +5 -2
- README.md +5 -3
- app.py +9 -6
- resources/raized_logo.png +0 -0
- semsearch.pyproj +2 -1
- utils.py +10 -8
.dockerignore
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
.streamlit/
|
| 2 |
env/
|
| 3 |
-
.env
|
| 4 |
.git/
|
| 5 |
__pycache__/
|
| 6 |
obj/
|
| 7 |
-
data/
|
| 8 |
bin/
|
| 9 |
*pyproj*
|
|
|
|
| 1 |
.streamlit/
|
| 2 |
env/
|
| 3 |
+
.env/
|
| 4 |
.git/
|
| 5 |
__pycache__/
|
| 6 |
obj/
|
|
|
|
| 7 |
bin/
|
| 8 |
*pyproj*
|
Dockerfile
CHANGED
|
@@ -11,12 +11,15 @@ RUN apt-get update && apt-get install -y \
|
|
| 11 |
git \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
-
RUN git clone https://hanch-raized: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@github.com/hanch-raized/ml.git .
|
| 15 |
|
| 16 |
-
|
|
|
|
| 17 |
RUN pip3 install streamlit
|
| 18 |
#COPY .streamlit/secrets.toml /app/.streamlit/secrets.toml
|
| 19 |
|
|
|
|
|
|
|
| 20 |
EXPOSE 8501
|
| 21 |
|
| 22 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
|
|
|
| 11 |
git \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
+
#RUN git clone https://hanch-raized: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@github.com/hanch-raized/ml.git .
|
| 15 |
|
| 16 |
+
ADD ./requirements.txt /app/requirements.txt
|
| 17 |
+
RUN pip3 install -r ./requirements.txt
|
| 18 |
RUN pip3 install streamlit
|
| 19 |
#COPY .streamlit/secrets.toml /app/.streamlit/secrets.toml
|
| 20 |
|
| 21 |
+
COPY . .
|
| 22 |
+
|
| 23 |
EXPOSE 8501
|
| 24 |
|
| 25 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
README.md
CHANGED
|
@@ -9,10 +9,12 @@ app_file: app.py
|
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 13 |
-
|
| 14 |
Build Docker:
|
| 15 |
-
docker build -t
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
## deploy container on GCP:
|
| 18 |
### First time
|
|
|
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
|
|
|
|
|
|
| 12 |
Build Docker:
|
| 13 |
+
docker build --no-cache -t semsearchdemo .
|
| 14 |
+
|
| 15 |
+
Run docker onport 8601
|
| 16 |
+
docker run -dp 8601:8601 semsearchdemo
|
| 17 |
+
docker run -dp 8601:8601 --env-file .env semsearchdemo
|
| 18 |
|
| 19 |
## deploy container on GCP:
|
| 20 |
### First time
|
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import json
|
| 2 |
|
|
|
|
| 3 |
from langchain.chains import RetrievalQA
|
| 4 |
from langchain.embeddings.openai import OpenAIEmbeddings
|
| 5 |
from langchain.prompts import PromptTemplate
|
|
@@ -13,6 +14,14 @@ from sentence_transformers import SentenceTransformer
|
|
| 13 |
|
| 14 |
import streamlit.components.v1 as components
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
import utils
|
| 17 |
import openai_utils as oai
|
| 18 |
|
|
@@ -29,12 +38,6 @@ from streamlit_extras.stylable_container import stylable_container
|
|
| 29 |
|
| 30 |
#"🤖",
|
| 31 |
|
| 32 |
-
st.set_page_config(
|
| 33 |
-
layout="wide",
|
| 34 |
-
initial_sidebar_state="collapsed",
|
| 35 |
-
page_title="RaizedAI Startup Discovery Assistant",
|
| 36 |
-
#page_icon=":robot:"
|
| 37 |
-
)
|
| 38 |
|
| 39 |
COUNTRIES_FN="data/countries.csv"
|
| 40 |
country_geo = pd.read_csv(COUNTRIES_FN)
|
|
|
|
| 1 |
import json
|
| 2 |
|
| 3 |
+
|
| 4 |
from langchain.chains import RetrievalQA
|
| 5 |
from langchain.embeddings.openai import OpenAIEmbeddings
|
| 6 |
from langchain.prompts import PromptTemplate
|
|
|
|
| 14 |
|
| 15 |
import streamlit.components.v1 as components
|
| 16 |
|
| 17 |
+
st.set_page_config(
|
| 18 |
+
layout="wide",
|
| 19 |
+
initial_sidebar_state="collapsed",
|
| 20 |
+
page_title="RaizedAI Startup Discovery Assistant",
|
| 21 |
+
#page_icon=":robot:"
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
import utils
|
| 26 |
import openai_utils as oai
|
| 27 |
|
|
|
|
| 38 |
|
| 39 |
#"🤖",
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
COUNTRIES_FN="data/countries.csv"
|
| 43 |
country_geo = pd.read_csv(COUNTRIES_FN)
|
resources/raized_logo.png
ADDED
|
semsearch.pyproj
CHANGED
|
@@ -12,7 +12,7 @@
|
|
| 12 |
<ProjectTypeGuids>{e614c764-6d9e-4607-9337-b7073809a0bd};{1b580a1a-fdb3-4b32-83e1-6407eb2722e6};{349c5851-65df-11da-9384-00065b846f21};{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
|
| 13 |
<LaunchProvider>Web launcher</LaunchProvider>
|
| 14 |
<InterpreterId>MSBuild|env|$(MSBuildProjectFullPath)</InterpreterId>
|
| 15 |
-
<WebBrowserUrl>http://localhost</WebBrowserUrl>
|
| 16 |
<PythonDebugWebServerCommandArguments> -m streamlit.cli run app.py --debug $(CommandLineArguments)</PythonDebugWebServerCommandArguments>
|
| 17 |
<PythonWsgiHandler>{StartupModule}.wsgi_app()</PythonWsgiHandler>
|
| 18 |
<PythonRunWebServerCommand>
|
|
@@ -30,6 +30,7 @@
|
|
| 30 |
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
|
| 31 |
</PropertyGroup>
|
| 32 |
<ItemGroup>
|
|
|
|
| 33 |
<Content Include=".gitignore" />
|
| 34 |
<Content Include=".streamlit\secrets.toml" />
|
| 35 |
<Content Include="Dockerfile" />
|
|
|
|
| 12 |
<ProjectTypeGuids>{e614c764-6d9e-4607-9337-b7073809a0bd};{1b580a1a-fdb3-4b32-83e1-6407eb2722e6};{349c5851-65df-11da-9384-00065b846f21};{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
|
| 13 |
<LaunchProvider>Web launcher</LaunchProvider>
|
| 14 |
<InterpreterId>MSBuild|env|$(MSBuildProjectFullPath)</InterpreterId>
|
| 15 |
+
<WebBrowserUrl>http://localhost:8501</WebBrowserUrl>
|
| 16 |
<PythonDebugWebServerCommandArguments> -m streamlit.cli run app.py --debug $(CommandLineArguments)</PythonDebugWebServerCommandArguments>
|
| 17 |
<PythonWsgiHandler>{StartupModule}.wsgi_app()</PythonWsgiHandler>
|
| 18 |
<PythonRunWebServerCommand>
|
|
|
|
| 30 |
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
|
| 31 |
</PropertyGroup>
|
| 32 |
<ItemGroup>
|
| 33 |
+
<Content Include=".env" />
|
| 34 |
<Content Include=".gitignore" />
|
| 35 |
<Content Include=".streamlit\secrets.toml" />
|
| 36 |
<Content Include="Dockerfile" />
|
utils.py
CHANGED
|
@@ -10,16 +10,18 @@ import psycopg2
|
|
| 10 |
from psycopg2 import extras
|
| 11 |
import streamlit as st
|
| 12 |
|
| 13 |
-
|
| 14 |
# gcp_client = secretmanager.SecretManagerServiceClient()
|
| 15 |
# response = gcp_client.access_secret_version(request={"name": version.name})
|
| 16 |
|
| 17 |
def get_variable(name):
|
| 18 |
-
res =
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
return res
|
| 24 |
|
| 25 |
OPENAI_API_KEY = get_variable("OPENAI_API_KEY") # app.pinecone.io
|
|
@@ -117,12 +119,12 @@ def search_index(query, top_k, regions, countries, retriever, index_namespace):
|
|
| 117 |
def check_password():
|
| 118 |
"""Returns `True` if the user had the correct password."""
|
| 119 |
|
| 120 |
-
if
|
| 121 |
return True
|
| 122 |
|
| 123 |
def password_entered():
|
| 124 |
"""Checks whether a password entered by the user is correct."""
|
| 125 |
-
if st.session_state["password"] ==
|
| 126 |
st.session_state["password_correct"] = True
|
| 127 |
del st.session_state["password"] # don't store password
|
| 128 |
else:
|
|
|
|
| 10 |
from psycopg2 import extras
|
| 11 |
import streamlit as st
|
| 12 |
|
| 13 |
+
print(f"openai-key{os.getenv('OPENAI_API_KEY')}")
|
| 14 |
# gcp_client = secretmanager.SecretManagerServiceClient()
|
| 15 |
# response = gcp_client.access_secret_version(request={"name": version.name})
|
| 16 |
|
| 17 |
def get_variable(name):
|
| 18 |
+
res = os.getenv(name)
|
| 19 |
+
if not res:
|
| 20 |
+
try:
|
| 21 |
+
res = st.secrets[name]
|
| 22 |
+
except Exception as e:
|
| 23 |
+
pass
|
| 24 |
+
print(f"Got var {name}: {res}")
|
| 25 |
return res
|
| 26 |
|
| 27 |
OPENAI_API_KEY = get_variable("OPENAI_API_KEY") # app.pinecone.io
|
|
|
|
| 119 |
def check_password():
|
| 120 |
"""Returns `True` if the user had the correct password."""
|
| 121 |
|
| 122 |
+
if get_variable('SKIP_PASSWORD')=="True":
|
| 123 |
return True
|
| 124 |
|
| 125 |
def password_entered():
|
| 126 |
"""Checks whether a password entered by the user is correct."""
|
| 127 |
+
if st.session_state["password"] == get_variable("password"):
|
| 128 |
st.session_state["password_correct"] = True
|
| 129 |
del st.session_state["password"] # don't store password
|
| 130 |
else:
|