updating JS sdk to 0.12.0, fixes summarization

This commit is contained in:
Believethehype
2024-03-28 11:48:52 +01:00
parent ea5b0cddce
commit 97857cd928
10 changed files with 27 additions and 28 deletions

View File

@@ -66,7 +66,7 @@ class TextSummarizationHuggingChat(DVMTaskInterface):
print("Event not found")
raise Exception
if evt.kind() == EventDefinitions.KIND_NIP90_RESULT_CONTENT_DISCOVERY:
if evt.kind().as_u64() == EventDefinitions.KIND_NIP90_RESULT_CONTENT_DISCOVERY:
result_list = json.loads(evt.content())
prompt = ""
for tag in result_list:

View File

@@ -68,7 +68,7 @@ class SummarizationUnleashedChat(DVMTaskInterface):
print("Event not found")
raise Exception
if evt.kind() == EventDefinitions.KIND_NIP90_RESULT_CONTENT_DISCOVERY:
if evt.kind().as_u64() == EventDefinitions.KIND_NIP90_RESULT_CONTENT_DISCOVERY:
result_list = json.loads(evt.content())
prompt = ""
for tag in result_list:

View File

@@ -1,5 +1,6 @@
import json
import os
import threading
from pathlib import Path
import dotenv
@@ -15,7 +16,6 @@ from nostr_dvm.utils.nostr_utils import check_and_set_private_key
from nostr_dvm.utils.zap_utils import check_and_set_ln_bits_keys
def playground():
bot_config = DVMConfig()
identifier = "bot_test"
@@ -26,7 +26,6 @@ def playground():
bot_config.LNBITS_ADMIN_KEY = admin_key # The dvm might pay failed jobs back
bot_config.LNBITS_URL = os.getenv("LNBITS_HOST")
admin_config = AdminConfig()
pdfextractor = textextraction_pdf.build_example("PDF Extractor", "pdf_extractor", admin_config)
@@ -34,12 +33,11 @@ def playground():
pdfextractor.run()
bot_config.SUPPORTED_DVMS.append(pdfextractor) # We add translator to the bot
x = threading.Thread(target=Bot, args=([bot_config]))
x.start()
Bot(bot_config, admin_config)
# Keep the main function alive for libraries that require it, like openai
keep_alive()
# keep_alive()
if __name__ == '__main__':

View File

@@ -13,9 +13,7 @@ def playground():
connectionstr = os.getenv("TEST_NWC")
keys = Keys.parse(os.getenv("TEST_USER"))
bolt11 = zaprequest("bot@nostrdvm.com", 5, "test", None, PublicKey.parse("npub1cc79kn3phxc7c6mn45zynf4gtz0khkz59j4anew7dtj8fv50aqrqlth2hf"), keys, dvmconfig.DVMConfig.RELAY_LIST, zaptype="private")
print(bolt11)
result = nwc_zap(connectionstr, bolt11, keys, externalrelay=None)
print(result)

View File

@@ -12,7 +12,7 @@
},
"dependencies": {
"@getalby/sdk": "^3.4.0",
"@rust-nostr/nostr-sdk": "^0.11.1",
"@rust-nostr/nostr-sdk": "^0.12.0",
"@vuepic/vue-datepicker": "^7.4.1",
"@vueuse/core": "^10.7.2",
"bech32": "^2.0.0",

View File

@@ -118,13 +118,13 @@ async function listen() {
const handle = {
// Handle event
handleEvent: async (relayUrl, event) => {
handleEvent: async (relayUrl, subscriptionId, event) => {
/* if (store.state.imagehasEventListener === false){
return true
}*/
//const dvmname = getNamefromId(event.author.toHex())
console.log("Received new event from", relayUrl);
console.log(event.asJson())
// console.log(event.asJ())
let resonsetorequest = false
sleep(0).then(async () => {
for (let tag in event.tags) {

View File

@@ -119,22 +119,23 @@ async function react(eventid, authorid){
if (objects !== undefined){
if(!objects.reacted ){
if (localStorage.getItem('nostr-key-method') === 'android-signer') {
let draft = {
let draft = {
content: "🧡",
kind: 7,
pubkey: store.state.pubkey.toHex(),
tags: [],
createdAt: Date.now()
};
let res = await amberSignerService.signEvent(draft)
await client.sendEvent(Event.fromJson(JSON.stringify(res)))
let requestid = res.id;
let res = await amberSignerService.signEvent(draft)
await client.sendEvent(Event.fromJson(JSON.stringify(res)))
let requestid = res.id;
}
else {
let event = EventBuilder.reaction(event_id, public_key, "🧡")
let res = await client.sendEventBuilder(event);
let event = new EventBuilder(7, "🧡", [])
//let event = EventBuilder.reaction(event_id, "🧡")
let requestid = await client.sendEventBuilder(event);
}
objects.reacted = true

View File

@@ -14,12 +14,11 @@ import {
Nip19Event,
Alphabet,
Keys,
nip04_decrypt,
SecretKey,
Duration,
SingleLetterTag,
NostrSigner,
nip44_encrypt,
nip44Encrypt,
NIP44Version
} from "@rust-nostr/nostr-sdk";
import store from '../store';
@@ -206,7 +205,7 @@ async function listen() {
const handle = {
// Handle event
handleEvent: async (relayUrl, event) => {
handleEvent: async (relayUrl, subscriptionId, event) => {
let resonsetorequest = false
sleep(1200).then(async () => {
for (let tag in event.tags) {
@@ -779,7 +778,7 @@ async function subscribe_to_dvm() {
}
await nclient.connect()
let encnwc = nip44_encrypt(SecretKey.parse(store.state.nooglekey), PublicKey.parse(store.state.subscription_verifier_pubkey),
let encnwc = nip44Encrypt(SecretKey.parse(store.state.nooglekey), PublicKey.parse(store.state.subscription_verifier_pubkey),
current_subscription_nwc.value, NIP44Version.V2)
let content = {

View File

@@ -178,7 +178,7 @@ async function listen() {
const handle = {
// Handle event
handleEvent: async (relayUrl, event) => {
handleEvent: async (relayUrl, subscriptionId, event) => {
/* if (store.state.hasEventListener === false){
return true
}*/

View File

@@ -29,10 +29,13 @@ import VueDatePicker from "@vuepic/vue-datepicker";
import {timestamp} from "@vueuse/core";
import NoteTable from "@/components/NoteTable.vue";
import {zap} from "@/components/helper/Zap.vue";
import index from "vuex";
let dvms =[]
async function summarizefeed(eventids) {
let sortedIds = eventids.sort(function(a,b) {return (a.index > b.index) ? 1 : ((b.index > a.index) ? -1 : 0);} );
try {
if(store.state.pubkey === undefined || localStorage.getItem('nostr-key-method') === "anon"){
miniToastr.showMessage("In order to receive personalized recommendations, sign-in first.", "Not signed in.", VueNotifications.types.warn)
@@ -47,9 +50,9 @@ async function summarizefeed(eventids) {
let kind = 5001
let tags = []
for (const tag of eventids){
for (const tag of sortedIds){
try{
tags.push(["i", tag.id.toHex(), "event"])
tags.push(["i", tag.id, "event"])
}
catch{}
}
@@ -110,7 +113,7 @@ async function listen() {
const handle = {
// Handle event
handleEvent: async (relayUrl, event) => {
handleEvent: async (relayUrl, subscriptionId, event) => {
/* if (store.state.summarizationhasEventListener === false){
return true
}*/