fix embedding
Browse files- app/embedding.py +1 -1
- app/main.py +8 -5
app/embedding.py
CHANGED
|
@@ -49,7 +49,7 @@ class EmbeddingClient:
|
|
| 49 |
)
|
| 50 |
response.raise_for_status()
|
| 51 |
data = response.json()
|
| 52 |
-
logger.info(f"[DEBUG] Embedding API response: {data[:10]}...{data[-10:]}")
|
| 53 |
return data["embedding"]
|
| 54 |
except Exception as e:
|
| 55 |
logger.error(f"Error creating embedding: {e}")
|
|
|
|
| 49 |
)
|
| 50 |
response.raise_for_status()
|
| 51 |
data = response.json()
|
| 52 |
+
logger.info(f"[DEBUG] Embedding API response: {data['embedding'][:10]}...{data['embedding'][-10:]}")
|
| 53 |
return data["embedding"]
|
| 54 |
except Exception as e:
|
| 55 |
logger.error(f"Error creating embedding: {e}")
|
app/main.py
CHANGED
|
@@ -113,15 +113,18 @@ async def webhook(request: Request):
|
|
| 113 |
and "entry" in body
|
| 114 |
and isinstance(body["entry"], list)
|
| 115 |
and len(body["entry"]) > 0
|
| 116 |
-
and
|
| 117 |
-
and body["entry"][0]
|
|
|
|
|
|
|
| 118 |
)
|
| 119 |
if is_echo:
|
| 120 |
logger.info(f"[DEBUG] Message is echo, skipping...")
|
| 121 |
return {"status": "ok"}
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
| 125 |
if not message_data:
|
| 126 |
return {"status": "ok"}
|
| 127 |
|
|
|
|
| 113 |
and "entry" in body
|
| 114 |
and isinstance(body["entry"], list)
|
| 115 |
and len(body["entry"]) > 0
|
| 116 |
+
and "messaging" in body["entry"][0]
|
| 117 |
+
and isinstance(body["entry"][0]["messaging"], list)
|
| 118 |
+
and len(body["entry"][0]["messaging"]) > 0
|
| 119 |
+
and body["entry"][0]["messaging"][0].get("message", {}).get("is_echo", False)
|
| 120 |
)
|
| 121 |
if is_echo:
|
| 122 |
logger.info(f"[DEBUG] Message is echo, skipping...")
|
| 123 |
return {"status": "ok"}
|
| 124 |
+
else:
|
| 125 |
+
message_data = facebook_client.parse_message(body)
|
| 126 |
+
logger.info(f"[DEBUG] message_data: {message_data}")
|
| 127 |
+
|
| 128 |
if not message_data:
|
| 129 |
return {"status": "ok"}
|
| 130 |
|