Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
from nostr_sdk import Client, NostrSigner, Keys, Event, UnsignedEvent, Filter, \
|
2 |
HandleNotification, Timestamp, nip04_decrypt, UnwrappedGift, init_logger, LogLevel, Kind, KindEnum
|
3 |
import time
|
|
|
|
|
|
|
4 |
|
5 |
keys = Keys.parse("nsec1zrl5ahr9hy43vwns0r423c0crtv45myjgelf6gf2kl8ae90x9nkqex90cg")
|
6 |
|
@@ -28,7 +31,12 @@ class NotificationHandler(HandleNotification):
|
|
28 |
try:
|
29 |
msg = nip04_decrypt(sk, event.author(), event.content())
|
30 |
print(f"Received new msg: {msg}")
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
32 |
except Exception as e:
|
33 |
print(f"Error during content NIP04 decryption: {e}")
|
34 |
|
|
|
1 |
from nostr_sdk import Client, NostrSigner, Keys, Event, UnsignedEvent, Filter, \
|
2 |
HandleNotification, Timestamp, nip04_decrypt, UnwrappedGift, init_logger, LogLevel, Kind, KindEnum
|
3 |
import time
|
4 |
+
from gradio_client import Client as gClient
|
5 |
+
|
6 |
+
gclient = gClient("Gyr0MAN/AlbiziaChat")
|
7 |
|
8 |
keys = Keys.parse("nsec1zrl5ahr9hy43vwns0r423c0crtv45myjgelf6gf2kl8ae90x9nkqex90cg")
|
9 |
|
|
|
31 |
try:
|
32 |
msg = nip04_decrypt(sk, event.author(), event.content())
|
33 |
print(f"Received new msg: {msg}")
|
34 |
+
result = client.predict(
|
35 |
+
message=msg,
|
36 |
+
api_name="/chat"
|
37 |
+
)
|
38 |
+
|
39 |
+
client.send_direct_msg(event.author(), f"{result}", event.id())
|
40 |
except Exception as e:
|
41 |
print(f"Error during content NIP04 decryption: {e}")
|
42 |
|