Spaces:
Runtime error
Runtime error
Commit
·
77bbd4b
1
Parent(s):
682aa43
build: debug hf deployment
Browse files- Dockerfile +1 -0
- src/chains/design_rag.py +13 -2
Dockerfile
CHANGED
|
@@ -11,6 +11,7 @@ ENV HOME=/home/user \
|
|
| 11 |
PATH=/home/user/.local/bin:$PATH
|
| 12 |
|
| 13 |
ENV UVICORN_WS_PROTOCOL=websockets
|
|
|
|
| 14 |
|
| 15 |
# Set the working directory
|
| 16 |
WORKDIR $HOME/app
|
|
|
|
| 11 |
PATH=/home/user/.local/bin:$PATH
|
| 12 |
|
| 13 |
ENV UVICORN_WS_PROTOCOL=websockets
|
| 14 |
+
ENV PYTHONPATH=/app
|
| 15 |
|
| 16 |
# Set the working directory
|
| 17 |
WORKDIR $HOME/app
|
src/chains/design_rag.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from langchain_core.runnables import RunnablePassthrough
|
| 2 |
from langchain_core.output_parsers import StrOutputParser
|
| 3 |
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
|
|
|
|
| 4 |
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
from langchain.prompts import ChatPromptTemplate
|
|
@@ -11,8 +12,18 @@ from langchain_core.documents import Document
|
|
| 11 |
|
| 12 |
class DesignRAG:
|
| 13 |
def __init__(self):
|
| 14 |
-
#
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# Load design data and create vector store
|
| 18 |
self.vector_store = self._create_vector_store()
|
|
|
|
| 1 |
from langchain_core.runnables import RunnablePassthrough
|
| 2 |
from langchain_core.output_parsers import StrOutputParser
|
| 3 |
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
from langchain_community.vectorstores import FAISS
|
| 7 |
from langchain.prompts import ChatPromptTemplate
|
|
|
|
| 12 |
|
| 13 |
class DesignRAG:
|
| 14 |
def __init__(self):
|
| 15 |
+
# Get API key from environment
|
| 16 |
+
api_key = os.getenv("OPENAI_API_KEY")
|
| 17 |
+
if not api_key:
|
| 18 |
+
raise ValueError(
|
| 19 |
+
"OPENAI_API_KEY environment variable not set. "
|
| 20 |
+
"Please set it in HuggingFace Spaces settings."
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Initialize embedding model with explicit API key
|
| 24 |
+
self.embeddings = OpenAIEmbeddings(
|
| 25 |
+
openai_api_key=api_key
|
| 26 |
+
)
|
| 27 |
|
| 28 |
# Load design data and create vector store
|
| 29 |
self.vector_store = self._create_vector_store()
|