akulai icon indicating copy to clipboard operation
akulai copied to clipboard

Add an API for plugins

Open Akul2010 opened this issue 2 years ago • 7 comments
trafficstars

The previous PR, #12, was discontinued because I messed up somewhere and wasn't able to do anything about it. But, I have ported the same changes to this new version with less messy commits.

This basically gives all plugins access to the speak and listen functions when run, so they too can speak and listen when needed rather than printing output in CMD or listening once without follow-up questions.

Akul2010 avatar May 04 '23 01:05 Akul2010

Hi @aaronchantrill, I have made some changes and would like you to review them as I am not as experienced with Perl/JS as I am with Python, so I'm not sure if I got anything wrong. Please try to doit as soon as possible so that I can update the plugins in the akulai-plugins repository when finished.

Akul2010 avatar May 10 '23 00:05 Akul2010

Okay, I think I understand what the problem was. I had to move the api setup stuff above the if name == main but below the AkulAI() class definition. Then I changed it to use different paths for speak and listen:

@app.get("/speak/{text}")
async def speak(text: str):
    akulai.speak(text)
    return {"message": "Text synthesized"}

@app.post("/listen")
async def listen():
    akulai.listen()
    return {"message": "Listening..."}

At that point I was able to start the program and then navigate to http://localhost:8000/speak/Hello+There to get it to say "Hello plus There". I guess it does not automatically urldecode the query string values.

aaronchantrill avatar May 24 '23 20:05 aaronchantrill

I will add your proposed changes right now. I'm not sure how I would implement urldecode, however.

Akul2010 avatar May 24 '23 21:05 Akul2010

I'm still having some issues with this. I'll try to submit a pull request. I'm trying to figure out why it won't shut down when I ask it to right now. Are you running this code on your system?

aaronchantrill avatar May 25 '23 12:05 aaronchantrill

Yes, I just pressed Ctrl+C and ignored it, because I considered it a trivial problem. I'll look into it now, though.

Akul2010 avatar May 25 '23 19:05 Akul2010

There seems to be a problem where the plugins can't access the FastAPI server. I'm not sure what is causing this, any ideas?

Akul2010 avatar Aug 07 '23 16:08 Akul2010

Rather than calling through a server, I'm thinking we could just wrap the functions into a command line interface, through which the respective languages will have their own functions for. (for example, JS listen function will run a command in js to run the listen function)

Akul2010 avatar Dec 23 '23 18:12 Akul2010