-
Notifications
You must be signed in to change notification settings - Fork 2
API crossplatform POC #3
Comments
Due date = 10/16/23 (updated) API High Level
Will expand after thinking deeper about it |
API Deep Dive Preface: By using python SDKs for Telegram and OpenAI/ChatGPT, I made an overly opinionated design decision that has locked us into using python. Using python to build a web API is do-able, but it may not be the right tool for the job. The python interpreter acts as a single, coordinated entity managing the execution environment. This is not ideal for APIs, so I'm wondering if the first step in the longer term vision of building an API-first Abbot is to take the time to swap all SDKs for naked API calls and rebuild Abbot for the hackathon using something more API native like Typescript. Granted, that will take a lot of time: time we don't have. The other extreme is to not change anything at the design level and forge ahead with python, then worry about the scalability of an API later. Deep Dive Options
Example 1 url = f"https://api.telegram.org/bot{token}/sendMessage"
payload = {
"chat_id": chat_id,
"text": text
}
response = requests.post(url, data=payload)
response.json() My vote is #2. Going to start there and work my way through the options as necessary. |
I think 2 is a good place to start. Just keeping the nostr logic separate for now is good. |
Thanks for the input and confirmation @niteshbalusu11! Might need your help with the relay code if you can spare the time. |
Will the above architecture diagram look different in light of the new direction outlined in #5 ? |
Not sure yet. @w3irdrobot is taking lead here. He's going to drop the notes and ideas he came up with in our call this AM. |
the basic setup will be the following graph TD;
NostrServer-->AbbotAPI;
AbbotAPI-->AbbotBot;
TelegramClient-->AbbotTGClient;
AbbotTGClient-->AbbotBot;
AbbotBot-->OpenAIAPI;
OpenAIAPI-->AbbotBot;
AbbotBot-->AbbotAPI;
AbbotAPI-->NostrServer;
AbbotBot-->AbbotTGClient;
AbbotTGClient-->TelegramClient;
not my best diagram but it gets the point across. i'm going to abstract the actual business logic that Abbot does out into a central place. that way, we can abstract out the inputs for the commands to easily support more. obviously, telegram will continue to function as is. i'm just going to pull out the code so it implements some sort of interface that can be reproduced. then i'll make an API using flask that can be called into to run commands on Abbot. this will be able to be used by the nostr server, since it seems we will implement that as an external process since the python nostr sdks seem to be less than ideal. the commands that are currently supported are as follows:
so for now, my plan is to just turn each of these into an endpoint that can be called into. for now, an easy way to auth would just be using a simple auth bearer token header using a shared secret. also i think it'd be good for the calling service to pass a request id using UUID version 4 and accept a webhook on a single endpoint that will be passed back to notify the calling service of the request for which we are passing data back to it.
|
@w3irdrobot updated list of commands based on master, which I'll be rebasing
Please kill the following
|
graph TD;
NostrServer-->AbbotAPI;
AbbotAPI-->AbbotBot;
TelegramClient-->AbbotTGClient;
AbbotTGClient-->AbbotBot;
AbbotBot-->OpenAIAPI;
OpenAIAPI-->AbbotBot;
AbbotBot-->AbbotAPI;
AbbotAPI-->NostrServer;
AbbotBot-->AbbotTGClient;
AbbotTGClient-->TelegramClient;
Questions about the actors in the diagram:
|
Update: @annieseth and I got pynostr to work last night!! So with that working, we can kill the Nostr Server and simply write a AbbotNostr class to handle the processing of incoming note events kinds 4, 40-44 and the creation of response note events. The initial skeleton code for this class is pushed to the nostrasia branch. |
# This is the 1st commit message: requirements.txt # This is the commit message ATLBitLab#2: service file # This is the commit message ATLBitLab#3: server # This is the commit message ATLBitLab#4: Bump babel from 2.8.0 to 2.9.1 Bumps [babel](https://github.com/python-babel/babel) from 2.8.0 to 2.9.1. - [Release notes](https://github.com/python-babel/babel/releases) - [Changelog](https://github.com/python-babel/babel/blob/master/CHANGES.rst) - [Commits](python-babel/babel@v2.8.0...v2.9.1) --- updated-dependencies: - dependency-name: babel dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> # This is the commit message ATLBitLab#5: Bump oauthlib from 3.2.0 to 3.2.2 Bumps [oauthlib](https://github.com/oauthlib/oauthlib) from 3.2.0 to 3.2.2. - [Release notes](https://github.com/oauthlib/oauthlib/releases) - [Changelog](https://github.com/oauthlib/oauthlib/blob/master/CHANGELOG.rst) - [Commits](oauthlib/oauthlib@v3.2.0...v3.2.2) --- updated-dependencies: - dependency-name: oauthlib dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> # This is the commit message ATLBitLab#6: Bump twisted from 22.4.0 to 22.10.0 Bumps [twisted](https://github.com/twisted/twisted) from 22.4.0 to 22.10.0. - [Release notes](https://github.com/twisted/twisted/releases) - [Changelog](https://github.com/twisted/twisted/blob/trunk/NEWS.rst) - [Commits](twisted/twisted@twisted-22.4.0...twisted-22.10.0) --- updated-dependencies: - dependency-name: twisted dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> # This is the commit message ATLBitLab#7: Update issue templates # This is the commit message ATLBitLab#8: server # This is the commit message ATLBitLab#9: group # This is the commit message ATLBitLab#10: server # This is the commit message ATLBitLab#11: update reqs
# This is the 1st commit message: requirements.txt # This is the commit message ATLBitLab#2: service file # This is the commit message ATLBitLab#3: server # This is the commit message ATLBitLab#4: Bump babel from 2.8.0 to 2.9.1 Bumps [babel](https://github.com/python-babel/babel) from 2.8.0 to 2.9.1. - [Release notes](https://github.com/python-babel/babel/releases) - [Changelog](https://github.com/python-babel/babel/blob/master/CHANGES.rst) - [Commits](python-babel/babel@v2.8.0...v2.9.1) --- updated-dependencies: - dependency-name: babel dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> # This is the commit message ATLBitLab#5: Bump oauthlib from 3.2.0 to 3.2.2 Bumps [oauthlib](https://github.com/oauthlib/oauthlib) from 3.2.0 to 3.2.2. - [Release notes](https://github.com/oauthlib/oauthlib/releases) - [Changelog](https://github.com/oauthlib/oauthlib/blob/master/CHANGELOG.rst) - [Commits](oauthlib/oauthlib@v3.2.0...v3.2.2) --- updated-dependencies: - dependency-name: oauthlib dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> # This is the commit message ATLBitLab#6: Bump twisted from 22.4.0 to 22.10.0 Bumps [twisted](https://github.com/twisted/twisted) from 22.4.0 to 22.10.0. - [Release notes](https://github.com/twisted/twisted/releases) - [Changelog](https://github.com/twisted/twisted/blob/trunk/NEWS.rst) - [Commits](twisted/twisted@twisted-22.4.0...twisted-22.10.0) --- updated-dependencies: - dependency-name: twisted dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> # This is the commit message ATLBitLab#7: Update issue templates # This is the commit message ATLBitLab#8: server # This is the commit message ATLBitLab#9: group # This is the commit message ATLBitLab#10: server # This is the commit message ATLBitLab#11: update reqs # This is the commit message ATLBitLab#12: updates # This is the commit message ATLBitLab#13: local
Due date = 10/15/23The text was updated successfully, but these errors were encountered: