Spaces:
Sleeping
Sleeping
JerameeUC commited on
Commit ·
aa2c39f
1
Parent(s): 9e1932d
5th commit More cleanup
Browse files- app/assets/html/agenticcore_frontend.html +1 -0
- app/assets/html/chat.html +1 -0
- app/assets/html/chat_console.html +1 -0
- app/assets/html/chat_minimal.html +1 -0
- app/mbf_bot/bot.py +1 -1
- app/mbf_bot/skills.py +1 -1
- app/routes.py +72 -1
- docs/DEV_DOC.md +1 -1
- docs/results.md +1 -1
- tests/test_guardrails.py +1 -0
app/assets/html/agenticcore_frontend.html
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
<!doctype html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
|
|
|
| 1 |
+
<!-- /app/assets/html/agenticcore_frontend.html -->
|
| 2 |
<!doctype html>
|
| 3 |
<html lang="en">
|
| 4 |
<head>
|
app/assets/html/chat.html
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
<!doctype html>
|
| 2 |
<html><head><meta charset="utf-8"/><title>Simple Chat</title>
|
| 3 |
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
|
|
|
| 1 |
+
<!-- /app/assets/html/chat.html -->
|
| 2 |
<!doctype html>
|
| 3 |
<html><head><meta charset="utf-8"/><title>Simple Chat</title>
|
| 4 |
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
app/assets/html/chat_console.html
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
<!doctype html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
|
|
|
| 1 |
+
<!-- /app/assets/html/chat_console.html -->
|
| 2 |
<!doctype html>
|
| 3 |
<html lang="en">
|
| 4 |
<head>
|
app/assets/html/chat_minimal.html
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
<!doctype html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
|
|
|
| 1 |
+
<!-- /app/assets/html/chat_minimal.html -->
|
| 2 |
<!doctype html>
|
| 3 |
<html lang="en">
|
| 4 |
<head>
|
app/mbf_bot/bot.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# bot.py
|
| 2 |
"""
|
| 3 |
Simple MBF bot:
|
| 4 |
- 'help' / 'capabilities' shows features
|
|
|
|
| 1 |
+
# /app/bot.py
|
| 2 |
"""
|
| 3 |
Simple MBF bot:
|
| 4 |
- 'help' / 'capabilities' shows features
|
app/mbf_bot/skills.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# skills.py
|
| 2 |
"""
|
| 3 |
Small, dependency-free helpers used by the MBF SimpleBot.
|
| 4 |
"""
|
|
|
|
| 1 |
+
# /app/skills.py
|
| 2 |
"""
|
| 3 |
Small, dependency-free helpers used by the MBF SimpleBot.
|
| 4 |
"""
|
app/routes.py
CHANGED
|
@@ -1 +1,72 @@
|
|
| 1 |
-
# /app/routes.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# /app/routes.py — HTTP handlers
|
| 2 |
+
import json
|
| 3 |
+
from aiohttp import web
|
| 4 |
+
from botbuilder.core import TurnContext
|
| 5 |
+
from botbuilder.schema import Activity
|
| 6 |
+
|
| 7 |
+
# Prefer project logic if available
|
| 8 |
+
try:
|
| 9 |
+
from logic import handle_text as _handle_text
|
| 10 |
+
except Exception:
|
| 11 |
+
from skills import normalize, reverse_text, is_empty
|
| 12 |
+
def _handle_text(user_text: str) -> str:
|
| 13 |
+
text = (user_text or "").strip()
|
| 14 |
+
if not text:
|
| 15 |
+
return "Please provide text."
|
| 16 |
+
cmd = normalize(text)
|
| 17 |
+
if cmd in {"help", "capabilities"}:
|
| 18 |
+
return "Try: reverse <text> | or just say anything"
|
| 19 |
+
if cmd.startswith("reverse "):
|
| 20 |
+
original = text.split(" ", 1)[1] if " " in text else ""
|
| 21 |
+
return reverse_text(original)
|
| 22 |
+
return f"You said: {text}"
|
| 23 |
+
|
| 24 |
+
def init_routes(app: web.Application, adapter, bot) -> None:
|
| 25 |
+
async def messages(req: web.Request) -> web.Response:
|
| 26 |
+
ctype = (req.headers.get("Content-Type") or "").lower()
|
| 27 |
+
if "application/json" not in ctype:
|
| 28 |
+
return web.Response(status=415, text="Unsupported Media Type: expected application/json")
|
| 29 |
+
try:
|
| 30 |
+
body = await req.json()
|
| 31 |
+
except json.JSONDecodeError:
|
| 32 |
+
return web.Response(status=400, text="Invalid JSON body")
|
| 33 |
+
|
| 34 |
+
activity = Activity().deserialize(body)
|
| 35 |
+
auth_header = req.headers.get("Authorization")
|
| 36 |
+
|
| 37 |
+
invoke_response = await adapter.process_activity(activity, auth_header, bot.on_turn)
|
| 38 |
+
if invoke_response:
|
| 39 |
+
return web.json_response(data=invoke_response.body, status=invoke_response.status)
|
| 40 |
+
return web.Response(status=202, text="Accepted")
|
| 41 |
+
|
| 42 |
+
async def messages_get(_req: web.Request) -> web.Response:
|
| 43 |
+
return web.Response(
|
| 44 |
+
text="This endpoint only accepts POST (Bot Framework activities).",
|
| 45 |
+
content_type="text/plain",
|
| 46 |
+
status=405
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
async def home(_req: web.Request) -> web.Response:
|
| 50 |
+
return web.Response(
|
| 51 |
+
text="Bot is running. POST Bot Framework activities to /api/messages.",
|
| 52 |
+
content_type="text/plain"
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
async def healthz(_req: web.Request) -> web.Response:
|
| 56 |
+
return web.json_response({"status": "ok"})
|
| 57 |
+
|
| 58 |
+
async def plain_chat(req: web.Request) -> web.Response:
|
| 59 |
+
try:
|
| 60 |
+
payload = await req.json()
|
| 61 |
+
except Exception:
|
| 62 |
+
return web.json_response({"error": "Invalid JSON"}, status=400)
|
| 63 |
+
user_text = payload.get("text", "")
|
| 64 |
+
reply = _handle_text(user_text)
|
| 65 |
+
return web.json_response({"reply": reply})
|
| 66 |
+
|
| 67 |
+
# Wire routes
|
| 68 |
+
app.router.add_get("/", home)
|
| 69 |
+
app.router.add_get("/healthz", healthz)
|
| 70 |
+
app.router.add_get("/api/messages", messages_get)
|
| 71 |
+
app.router.add_post("/api/messages", messages)
|
| 72 |
+
app.router.add_post("/plain-chat", plain_chat)
|
docs/DEV_DOC.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
<!-- /docs/DEV_DOC.md -->
|
| 2 |
|
| 3 |
## 3. Functional Requirements
|
| 4 |
|
|
|
|
| 1 |
+
<!-- /docs/slides/DEV_DOC.md -->
|
| 2 |
|
| 3 |
## 3. Functional Requirements
|
| 4 |
|
docs/results.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
|
| 2 |
# Results\n\nChallenges, metrics, screenshots.\n
|
|
|
|
| 1 |
+
<!-- /docs/slides/results.md -->
|
| 2 |
# Results\n\nChallenges, metrics, screenshots.\n
|
tests/test_guardrails.py
CHANGED
|
@@ -1 +1,2 @@
|
|
|
|
|
| 1 |
def test_guardrails_stub(): assert True
|
|
|
|
| 1 |
+
# /test/test_guardrails.py
|
| 2 |
def test_guardrails_stub(): assert True
|