Spaces:
Sleeping
Sleeping
Handle installatio of custom .whl
Browse filesHuggingFace Spaces loads the requirements.txt before loading the entire app directory. That's why the installation of the custom .whl needs to be handled at runtime.
- app.py +21 -6
- requirements.txt +0 -1
app.py
CHANGED
@@ -1,20 +1,35 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
from dotenv import load_dotenv
|
3 |
|
4 |
-
from cv_assistant.agent import Agent
|
5 |
-
|
6 |
load_dotenv()
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
)
|
|
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
def answer(query):
|
15 |
return agent.answer(query=query)
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
description = """
|
19 |
### Ask about my experience, skills, and education!
|
20 |
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
import gradio as gr
|
4 |
+
import pkg_resources
|
5 |
from dotenv import load_dotenv
|
6 |
|
|
|
|
|
7 |
load_dotenv()
|
8 |
|
9 |
+
|
10 |
+
def package_installed(package_name):
|
11 |
+
try:
|
12 |
+
pkg_resources.get_distribution(package_name)
|
13 |
+
except pkg_resources.DistributionNotFound:
|
14 |
+
return False
|
15 |
+
else:
|
16 |
+
return True
|
17 |
|
18 |
|
19 |
def answer(query):
|
20 |
return agent.answer(query=query)
|
21 |
|
22 |
|
23 |
+
if not package_installed("cv_assistant"):
|
24 |
+
os.system("pip install cv_assistant-0.1-py2.py3-none-any.whl")
|
25 |
+
|
26 |
+
from cv_assistant.agent import Agent
|
27 |
+
|
28 |
+
agent = Agent(
|
29 |
+
faiss_index_path="./content_assets/docs.index",
|
30 |
+
faise_store_path="./content_assets/faiss_store.pkl",
|
31 |
+
)
|
32 |
+
|
33 |
description = """
|
34 |
### Ask about my experience, skills, and education!
|
35 |
|
requirements.txt
CHANGED
@@ -3,4 +3,3 @@ langchain==0.0.125
|
|
3 |
openai==0.27.2
|
4 |
python-dotenv==1.0.0
|
5 |
transformers==4.24.0
|
6 |
-
/home/user/app/cv_assistant-0.1-py2.py3-none-any.whl
|
|
|
3 |
openai==0.27.2
|
4 |
python-dotenv==1.0.0
|
5 |
transformers==4.24.0
|
|