Closed tomastiminskas closed 11 months ago
This is a great idea. It looks like you're already doing this @tomastiminskas but it would be worthwhile to keep this "recipe" scalable & interoperable for other possible services (for example suppose we want Midjourney as a contact next). This is a great step toward making AI accessible to everyone even without a credit card.
Other thought: do we need some sort of throttling? I understand we are charging sats but my understanding is ChatGPT does have a hard limit after a certain point. Maybe we need a pool of accounts that we can route to to minimize the likelihood of issues.
@jimBeaux27 we have a paid chatGPT account in Stakwork so we will be using that one. As it's paid, we will charge the user for it as well.
@pitoi whenever you have time, please take a look at this ticket and let me know your thoughts.
Just because it's paid does not mean it has no limitations. I understand that it is possible that you reach the limit of bandwidth in what you can ask ChatGPT in a given time window. If there are hundreds of people on the same account, even if it's paid that could be an issue. Even if it has a cost to them it is possible you have a "rich bastard" that just spams requests.
One workaround is to have a pool of accounts to help scale or to limit the # of requests in a given window. I have implemented something similar to this on a different application if you'd like to discuss.
@jimBeaux27 we discussed this with Paul and we will remove encryption of the process. Messages will be stored encrypted in user relay, but they will go unencrypted from relay to Stakwork. Same with the response from Stakwork to relay.
In the other hand, if we will charge the user for each question, instead of hitting an endpoint on Stakwork we would need to send a keysend with a new type and the amount needed. So Stakwork will process it if the amount is correct and will send another keysend to user node with the response.
@Evanfeenstra @gonzaloaune not sure if Stakwork has a relay instance running that could handle this. Thoughts?
Stakwork does not have the ability to send / receive keysends since it doesn't have its own Relay.
We do make payments via Keysend but that's just a custom endpoint we have in Hub for the purpose of paying people.
We might need to use LSAT as we use on Second Brain so user can pay for it, then send the proof of payment when sending the question to ChatGPT through the Stakwork endpoint, so Stakwork can verify the pmt and send the response on the endpoint response. Or an error message if pmt was not verified.
Maybe we can do a call when @Evanfeenstra is back to discuss this and find the best approach
we do have this endpoint that gives access to chatGPT4 workflow on stakwork that needs a lsat
http://<redacted>/chatGPT
we also have these endpoints on relay that we could use on the ios app
app.get('/lsats', lsats.listLsats)
app.get('/lsats/:identifier', lsats.getLsat)
app.post('/lsats', lsats.saveLsat)
app.put('/lsats/:identifier', lsats.updateLsat)
app.delete('/lsats/:identifier', lsats.deleteLsat)
app.get('/active_lsat', lsats.getActiveLsat)
Not sure if on the app we can add the endpoint for stakwork and then use these endpoints to do the request, only thing is that stakwork responds only to a webhook url cause the response takes time and I'm not sure if its possible for the app itself to get the response
we were discussing with @tomastiminskas maybe have a dedicated relay + lnd for Stakwork (or use the one we use now to pay workers) and Stak will have special skills to communicate with it, that way Stak can respond by replying to that Relay and it can issue keysend commands to specific pubkeys.
Question:
STAKWORK:
GET
endpoint to getencryption_public_key
base64 string from Stakwork andprice_per_message
POST
endpoint to send message/question to ChatGPT (?) Params:message
: encrypted message using Stakwork encryption public keyuser_public_key
: user encryption public key so stakwork can encrypt response for userRELAY:
GET
endpoint in step 1 (ascontact_key
on contacts table). Also create the chat with this contact and store theprice_per_message
on itAPP:
If we remove encryption on the process, we can store messages encrypted in relay, but they will go from phone to relay and from relay to Stakwork unencrypted. Same with the response, they will travel unencrypted but will be encrypted before being stored in relay db and sent to device. This would simplify the process a lot.