mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-09-29 21:53:20 +02:00
fixes
This commit is contained in:
@@ -31,7 +31,7 @@ class DVMTaskInterface:
|
|||||||
admin_config: AdminConfig
|
admin_config: AdminConfig
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|
||||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config,
|
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
|
||||||
admin_config: AdminConfig = None,
|
admin_config: AdminConfig = None,
|
||||||
options=None, task=None):
|
options=None, task=None):
|
||||||
self.init(name, dvm_config, admin_config, nip88config, nip89config, task)
|
self.init(name, dvm_config, admin_config, nip88config, nip89config, task)
|
||||||
@@ -59,7 +59,7 @@ class DVMTaskInterface:
|
|||||||
dvm_config.NIP89 = self.NIP89_announcement(nip89config)
|
dvm_config.NIP89 = self.NIP89_announcement(nip89config)
|
||||||
|
|
||||||
if nip88config is None:
|
if nip88config is None:
|
||||||
dvm_config.NIP88 = NIP88Config()
|
dvm_config.NIP88 = None
|
||||||
else:
|
else:
|
||||||
dvm_config.NIP88 = nip88config
|
dvm_config.NIP88 = nip88config
|
||||||
|
|
||||||
|
@@ -165,7 +165,7 @@ def build_example(name, identifier, admin_config):
|
|||||||
# Add NIP89
|
# Add NIP89
|
||||||
nip89info = {
|
nip89info = {
|
||||||
"name": name,
|
"name": name,
|
||||||
"image": "https://image.nostr.build/a99ab925084029d9468fef8330ff3d9be2cf67da473b024f2a6d48b5cd77197f.jpg",
|
"image": "https://nostr.band/android-chrome-192x192.png",
|
||||||
"about": "I search notes on Nostr.band.",
|
"about": "I search notes on Nostr.band.",
|
||||||
"encryptionSupported": True,
|
"encryptionSupported": True,
|
||||||
"cashuAccepted": True,
|
"cashuAccepted": True,
|
||||||
|
@@ -97,6 +97,7 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
|
|||||||
# Query events from database
|
# Query events from database
|
||||||
timestamp_hour_ago = Timestamp.now().as_secs() - 3600
|
timestamp_hour_ago = Timestamp.now().as_secs() - 3600
|
||||||
lasthour = Timestamp.from_secs(timestamp_hour_ago)
|
lasthour = Timestamp.from_secs(timestamp_hour_ago)
|
||||||
|
|
||||||
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(lasthour)
|
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(lasthour)
|
||||||
events = cli.database().query([filter1])
|
events = cli.database().query([filter1])
|
||||||
ns.finallist = {}
|
ns.finallist = {}
|
||||||
|
@@ -78,8 +78,9 @@ class TrendingNotesNostrBand(DVMTaskInterface):
|
|||||||
|
|
||||||
return json.dumps(result_list)
|
return json.dumps(result_list)
|
||||||
|
|
||||||
except:
|
except Exception as e:
|
||||||
return "error"
|
print(e)
|
||||||
|
return json.dumps([])
|
||||||
|
|
||||||
def post_process(self, result, event):
|
def post_process(self, result, event):
|
||||||
"""Overwrite the interface function to return a social client readable format, if requested"""
|
"""Overwrite the interface function to return a social client readable format, if requested"""
|
||||||
@@ -104,7 +105,7 @@ def build_example(name, identifier, admin_config):
|
|||||||
|
|
||||||
nip89info = {
|
nip89info = {
|
||||||
"name": name,
|
"name": name,
|
||||||
"image": "https://image.nostr.build/4dc758923c7bfc5ba92030e6419272ec7470c3809d36e88e99f3a9daece88bac.png",
|
"image": "https://nostr.band/android-chrome-192x192.png",
|
||||||
"about": "I show trending notes from nostr.band",
|
"about": "I show trending notes from nostr.band",
|
||||||
"amount": "Free",
|
"amount": "Free",
|
||||||
"encryptionSupported": True,
|
"encryptionSupported": True,
|
||||||
|
@@ -25,7 +25,7 @@ class ImageInterrogator(DVMTaskInterface):
|
|||||||
TASK: str = "image-to-text"
|
TASK: str = "image-to-text"
|
||||||
FIX_COST: float = 80
|
FIX_COST: float = 80
|
||||||
|
|
||||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config,
|
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
|
||||||
admin_config: AdminConfig = None, options=None):
|
admin_config: AdminConfig = None, options=None):
|
||||||
super().__init__(name=name, dvm_config=dvm_config, nip89config=nip89config, nip88config=nip88config,
|
super().__init__(name=name, dvm_config=dvm_config, nip89config=nip89config, nip88config=nip88config,
|
||||||
admin_config=admin_config, options=options)
|
admin_config=admin_config, options=options)
|
||||||
|
@@ -95,7 +95,7 @@ class SearchUser(DVMTaskInterface):
|
|||||||
|
|
||||||
# Query events from database
|
# Query events from database
|
||||||
|
|
||||||
filter1 = Filter().kind(0)
|
filter1 = Filter().kind(Kind(0))
|
||||||
events = cli.database().query([filter1])
|
events = cli.database().query([filter1])
|
||||||
# for event in events:
|
# for event in events:
|
||||||
# print(event.as_json())
|
# print(event.as_json())
|
||||||
|
@@ -109,7 +109,7 @@ class SummarizationUnleashedChat(DVMTaskInterface):
|
|||||||
for model in client.models.list():
|
for model in client.models.list():
|
||||||
print('- ' + model.id)
|
print('- ' + model.id)
|
||||||
|
|
||||||
content = "Summarize the following notes: " + str(options["prompt"])[:4000]
|
content = "Summarize the following notes: " + str(options["prompt"])[:3500]
|
||||||
normal_stream = client.chat.completions.create(
|
normal_stream = client.chat.completions.create(
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
|
@@ -114,7 +114,11 @@ def get_from_sql_table(db, npub):
|
|||||||
user.lud16 = row[5]
|
user.lud16 = row[5]
|
||||||
user.name = row[6]
|
user.name = row[6]
|
||||||
user.lastactive = row[7]
|
user.lastactive = row[7]
|
||||||
|
try:
|
||||||
user.subscribed = row[8]
|
user.subscribed = row[8]
|
||||||
|
except:
|
||||||
|
user.subscribed = False
|
||||||
|
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@@ -15,7 +15,7 @@ setup(
|
|||||||
long_description=LONG_DESCRIPTION,
|
long_description=LONG_DESCRIPTION,
|
||||||
packages=find_packages(include=['nostr_dvm', 'nostr_dvm.*']),
|
packages=find_packages(include=['nostr_dvm', 'nostr_dvm.*']),
|
||||||
|
|
||||||
install_requires=["nostr-sdk==0.10.0",
|
install_requires=["nostr-sdk=>0.10.0",
|
||||||
"bech32",
|
"bech32",
|
||||||
"pycryptodome==3.20.0",
|
"pycryptodome==3.20.0",
|
||||||
"python-dotenv==1.0.0",
|
"python-dotenv==1.0.0",
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import dotenv
|
import dotenv
|
||||||
@@ -37,9 +38,10 @@ def playground():
|
|||||||
subscription_config.LNBITS_INVOICE_KEY = invoice_key
|
subscription_config.LNBITS_INVOICE_KEY = invoice_key
|
||||||
subscription_config.LNBITS_ADMIN_KEY = admin_key # The dvm might pay failed jobs back
|
subscription_config.LNBITS_ADMIN_KEY = admin_key # The dvm might pay failed jobs back
|
||||||
subscription_config.LNBITS_URL = os.getenv("LNBITS_HOST")
|
subscription_config.LNBITS_URL = os.getenv("LNBITS_HOST")
|
||||||
Subscription(subscription_config)
|
x = threading.Thread(target=Subscription, args=(Subscription(subscription_config),))
|
||||||
|
x.start()
|
||||||
|
|
||||||
keep_alive()
|
#keep_alive()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user