File size: 1,507 Bytes
97a6c2a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# /// script
# requires-python = ">=3.10"
# dependencies = [
#     "marimo",
#     "requests",
# ]
# ///

import marimo

__generated_with = "0.9.0"
app = marimo.App()


@app.cell
def _():
    import marimo as mo
    import requests
    return mo, requests


@app.cell
def _(mo):
    mo.md("# πŸ¦€ VerdantClaw Chat")
    mo.md("**Simple chat with ZeroClaw**")
    mo.md("---")
    return


@app.cell
def _(mo, requests):
    """Simple working chat"""
    mo.md("### πŸ’¬ Chat")
    
    # Message input
    msg = mo.ui.text(
        label="",
        placeholder="Type your message..."
    )
    
    # Send button
    send = mo.ui.run_button(label="Send")
    
    # Display input and button
    mo.hstack([msg, send])
    
    msg, send
    return msg, send


@app.cell
def _(mo, requests, msg, send):
    """Process message"""
    if send.value and msg.value:
        try:
            response = requests.post(
                "http://localhost:42617/webhook",
                json={"message": msg.value},
                timeout=120
            )
            
            if response.status_code == 200:
                result = response.json()
                mo.md(f"**βœ… Response:** {result.get('response', 'No response')}")
            else:
                mo.md(f"❌ Error {response.status_code}: {response.text}")
        except Exception as e:
            mo.md(f"❌ Error: {e}")
    else:
        mo.md("*Type a message and click Send*")
    return


if __name__ == "__main__":
    app.run()