Spaces:
Sleeping
Sleeping
Commit
·
d6cf0f0
1
Parent(s):
d17c60a
asdf
Browse files- app.py +9 -2
- requirements.txt +2 -2
- vercel.json +15 -1
app.py
CHANGED
|
@@ -6,8 +6,11 @@ from langchain.prompts import PromptTemplate
|
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
import os
|
| 8 |
|
| 9 |
-
# Load environment variables
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
# Initialize FastAPI app
|
| 13 |
app = FastAPI()
|
|
@@ -16,6 +19,10 @@ app = FastAPI()
|
|
| 16 |
class SearchQuery(BaseModel):
|
| 17 |
query: str
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Initialize LangChain with Groq
|
| 20 |
llm = ChatGroq(
|
| 21 |
temperature=0.7,
|
|
|
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
import os
|
| 8 |
|
| 9 |
+
# Load environment variables from .env file if it exists
|
| 10 |
+
try:
|
| 11 |
+
load_dotenv()
|
| 12 |
+
except:
|
| 13 |
+
pass # If .env doesn't exist (like in Vercel), continue without it
|
| 14 |
|
| 15 |
# Initialize FastAPI app
|
| 16 |
app = FastAPI()
|
|
|
|
| 19 |
class SearchQuery(BaseModel):
|
| 20 |
query: str
|
| 21 |
|
| 22 |
+
# Check if API key exists
|
| 23 |
+
if not os.getenv("GROQ_API_KEY"):
|
| 24 |
+
raise ValueError("GROQ_API_KEY environment variable is not set")
|
| 25 |
+
|
| 26 |
# Initialize LangChain with Groq
|
| 27 |
llm = ChatGroq(
|
| 28 |
temperature=0.7,
|
requirements.txt
CHANGED
|
@@ -2,5 +2,5 @@ fastapi
|
|
| 2 |
uvicorn
|
| 3 |
python-dotenv
|
| 4 |
langchain
|
| 5 |
-
|
| 6 |
-
pydantic
|
|
|
|
| 2 |
uvicorn
|
| 3 |
python-dotenv
|
| 4 |
langchain
|
| 5 |
+
langchain-groq
|
| 6 |
+
pydantic
|
vercel.json
CHANGED
|
@@ -1 +1,15 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"version": 2,
|
| 3 |
+
"builds": [
|
| 4 |
+
{
|
| 5 |
+
"src": "app.py",
|
| 6 |
+
"use": "@vercel/python"
|
| 7 |
+
}
|
| 8 |
+
],
|
| 9 |
+
"routes": [
|
| 10 |
+
{
|
| 11 |
+
"src": "/(.*)",
|
| 12 |
+
"dest": "app.py"
|
| 13 |
+
}
|
| 14 |
+
]
|
| 15 |
+
}
|