Update app.py
Browse files
app.py
CHANGED
|
@@ -19,6 +19,8 @@ from langchain_core.prompts import PromptTemplate
|
|
| 19 |
from langchain.memory.buffer import ConversationBufferMemory
|
| 20 |
|
| 21 |
|
|
|
|
|
|
|
| 22 |
load_dotenv()
|
| 23 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 24 |
auth_token = os.environ.get("DAYSOFF_API_TOKEN")
|
|
@@ -66,6 +68,12 @@ async def async_post_request(url, headers, data):
|
|
| 66 |
except requests.RequestException as e:
|
| 67 |
raise APIResponseError(f"API request failed: {str(e)}")
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
@cl.set_starters
|
| 70 |
async def set_starters():
|
| 71 |
return [
|
|
|
|
| 19 |
from langchain.memory.buffer import ConversationBufferMemory
|
| 20 |
|
| 21 |
|
| 22 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 23 |
+
|
| 24 |
load_dotenv()
|
| 25 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 26 |
auth_token = os.environ.get("DAYSOFF_API_TOKEN")
|
|
|
|
| 68 |
except requests.RequestException as e:
|
| 69 |
raise APIResponseError(f"API request failed: {str(e)}")
|
| 70 |
|
| 71 |
+
|
| 72 |
+
async def long_running_task():
|
| 73 |
+
loop = asyncio.get_running_loop()
|
| 74 |
+
with ThreadPoolExecutor() as pool:
|
| 75 |
+
return await loop.run_in_executor(pool, your_function)
|
| 76 |
+
|
| 77 |
@cl.set_starters
|
| 78 |
async def set_starters():
|
| 79 |
return [
|