Skip to content

Instantly share code, notes, and snippets.

View tbvinh's full-sized avatar
🧑‍🍼
I may be slow to respond.

Vinh Tran tbvinh

🧑‍🍼
I may be slow to respond.
  • Ho Chi Minh - Vietnam
View GitHub Profile
@tbvinh
tbvinh / get-ngrok.py
Created July 30, 2024 12:26
AI - get ngrOK URL
import requests
def get_ngrok_url():
try:
response = requests.get('http://localhost:4040/api/tunnels')
tunnels = response.json()['tunnels']
if tunnels:
return tunnels[0]['public_url']
else:
return None
#/etc/apache2/sites-enabled/000-default.conf
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod headers
sudo systemctl restart apache2
<VirtualHost *:80>
#ServerName www.example.com
@tbvinh
tbvinh / ngrok.service
Created July 30, 2024 12:22
AI ngrok service
#/etc/systemd/system/ngrok.service
[Unit]
Description=Ngrok Tunnel
After=network.target
[Service]
User=vinh
ExecStart=/usr/local/bin/ngrok http 80
@tbvinh
tbvinh / gunicorn.service
Created July 30, 2024 12:21
AI-gunicorn service
#/etc/systemd/system/gunicorn.service
[Unit]
Description=Gunicorn instance to serve myapp
After=network.target
[Service]
User=vinh
Group=www-data
WorkingDirectory=/home/vinh
@tbvinh
tbvinh / universal-sentence-encoder.py
Created July 25, 2024 11:09
Save model 'universal-sentence-encoder' to disk
import tensorflow as tf
import tensorflow_hub as hub
# Check if the Universal Sentence Encoder can be loaded from the provided link
model_url = "https://tfhub.dev/google/universal-sentence-encoder/4"
try:
model = hub.load(model_url)
# model.save('universal-sentence-encoder.model')
tf.saved_model.save(model, 'universal-sentence-encoder.model')
@tbvinh
tbvinh / chatbot.py
Last active July 25, 2024 11:15
the AI chatbot in python
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
import re
# Intents and responses
intents = {
@tbvinh
tbvinh / chatbot.html
Created July 19, 2024 15:01
Chatbot html and js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Chatbot</title>
<style>
body {
font-family: Arial, sans-serif;
}
@tbvinh
tbvinh / circle.html
Created July 19, 2024 11:31
AI Chatbot html java script with Circle calculation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>circle.html</title>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/universal-sentence-encoder@latest"></script>
<style>
body {
@tbvinh
tbvinh / rectangle.html
Created July 19, 2024 11:30
AI Chatbot html java script with Rectangle calculation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>rectangle.html</title>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/universal-sentence-encoder@latest"></script>
<style>
body {
@tbvinh
tbvinh / hello-2.html
Created July 19, 2024 11:29
The second sample of API chatbot with Threshold = .5
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>hello-02.html</title>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/universal-sentence-encoder@latest"></script>
<style>
body {