Spaces:
Sleeping
Sleeping
Commit
·
212b42a
1
Parent(s):
b1cee42
add parent dir path to support running main locally
Browse files- app/main.py +11 -0
app/main.py
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from langchain_core.runnables import Runnable
|
| 2 |
from langchain_core.callbacks import BaseCallbackHandler
|
| 3 |
from fastapi import FastAPI, Request, Depends
|
|
@@ -81,6 +84,14 @@ async def simple_stream(request: Request):
|
|
| 81 |
# raise NotImplemented
|
| 82 |
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
if __name__ == "__main__":
|
| 86 |
import uvicorn
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
from langchain_core.runnables import Runnable
|
| 5 |
from langchain_core.callbacks import BaseCallbackHandler
|
| 6 |
from fastapi import FastAPI, Request, Depends
|
|
|
|
| 84 |
# raise NotImplemented
|
| 85 |
|
| 86 |
|
| 87 |
+
# Run From the Parent Directory with Script
|
| 88 |
+
# If you want to use uvicorn.run from within a script using "app.main:app",
|
| 89 |
+
# you need to provide the proper path. In this way no matter you run the code
|
| 90 |
+
# locally or on the huggingface space, you will alwazs use "app.main:app" as
|
| 91 |
+
# input argument in the uvicorn.run
|
| 92 |
+
|
| 93 |
+
# Add the parent directory to sys.path
|
| 94 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 95 |
|
| 96 |
if __name__ == "__main__":
|
| 97 |
import uvicorn
|