gdansk-ai

Full stack voice chatbot

https://github.com/jmaczan/gdansk-ai

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.3%) to scientific vocabulary

Keywords

ai auth0 gdansk google google-cloud gpt-35-turbo llm ml nodejs openai python speech-to-text stripe text-to-speech typescript voice-ai voice-assistant voice-chat voice-chat-bot whisper-ai

Keywords from Contributors

mesh interactive hacking
Last synced: 6 months ago · JSON representation ·

Repository

Full stack voice chatbot

Basic Info
Statistics
  • Stars: 198
  • Watchers: 6
  • Forks: 21
  • Open Issues: 0
  • Releases: 0
Topics
ai auth0 gdansk google google-cloud gpt-35-turbo llm ml nodejs openai python speech-to-text stripe text-to-speech typescript voice-ai voice-assistant voice-chat voice-chat-bot whisper-ai
Created over 2 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

Gdask AI

Gdask AI is a full stack AI voice chatbot (speech-to-text, LLM, text-to-speech) with integrations to Auth0, OpenAI, Google Cloud API and Stripe - Web App, API and AI

Gdask AI

Web API

It uses Stripe to provide payments infrastructure, so users can buy bibs - the API tokens. Auth0 is used to provide authentication and authorization. You can use them for free - Auth0 has a free tier up to 7000 users per month. Stripe only charges fees from purchases, so you have no ongoing costs from any of them.

If you want to use these services, you have to set up your Stripe and Auth0 accounts and put API keys into .env in web-api/ directory.

Node.js, TypeScript and Express are used here

.env

.env_example shows which values you have to set

``` CHATBOTAPIKEY={whatever you decide; this value is reused among ai-api, web-api and web in this project} OPENAIAPI_KEY={go to platform.openai.com, generate and copy-paste api key here}

Google Cloud API

type=serviceaccount projectid={project id} privatekeyid= privatekey={multiline private key with structure like this:-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----\n} clientemail={project name}@{project id}.iam.gserviceaccount.com clientid= authuri=https://accounts.google.com/o/oauth2/auth tokenuri=https://oauth2.googleapis.com/token authproviderx509certurl=https://www.googleapis.com/oauth2/v1/certs clientx509certurl=https://www.googleapis.com/robot/v1/metadata/x509/{project-name}%40{project-id}.iam.gserviceaccount.com universe_domain=googleapis.com

Stripe

STRIPESECRETKEY={sk...} STRIPEPUBLISHABLEKEY={pk...} TOKENSPRICEID={price_some characters here - you need to create a price in Stripe for tokens first and then copy-paste it here}

TOKENSPERTRANSACTION defines how many interactions user can make with AI per single bibs purchase

TOKENSPERTRANSACTION=5

Auth0

AUTH0ISSUERBASEURL='https://{tenant-name}.us.auth0.com' AUTH0DOMAIN='{tenant-name}.us.auth0.com' AUTH0CLIENTID= AUTH0CLIENTSECRET= AUTH0AUDIENCE="https://{tenant-name}.us.auth0.com/api/v2/" AUTH0SCOPE="openid profile email offlineaccess" CLIENTURL={url pointing to where web is deployed} AIAPIURL={url pointing to where ai api is deployed} ```

Run

  • go to web-api directory
  • npm install or npm ci
  • npm run build
  • npm run start or npm run dev to run it with hot-reload

Web

It works in Google Chrome currently. You can press Gdask AI logo to record audio, then press it once again to send it to Web API. After a successful response, a received audio is played to you.

Next.js used here with Vercel's template

.env

.env_example shows which values you have to set

``` CHATBOTAPIKEY={whatever you decide; this value is reused among ai-api, web-api and web in this project} CHATBOTAPIURL={url to where api is deployed}

NEXTPUBLICAPIURL={url pointing to where api is deployed} APIURL={url to where api is deployed}

Auth0

NEXTPUBLICAUTH0ISSUERBASEURL="https://{tenant-name}.us.auth0.com" NEXTPUBLICAUTH0CLIENTID= AUTH0SECRET= AUTH0BASEURL={url pointing to where web is deployed} AUTH0ISSUERBASEURL='https://{tenant-name}.us.auth0.com' AUTH0DOMAIN='{tenant-name}.us.auth0.com' AUTH0CLIENTID= AUTH0CLIENTSECRET= AUTH0AUDIENCE="https://{tenant-name}.us.auth0.com/api/v2/" AUTH0SCOPE="openid profile email offlineaccess" CLIENTURL={url pointing to where web is deployed} ```

Run

  • go to web directory
  • npm install or npm ci
  • npm run build
  • install Stripe cli
  • stripe listen --forward-to http://localhost:3000/webhook (adjust the port from 3000 if you've changed it) - we need this to invoke /webhook endpoint on bibs purchases
  • npm run start

Troubleshooting

  • you might neet to remove/comment out screen_hint: "signup", in signup.ts

AI API

OpenAI and Google Cloud API are used here to provide speech-to-text (Whisper-1), LLM (gpt-3.5-turbo) and text-to-speech (Google Cloud TextToSpeechClient) services.

Python and FastAPI here

.env

.env_example shows which values you have to set

``` CHATBOTAPIKEY={whatever you decide; this value is reused among ai-api, web-api and web in this project} OPENAIAPI_KEY={go to platform.openai.com, generate and copy-paste api key here}

Google Cloud API start

type=serviceaccount projectid={project id} privatekeyid= privatekey={multiline private key with structure like this:-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----\n} clientemail={project name}@{project id}.iam.gserviceaccount.com clientid= authuri=https://accounts.google.com/o/oauth2/auth tokenuri=https://oauth2.googleapis.com/token authproviderx509certurl=https://www.googleapis.com/oauth2/v1/certs clientx509certurl=https://www.googleapis.com/robot/v1/metadata/x509/{project-name}%40{project-id}.iam.gserviceaccount.com universe_domain=googleapis.com PORT=9000 ```

Run

  • go to ai-api directory
  • python3 app.py, by default it runs on port 9000

Auth0 setup

Create an account, then a new tenant. You will need to set up:

  • Applications

    • API Explorer Application (Machine to Machine)
    • Client secret taken from here
    • Allow Cross-Origin Authentication
    • Credentials - Authentication Methods - Client Secret (Post)
    • APIs - Auth0 Management API - Authorized and all permissions should be granted in dropdown to the right
    • Regular Web Application
    • Client secret here
    • Allowed Callback URLs: 6 URLs in total in format: url, url/callback, url/api/auth/callback - one url is web api url and another one is for web url (example: http://localhost:8080, http://localhost:8080/callback, http://localhost:8080/api/auth/callback, http://localhost:3000, http://localhost:3000/callback, http://localhost:3000/api/auth/callback; replace localhost and port with with your domain and make sure you use correct protocol http/https)
    • Allowed Logout URLs: URL of web api and web app - http://localhost:3000 and http://localhost:8080 or your domain
    • Allowed Web Origins: URL of web api and web app - http://localhost:8080, your API and AI API domain or your domain
    • Allow Cross-Origin Authentication: Allowed Cors should be web url, your Web API and AI API domain
    • Rotation ON
    • Credentials - Authentication Methods - Client Secret (Post)
  • APIs

    • Auth0 Management API (System API):
    • Machine To Machine Applications:
      • add both applications listed above and make sure the switch Authorized to the right is turned on for both
      • add all permissions for both of them, by clicking on dropdown to the right and selecting All permissions and saving

Stripe setup

Create an account, turn the test mode unless you want to run it on production and process real payments, go to Developers tab, then API keys. This is where you can find values for STRIPESECRETKEY and STRIPEPUBLISHABLEKEY. Now go to Products tab and Add product which represents a single purchase of bibs (one bib - one interaction with AI for a user). Once you create it, copy priceId and put it into .env as TOKENSPRICEID.

OpenAI setup

Create an account, go to platform.openai.com, generate API key, use it in .env files

Google Cloud API setup

Create an account, go to IAM & Admin, then Service Accounts and create a project - you need id of the project to put into .env files. Then you need to generate json with credentials and extract the values from the file to your .env files. Go to Create access credentials page (you can use search engine to find a link). Then Keys -> Add Key -> Create new key -> JSON -> Create. You should get credentials.json with all values you need to .env. Finally, you need to enable text to speech API service and you're ready

Acknowledgements

Thanks to Jeff McJunkin for improving the README by going through the config process from the scratch and filling the gaps in the docs

License

GNU GPL v2

Cite

If you use this software in your research, please use the following citation:

bibtex @software{Maczan_Gdansk_AI_2023, author = {Maczan, Jdrzej Pawe}, title = {{Gdask AI - Full stack voice chatbot}}, url = {https://github.com/jmaczan/gdansk-ai}, year = {2023}, publisher = {GitHub} }

Author

Made in Gdask, Poland in 2023 by Jdrzej Pawe Maczan

Owner

  • Name: Jędrzej Maczan
  • Login: jmaczan
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Maczan"
  given-names: "Jędrzej Paweł"
  orcid: "https://orcid.org/0000-0003-1741-6064"
title: "Gdańsk AI -  Full stack voice chatbot"
date-released: 2023-07-04
url: "https://github.com/jmaczan/gdansk-ai"

GitHub Events

Total
  • Watch event: 7
  • Fork event: 3
Last Year
  • Watch event: 7
  • Fork event: 3

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 30
  • Total Committers: 3
  • Avg Commits per committer: 10.0
  • Development Distribution Score (DDS): 0.4
Past Year
  • Commits: 5
  • Committers: 1
  • Avg Commits per committer: 5.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Jędrzej Paweł Maczan j****j@E****l 18
Jędrzej Paweł Maczan j****l@m****l 11
dependabot[bot] 4****] 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 0
  • Total pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 37 minutes
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • dependabot[bot] (1)
Top Labels
Issue Labels
Pull Request Labels
dependencies (1)