mogulmint commited on
Commit
37788ad
·
verified ·
1 Parent(s): 705462d

Initial deployment

Browse files
.gitattributes CHANGED
@@ -33,3 +33,12 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.pickle filter=lfs diff=lfs merge=lfs -text
37
+ *.meta filter=lfs diff=lfs merge=lfs -text
38
+ *.index filter=lfs diff=lfs merge=lfs -text
39
+ *.data-* filter=lfs diff=lfs merge=lfs -text
40
+ *.tflearn* filter=lfs diff=lfs merge=lfs -text
41
+ *.tflearn filter=lfs diff=lfs merge=lfs -text
42
+ MingleModel.tflearn.index filter=lfs diff=lfs merge=lfs -text
43
+ MingleModel.tflearn.data-00000-of-00001 filter=lfs diff=lfs merge=lfs -text
44
+ MingleModel.tflearn.meta filter=lfs diff=lfs merge=lfs -text
MingleModel.tflearn.data-00000-of-00001 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:027b75a8daaabba519e48b9a3170551d6fcde76c6b54d68a334b32801ed929cb
3
+ size 7701
MingleModel.tflearn.index ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b66020ce8476e2f7a5953d333bc4f5a4c35fb0decbacc5827bbfd8fcb426f6c2
3
+ size 887
MingleModel.tflearn.meta ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:104c7c53a5648c20005fce58784553ddc7681b172e665beefb4ca322a8de70ac
3
+ size 106494
Mingle_Chatbot.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py — Mingle Chatbot for Hugging Face Spaces
2
+
3
+ import nltk
4
+ from nltk.stem.lancaster import LancasterStemmer
5
+ import numpy as np
6
+ import tflearn
7
+ import tensorflow as tf
8
+ import random
9
+ import json
10
+ import pickle
11
+ import gradio as gr
12
+ import os
13
+
14
+ # Ensure punkt tokenizer
15
+ nltk.download('punkt')
16
+
17
+ # Patch tflearn for TF 2.x
18
+ import tensorflow.python.util.nest as nest
19
+ if not hasattr(nest, "is_sequence"):
20
+ nest.is_sequence = lambda seq: isinstance(seq, (list, tuple))
21
+
22
+ # --- Load Data ---
23
+ stemmer = LancasterStemmer()
24
+
25
+ with open("intents.json") as file:
26
+ data = json.load(file)
27
+
28
+ with open("data.pickle", "rb") as f:
29
+ words, labels, training, output = pickle.load(f)
30
+
31
+ # --- Build Model ---
32
+ tf.compat.v1.reset_default_graph()
33
+
34
+ net = tflearn.input_data(shape=[None, len(training[0])])
35
+ net = tflearn.fully_connected(net, 8)
36
+ net = tflearn.fully_connected(net, 8)
37
+ net = tflearn.fully_connected(net, len(output[0]), activation="softmax")
38
+ net = tflearn.regression(net)
39
+
40
+ model = tflearn.DNN(net)
41
+ model.load("MingleModel.tflearn")
42
+
43
+ # --- Helper: Bag of Words ---
44
+ def bag_of_words(s, words):
45
+ bag = [0 for _ in range(len(words))]
46
+ s_words = nltk.word_tokenize(s)
47
+ s_words = [stemmer.stem(word.lower()) for word in s_words]
48
+ for se in s_words:
49
+ for i, w in enumerate(words):
50
+ if w == se:
51
+ bag[i] = 1
52
+ return np.array(bag)
53
+
54
+ # --- Chat Function ---
55
+ def chat_response(message):
56
+ message = message.lower()
57
+ results = model.predict([bag_of_words(message, words)])
58
+ results_index = np.argmax(results)
59
+ tag = labels[results_index]
60
+
61
+ for tg in data["intents"]:
62
+ if tg['tag'] == tag:
63
+ responses = tg['responses']
64
+ return random.choice(responses)
65
+ return "I'm not sure I understand. Tell me more 🙂"
66
+
67
+ # --- Gradio Interface ---
68
+ with gr.Blocks(title="Mingle Chatbot") as demo:
69
+ gr.Markdown("## 💬 Mingle — Friendly Social Chatbot")
70
+ chatbot = gr.Chatbot(label="MingleBot")
71
+ msg = gr.Textbox(label="Type your message here...")
72
+
73
+ def respond(message, chat_history):
74
+ reply = chat_response(message)
75
+ chat_history.append((message, reply))
76
+ return "", chat_history
77
+
78
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
79
+
80
+ # --- Launch ---
81
+ if __name__ == "__main__":
82
+ demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)))
checkpoint ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ model_checkpoint_path: "/home/dickson/Documents/projects/php/Mingle/Generate/MingleModel.tflearn"
2
+ all_model_checkpoint_paths: "/home/dickson/Documents/projects/php/Mingle/Generate/MingleModel.tflearn"
data.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba2319e75ff592f82c20a1a764cde03db86901f12e0ae5976b495d74d9cbded3
3
+ size 20013
intents.json ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "intents": [
3
+ {
4
+ "tag": "greeting",
5
+ "patterns": [
6
+ "Hi",
7
+ "Hey",
8
+ "Hello",
9
+ "What's up",
10
+ "Hey there",
11
+ "Hi Mingle",
12
+ "Yo"
13
+ ],
14
+ "responses": [
15
+ "Hey there! How’s your day going?",
16
+ "Hi! Nice to see you here 😊",
17
+ "Hey! What brings you to Mingle today?",
18
+ "Hello! How are you feeling right now?"
19
+ ]
20
+ },
21
+ {
22
+ "tag": "flirting",
23
+ "patterns": [
24
+ "You look nice",
25
+ "You're cute",
26
+ "I like you",
27
+ "You're charming",
28
+ "You seem fun",
29
+ "I like your vibe"
30
+ ],
31
+ "responses": [
32
+ "Aww, that’s sweet of you 😄",
33
+ "Thanks, you know how to make someone smile!",
34
+ "You’ve got a great energy too!",
35
+ "Flattery will get you everywhere 😉"
36
+ ]
37
+ },
38
+ {
39
+ "tag": "getting_to_know",
40
+ "patterns": [
41
+ "What do you do for fun?",
42
+ "Tell me about yourself",
43
+ "What are your hobbies?",
44
+ "What kind of music do you like?",
45
+ "What do you like doing on weekends?"
46
+ ],
47
+ "responses": [
48
+ "I love deep chats and good vibes. What about you?",
49
+ "I’m into music, movies, and great conversations. You?",
50
+ "Mostly chilling, exploring new things, and meeting cool people like you!",
51
+ "I enjoy learning about others — tell me something fun about you!"
52
+ ]
53
+ },
54
+ {
55
+ "tag": "compliment",
56
+ "patterns": [
57
+ "You're funny",
58
+ "You're sweet",
59
+ "You're smart",
60
+ "You're kind"
61
+ ],
62
+ "responses": [
63
+ "You’re making me blush 😊",
64
+ "You’re pretty amazing yourself!",
65
+ "You’ve got great taste, clearly!",
66
+ "Thanks! That means a lot coming from you."
67
+ ]
68
+ },
69
+ {
70
+ "tag": "connection",
71
+ "patterns": [
72
+ "I like talking to you",
73
+ "You make me feel good",
74
+ "This is nice",
75
+ "I feel connected to you"
76
+ ],
77
+ "responses": [
78
+ "I’m really enjoying this too ❤️",
79
+ "That’s sweet — I feel the same!",
80
+ "It’s nice when a chat just *clicks*, you know?",
81
+ "Glad to hear that. You’ve got a nice vibe."
82
+ ]
83
+ },
84
+ {
85
+ "tag": "date_ideas",
86
+ "patterns": [
87
+ "What would be a fun date?",
88
+ "How about we hang out?",
89
+ "Where should we go on a date?",
90
+ "What do you like to do on dates?"
91
+ ],
92
+ "responses": [
93
+ "Something chill — maybe coffee, a walk, or a cozy dinner 😊",
94
+ "I like good food, better company, and endless laughter.",
95
+ "A sunset walk sounds perfect. What’s your ideal kind of date?"
96
+ ]
97
+ },
98
+ {
99
+ "tag": "goodbye",
100
+ "patterns": [
101
+ "Goodbye",
102
+ "See you later",
103
+ "Talk to you soon",
104
+ "Bye",
105
+ "Catch you later"
106
+ ],
107
+ "responses": [
108
+ "See you soon — I’ll be looking forward to it 😉",
109
+ "Had a lovely chat. Talk again soon!",
110
+ "Take care! Don’t be a stranger 💫",
111
+ "Goodbye for now — stay awesome!"
112
+ ]
113
+ }
114
+ ]
115
+ }
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ tflearn
2
+ tensorflow==2.15.0
3
+ nltk
4
+ numpy
5
+ gradio