diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_topic.py b/nostr_dvm/tasks/content_discovery_currently_popular_topic.py index 3af36a0..720d739 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_topic.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_topic.py @@ -93,6 +93,7 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface): # default values max_results = 200 + user = event.author().to_hex() for tag in event.tags(): if tag.as_vec()[0] == 'i': @@ -101,6 +102,8 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface): param = tag.as_vec()[1] if param == "max_results": # check for param type max_results = int(tag.as_vec()[2]) + elif param == "user": # check for param type + user = (tag.as_vec()[2]) elif param == "search_list": # check for param type self.search_list = str(tag.as_vec()[2]).split(",") print(self.search_list) @@ -113,6 +116,8 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface): options = { "max_results": max_results, + "request_event_id": event.id().to_hex(), + "request_event_author": event.author().to_hex() } request_form['options'] = json.dumps(options) self.request_form = request_form diff --git a/nostr_dvm/tasks/generic_dvm.py b/nostr_dvm/tasks/generic_dvm.py index 6a3f4a6..695e485 100644 --- a/nostr_dvm/tasks/generic_dvm.py +++ b/nostr_dvm/tasks/generic_dvm.py @@ -51,9 +51,8 @@ class GenericDVM(DVMTaskInterface): request_form = {"jobID": event.id().to_hex()} - self.options["user"] = user self.options["request_event_id"] = event.id().to_hex() - self.options["request_event_author"] = event.author().to_hex() + self.options["request_event_author"] = user if prompt != "": self.options["input"] = prompt request_form['options'] = json.dumps(self.options) diff --git a/tests/generic_dvm_autotopic_feed.py b/tests/generic_dvm_autotopic_feed.py index 9626976..8a15665 100644 --- a/tests/generic_dvm_autotopic_feed.py +++ b/tests/generic_dvm_autotopic_feed.py @@ -8,7 +8,7 @@ from duck_chat import ModelType from nostr_sdk import Kind, Filter, PublicKey, SecretKey, Keys, NostrSigner, RelayLimits, Options, Client, Tag, \ LogLevel, Timestamp, NostrDatabase -from nostr_dvm.tasks.content_discovery_currently_popular_topic import DicoverContentCurrentlyPopularbyTopic + from nostr_dvm.tasks.generic_dvm import GenericDVM from nostr_dvm.utils import definitions from nostr_dvm.utils.admin_utils import AdminConfig @@ -54,10 +54,10 @@ def playground(announce=False): dvm_config.FIX_COST = 0 - admin_config.DELETE_NIP89 = True - admin_config.POW = True - admin_config.EVENTID = "5322b731230cf8961f8403d025722a381af9b012b5d5f6dcc09f88e160f4e4ff" - admin_config.PRIVKEY = dvm_config.PRIVATE_KEY + #admin_config.DELETE_NIP89 = True + #admin_config.POW = True + #admin_config.EVENTID = "5322b731230cf8961f8403d025722a381af9b012b5d5f6dcc09f88e160f4e4ff" + #admin_config.PRIVKEY = dvm_config.PRIVATE_KEY # Add NIP89 @@ -80,7 +80,7 @@ def playground(announce=False): "input": "How do you call a noisy ostrich?", } - dvm = DicoverContentCurrentlyPopularbyTopic(name=name, dvm_config=dvm_config, nip89config=nip89config, + dvm = GenericDVM(name=name, dvm_config=dvm_config, nip89config=nip89config, admin_config=admin_config, options=options) @@ -88,7 +88,6 @@ def playground(announce=False): result = "" try: from duck_chat import DuckChat - result = "" async with DuckChat(model=ModelType.GPT4o) as chat: query = prompt result = await chat.ask_question(query) @@ -119,7 +118,8 @@ def playground(announce=False): await cli.connect() #pip install -U https://github.com/mrgick/duckduckgo-chat-ai/archive/master.zip - author = PublicKey.parse(options["user"]) + author = PublicKey.parse(options["request_event_author"]) + print(options["request_event_author"]) filterauth = Filter().kind(definitions.EventDefinitions.KIND_NOTE).author(author).limit(100) evts = await cli.get_events_of([filterauth], relay_timeout) @@ -128,12 +128,14 @@ def playground(announce=False): for event in evts: text = text + event.content() + ";" + text = text[:6000] prompt = "Only reply with the result. Here is a list of notes, seperated by ;. Find the 20 most important keywords and return them by a comma seperated list: " + text #loop = asyncio.get_running_loop() result = await process_request(options, prompt) + print(result) content = "I identified these as your topics:\n\n"+result.replace(",", ", ") + "\n\nProcessing, just a few more seconds..." await send_job_status_reaction(original_event_id_hex=dvm.options["request_event_id"], original_event_author_hex=dvm.options["request_event_author"], client=cli, dvm_config=dvm_config, content=content) @@ -144,7 +146,7 @@ def playground(announce=False): # result = await chat.ask_question(query) # result = result.replace(", ", ",") # print(result) - result = "" + from types import SimpleNamespace ns = SimpleNamespace() @@ -159,7 +161,7 @@ def playground(announce=False): if dvm.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value: print("[" + dvm.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events") ns.finallist = {} - search_list = result.split('') + #search_list = result.split(',') for event in events: #if all(ele in event.content().lower() for ele in []): diff --git a/tests/test_dvm_client.py b/tests/test_dvm_client.py index 1312d5f..e628d6c 100644 --- a/tests/test_dvm_client.py +++ b/tests/test_dvm_client.py @@ -466,6 +466,8 @@ async def nostr_client(): # await nostr_client_test_image_private("a beautiful ostrich watching the sunset") nutzap_wallet = NutZapWallet() + + nut_wallet = await nutzap_wallet.get_nut_wallet(client, keys) #dangerous, dont use this, except your wallet is messed up. delete = False