Coder Social home page Coder Social logo

crispengari / farb Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 1.92 MB

๐Ÿค–๐Ÿค–๐Ÿฅ‡ First Aid Recommendation Bot (FARB) is a REST and GraphQL API that exposes a virtual assistant bot built from using Deep Learning Techniques. In this repository I will show by example how to integrate with these API's by building a web and mobile application tool.

License: MIT License

TypeScript 68.15% JavaScript 0.45% Python 21.32% CSS 10.09%
ariadne chatbot flask graphql natural-language-processing nextjs python pytorch react react-native torchtext

farb's Introduction

First Aid Recommendation Bot (FARB)

FARB is a simple machine learning graphql and rest API build to do basic virtual assistance in first aid treatments. So I present the FARB that helps human in recommending the first aid treatments.

logo

First Aid Recommendation Bot (FARB) is an BOT API for recommending First Aid Treatments to human beings.

cover

FARB Tool

FARB tools were built for both mobile applications and web applications using react-native and next.js respectively.

  1. mobile

cover cover cover

  1. web

cover cover cover

API

FARB api is a simple rest api that is served at http://localhost:3001/api/v1/ask and is able to predict tags in the message and give you better recommendations for your First Aid Treatment.

API response

If a proper POST request is sent to the server at http://localhost:3001/api/v1/ask we will be able to get ~99.11% accurate predictions of tags from the farb bot model and with the correct request body you will be able to get the predictions of the tag together with the recommendations from the bot on your First Aid query.

Rest request

Rest API is exposed at http://localhost:3001/api/v1/ask using the POST method only. So you can use any client such as:

  1. Thunder Client
  2. Postman
  3. cURL
  4. Axios (javascript)
  5. Fetch API (javascript)
  6. etc

To make a post request to the server at http://localhost:3001/api/v1/ask with a json body that looks as follows:

{
  "message": "What to do if I have splinters?"
}

The server will respond with the API response which looks as follows:

{
  "prediction": {
    "confidence": 1.0,
    "pattern": "what to do if i have splinters?",
    "tag": "splinter",
    "tagId": 10
  },
  "response": {
    "message": "1. SOAK IT IN EPSOM SALTS. Dissolve a cup of the salts into a warm bath and soak whatever part of the body has the splinter. Failing that, you can also put some of the salts onto a bandage pad and leave it covered for a day; this will eventually help bring the splinter to the surface. 2. VINEGAR OR OIL. Another simple way to draw out that stubborn splinter is to soak the affected area in oil (olive or corn) or white vinegar. Just pour some in a bowl and soak the area for around 20 to 30 minutes,"
  },
  "success": true
}

GraphQL endpoint

GraphQL endpoint is served at http://localhost:3001/graphql sending a graphql request at this endpoint that looks as follows:

fragment ErrorFragment on Error {
  field
  message
}
fragment BotResponseFragment on BotResponse {
  message
}
fragment BotPredictionFragement on BotPrediction {
  confidence
  tag
  tagId
  pattern
}

fragment AskBotResponse on AskBotResponse {
  error {
    ...ErrorFragment
  }
  success
  response {
    ...BotResponseFragment
  }
  prediction {
    ...BotPredictionFragement
  }
}
mutation AskBot($input: AskBotInput!) {
  askBot(input: $input) {
    ...AskBotResponse
  }
}

With the following variables:

{
  "input": {
    "message": "What to do if I have splinters?"
  }
}

Will yield the results that looks as follows:

{
  "data": {
    "askBot": {
      "error": null,
      "prediction": {
        "confidence": 1,
        "pattern": "what to do if i have splinters?",
        "tag": "splinter",
        "tagId": 10
      },
      "response": {
        "message": "1. SOAK IT IN EPSOM SALTS. Dissolve a cup of the salts into a warm bath and soak whatever part of the body has the splinter. Failing that, you can also put some of the salts onto a bandage pad and leave it covered for a day; this will eventually help bring the splinter to the surface. 2. VINEGAR OR OIL. Another simple way to draw out that stubborn splinter is to soak the affected area in oil (olive or corn) or white vinegar. Just pour some in a bowl and soak the area for around 20 to 30 minutes,"
      },
      "success": true
    }
  }
}

Languages

In this project the following languages was used:

- typescript(javascript)
- python

Notebooks

The notebooks for training the model that is being used to intents classification wan be found here.

intents.json

This file also contain responses for the Bot. Not that from the original dataset from kaggle this file was missing responses for other tags so i went ehead and fill that up and you can find the final intents.json file in the server/api/models/static folder.

License

In this simple AI tool i'm using MIT license which read as follows:

MIT License

Copyright (c) 2022 crispengari

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

farb's People

Contributors

crispengari avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.