Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -28,8 +28,6 @@ from langchain.memory.buffer import ConversationBufferMemory
|
|
28 |
load_dotenv()
|
29 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
30 |
auth_token = os.environ.get("CHAINLIT_AUTH_SECRET")
|
31 |
-
if not auth_token.startswith("Bearer "):
|
32 |
-
auth_token = f"Bearer {auth_token}"
|
33 |
|
34 |
# API endpoint
|
35 |
API_URL = "https://aivisions.no/data/daysoff/api/v1/booking/"
|
@@ -120,6 +118,9 @@ async def handle_message(message: cl.Message):
|
|
120 |
except requests.exceptions.RequestException as e:
|
121 |
await cl.Message(content=f"Request failed: {str(e)}").send()
|
122 |
else:
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
28 |
load_dotenv()
|
29 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
30 |
auth_token = os.environ.get("CHAINLIT_AUTH_SECRET")
|
|
|
|
|
31 |
|
32 |
# API endpoint
|
33 |
API_URL = "https://aivisions.no/data/daysoff/api/v1/booking/"
|
|
|
118 |
except requests.exceptions.RequestException as e:
|
119 |
await cl.Message(content=f"Request failed: {str(e)}").send()
|
120 |
else:
|
121 |
+
response = await llm_chain.ainvoke(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
|
122 |
+
|
123 |
+
|
124 |
+
response_key = "output" if "output" in response else "text"
|
125 |
+
await cl.Message(response.get(response_key, "")).send()
|
126 |
+
return message.content
|