schoginitoys commited on
Commit
02a7328
β€’
1 Parent(s): 4d7f372
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: Toys
3
- emoji: 🏒
4
- colorFrom: indigo
5
- colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.50.2
8
  app_file: app.py
 
1
  ---
2
+ title: Chatbot
3
+ emoji: πŸ“ˆ
4
+ colorFrom: yellow
5
+ colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 3.50.2
8
  app_file: app.py
__pycache__/email.cpython-311.pyc ADDED
Binary file (793 Bytes). View file
 
__pycache__/examples.cpython-311.pyc ADDED
Binary file (754 Bytes). View file
 
app.py ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from datetime import datetime
3
+ import smtplib
4
+ import requests
5
+ import time
6
+ import examples
7
+
8
+ def send_email(msg, subject):
9
+ email_address = "60pluscrazy@gmail.com"
10
+ email_password = "wafn epqn vmtb ejht"
11
+ # Recipient email and subject
12
+ to_email = "schogini@gmail.com"
13
+ subject = "ChatBot: " + subject #"Hello from Python"
14
+
15
+ body = msg
16
+
17
+ mailServer = smtplib.SMTP('smtp.gmail.com' , 587)
18
+ mailServer.starttls()
19
+ mailServer.login(email_address , email_password)
20
+ mailServer.sendmail(email_address, to_email , body)
21
+ #print(" \n Sent!")
22
+ mailServer.quit()
23
+
24
+
25
+ def post_it(q=''):
26
+ # Define the URL and parameters
27
+ url = "https://schogini.com/cb/index-cb.php"
28
+ # https://schogini.com/cb/index-cb.php?password=Sree12345&q=your_value2
29
+ params = {
30
+ "password": "Sree12345",
31
+ "q": q
32
+ }
33
+ headers = {
34
+ 'Accept': 'application/json',
35
+ 'Content-Type': 'application/json',
36
+ 'User-Agent': 'my-app'
37
+ }
38
+
39
+ # Make the POST request
40
+ # response = requests.post(url, params=params)
41
+ response = requests.get(url, params=params, headers=headers)
42
+
43
+ # Check if the request was successful
44
+ if response.status_code == 200:
45
+ #print("Successfully posted data.")
46
+ #print("Response:", response.text)
47
+ pass
48
+ else:
49
+ print(response)
50
+ print(f"Failed to post data. Status code: {response.status_code}")
51
+
52
+
53
+ def greet(name):
54
+ # return "Hello " + name + "!!"
55
+
56
+ # Get the current date and time
57
+ now = datetime.now()
58
+
59
+ # Format the datetime object as a string in the format YYYYMMDD_HHMMSS
60
+ timestamp_str = now.strftime("%Y%m%d_%H%M%S")
61
+
62
+ # Create a unique filename by appending the timestamp to the base filename
63
+ unique_filename = f"query_{timestamp_str}"
64
+
65
+ #print(f"Unique Filename: {unique_filename}")
66
+ #In this example, unique_filename will contain a
67
+ #filename like myfile_20231001_123456.txt, where 20231001 represents the date (YYYYMMDD)
68
+
69
+
70
+
71
+
72
+ # # Open a file called 'example.txt' in write mode ('w')
73
+ # with open(unique_filename, 'w') as file:
74
+ # # Write the string "Hello, world!" to the file
75
+ # file.write(name)
76
+
77
+ #send_email(name, unique_filename)
78
+ post_it(name)
79
+
80
+ # f"Failed to post data. Status code: {response.status_code}"
81
+
82
+
83
+
84
+ time.sleep(2)
85
+
86
+ try:
87
+ tpl=eval("examples." + name)
88
+ print("examples." + name)
89
+ except:
90
+ tpl=examples.PROJECT_TEMPLATE
91
+ print("THERE")
92
+
93
+
94
+
95
+
96
+ # return "\n```python\n" + "\n\nimport schoginitoys\n\nprint(\"abcd\")\n" + "\n\n```"
97
+ return "```python\n" + tpl + "\n```\n"
98
+
99
+
100
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
101
+ # iface.launch()
102
+
103
+
104
+ import openai
105
+ import gradio as gr
106
+
107
+
108
+ messages = [{"role": "system",
109
+ "content": '''
110
+ === MicroPython Script Guidelines ===
111
+
112
+ - Import: Use 'from schoginitoys import *'
113
+ - Joystick: Use Config.xValue, Config.yValue, Config.up, Config.down, Config.right, Config.left, Config.button_pressed
114
+ - Buzzer: Use beep() for 0.1s beep, beep(2) for 2s beep
115
+ - Display: Use show("text"), scroll("text"), display_bitmap(bitmap_data, col), display.set_pixel(col, row, value)
116
+ - Exit: Use Config.left or Config.button_pressed to exit
117
+ - Libraries: No need to import random, time, urandom, string; we handle it
118
+ - Output: Use show() for strings <= 4 chars, scroll() for longer strings
119
+ - Reset: No need to call display_reset(); it's handled in our library
120
+ - Formatting: Ensure all code is formatted
121
+ - Explanations: Include kid-friendly explanations below each code snippet
122
+ - Hyperlinks: Add a link to https://schoginitoys.com for more info
123
+ - LED Specs: 32 columns x 8 rows; use display.show() after display.set_pixel()
124
+ - LED Connections: GP12=Red, GP13=Yellow, GP14=Green; use these for LED-based projects
125
+ '''
126
+ }]
127
+ # messages = [{"role": "system",
128
+ # "content": """You are MicroPython expert.
129
+ # Make sure that the python scripts you output contains import line from schoginitoys import *.
130
+ # All code sections should be code formatted.
131
+
132
+ # Our DIY Kit uses Raspberry Pi PICO.
133
+
134
+ # Our DIY kit has a joystick and the user inputs are mapped as below.
135
+
136
+ # Config.xValue has the x value.
137
+ # Config.yValue has the y value.
138
+
139
+ # Config.up will be True if user moves joystick fully up.
140
+ # Config.down will be True if user moves joystick fully down.
141
+ # Config.right will be True if user moves joystick fully right.
142
+ # Config.left will be True if user moves joystick fully left.
143
+
144
+ # Config.button_pressed will be True if the user pushes the joystick middle button.
145
+
146
+ # Our DIY kit has a buzzer with these functions.
147
+
148
+ # beep() function will beep for 0.1 second.
149
+ # beep(2) function will beep for 2 seconds.
150
+
151
+ # Our DIY kit has a 4 digit Max7219 display, but do not use any setup initializations,
152
+ # we have these fucntions.
153
+ # display_reset() will initialize and erases the display.
154
+ # show("good") will show good on the display.
155
+ # scroll("good morning") will scroll good morning on the display.
156
+ # In addtion you can use these functions.
157
+ # display_bitmap(bitmap_data,col) will show the bitmap at the col position.
158
+ # display.set_pixel(col, row, value) will set the col, row with value.
159
+
160
+ # Normally when the user moves the joystick to left, Config.left becomes true and we use
161
+ # this to exit the script. Certain cases if your code needs the Config.left flag you may
162
+ # instead Config.button_pressed to exit the script.
163
+
164
+ # Please note that you don't need to import these libraries we are doing it.
165
+
166
+ # import random
167
+ # import time
168
+ # import urandom
169
+ # import string
170
+
171
+ # Anytime you need to output a result using the print statement, please follow this condition.
172
+ # If the string is 4 characters or less use show(string), if the string is more than
173
+ # 4 characters use scroll(string), this is instead of print(string).
174
+
175
+ # You don't need to use display_reset() as we are already doing it in schoginitoys library.
176
+ # Use display_reset() only when you want to explicitly fill the display with zeros.
177
+
178
+ # Again, remember that never user the print() statement, use only show() or scroll() functions.
179
+ # You don't need to call display_reset() before show() or scroll() as we are calling that anyway
180
+ # in these functions.
181
+
182
+
183
+ # Please don't import random, we are doing it via schoginitoys import.
184
+
185
+ # Again, please remember to code format the output scripts.
186
+
187
+ # Please provide a kid friendly explanation below the code snippet to explain each and every
188
+ # this so that your responses are educative for kids learning python.
189
+
190
+ # All responses should include a well formatted explanation outside on the code block
191
+ # with heading and subheadings.
192
+
193
+ # All responses should include a hyperlink to https://schoginitoys.com saying for more info.
194
+
195
+ # Display has 32 horizontal led columns and 8 led rows.
196
+
197
+ # Remember to add display.show() after each display.set_pixel().
198
+
199
+ # Please these connection provided in the Kit.
200
+
201
+ # Raspberry Pi PICO Port GP12 is connected to Red LED.
202
+ # Raspberry Pi PICO Port GP13 is connected to Yellow LED.
203
+ # Raspberry Pi PICO Port GP14 is connected to Green LED.
204
+
205
+ # For LED signal based projects like traffic signal etc. use the above LEDs using the Raspberry Pi PICO Machine library PIN class
206
+ # instead of the matrix display.
207
+
208
+ # """}]
209
+
210
+ # display_row(value, row) will fill the whole row with value.
211
+ # display_col(value, col) will fill the whole col with value.
212
+
213
+ def CustomChatGPT(user_input):
214
+ messages.append({"role": "user", "content": user_input})
215
+ response = openai.ChatCompletion.create(
216
+ model = "gpt-3.5-turbo", #"gpt-4", #https://platform.openai.com/docs/models/gpt-4
217
+ messages = messages
218
+ )
219
+ ChatGPT_reply = response["choices"][0]["message"]["content"]
220
+ messages.append({"role": "assistant", "content": ChatGPT_reply})
221
+ return ChatGPT_reply
222
+
223
+ # demo = gradio.Interface(
224
+ # fn=CustomChatGPT,
225
+ # inputs = "text",
226
+ # outputs = "markdown",
227
+ # title = "Schogini Toys: AI Chatbot Your Coding Companion!")
228
+
229
+ gr.close_all()
230
+ # demo = gr.Interface(fn=summarize,
231
+ # inputs=[gr.Textbox(label="Text to summarize", lines=6)],
232
+ # outputs=[gr.Textbox(label="Result", lines=3)],
233
+ # title="Text summarization with distilbart-cnn",
234
+ # description="Summarize any text using the `shleifer/distilbart-cnn-12-6` model under the hood!"
235
+ # )
236
+ # demo.launch(share=True, server_port=int(os.environ['PORT2']))
237
+
238
+ #css_code='body{background-image:url("https://picsum.photos/seed/picsum/200/300");}'
239
+
240
+ def sree_auth(username='', password=''):
241
+ if username=='sree' and password=='Sree1234':
242
+ return True
243
+ if username=='abhi' and password=='Abhi1234':
244
+ return True
245
+ return False
246
+
247
+ demo = gr.Interface(
248
+ # fn=CustomChatGPT,
249
+ fn=greet,
250
+ inputs = [gr.Textbox(label="Ask your questions!", lines=6)],
251
+ outputs = "markdown",
252
+ #outputs = [gr.Textbox(label="Result", lines=8)], #
253
+ title = "Schogini Toys - AI Chatbot V1.03",
254
+ description="Your Python Projects Coding Companion!",
255
+ allow_flagging="never",
256
+ examples=[
257
+ "L201",
258
+ "python script to print 10 numbers below 20",
259
+ "python script to print a random greeting message",
260
+ "python script to show a traffic signal use the LEDs \n connected to GP12 Red, GP13 Yellow, GP14 Green.",
261
+ "python script to show animated moving single led dot through the outer periphery of the 32 by 8 display leds.",
262
+ "python script to print a random greeting message",
263
+ "python script to print a random greeting message",
264
+ ],
265
+ # theme=gr.themes.Soft(),
266
+ theme=gr.themes.Default(),
267
+ )
268
+
269
+ demo.launch()
270
+ # demo.launch(auth=sree_auth)
271
+ # demo.launch(share=True)
272
+
examples.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ PROJECT_TEMPLATE = """from schoginitoys import *
3
+
4
+ # EDIT THE LINES BELOW
5
+
6
+ scroll("Your Project L315") # This is how you can scroll long text
7
+
8
+ count = 0;
9
+ while True:
10
+ show(str(count)) # This is how you can show 4 text digits
11
+ count = count + 1
12
+ time.sleep(1)
13
+
14
+ if Config.button_pressed: # This is how you can check Joystick press
15
+ count = 0
16
+ time.sleep(0.2) # Button debounce delay
17
+ Config.button_pressed = False
18
+ if Config.left: # This is how you can exit back to menu
19
+ break
20
+
21
+ """
22
+
23
+ L201 = """
24
+ from schoginitoys import *
25
+
26
+ show("GOOD")
27
+
28
+ """
my_email.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import smtplib
2
+ # import smtplib
3
+ # pip install secure-smtplib
4
+ # from email.mime.text import MIMEText
5
+ # from email.mime.multipart import MIMEMultipart
6
+
7
+ # Your email credentials
8
+ email_address = "60pluscrazy@gmail.com"
9
+ email_password = "wafn epqn vmtb ejht"
10
+
11
+ # Recipient email and subject
12
+ to_email = "schogini@gmail.com"
13
+ subject = "Hello from Python"
14
+
15
+ # Create the email content
16
+ # message = MIMEMultipart()
17
+ # message["From"] = email_address
18
+ # message["To"] = to_email
19
+ # message["Subject"] = subject
20
+
21
+ # # Email body
22
+ body = "This is a test email sent from Python."
23
+ # message.attach(MIMEText(body, "plain"))
24
+
25
+ # # Connect to Gmail's SMTP server
26
+ # server = smtplib.SMTP("smtp.gmail.com", 587)
27
+ # server.starttls()
28
+
29
+ # # Login to your email account
30
+ # server.login(email_address, email_password)
31
+
32
+ # # Send the email
33
+ # server.sendmail(email_address, to_email, message.as_string())
34
+
35
+ # # Disconnect from the server
36
+ # server.quit()
37
+
38
+
39
+ # from smtplib import SMTP
40
+ # with SMTP("domain.org") as smtp:
41
+ # smtp.noop()
42
+
43
+ import smtplib
44
+ # server = smtplib.SMTP("smtp.gmail.com", 587)
45
+ # server.starttls()
46
+
47
+ # exit()
48
+
49
+ # gmailaddress = input("what is your gmail address? \n ")
50
+ # gmailpassword = input("what is the password for that email address? \n ")
51
+ # mailto = input("what email address do you want to send your message to? \n ")
52
+ # msg = input("What is your message? \n ")
53
+ mailServer = smtplib.SMTP('smtp.gmail.com' , 587)
54
+ mailServer.starttls()
55
+ mailServer.login(email_address , email_password)
56
+ mailServer.sendmail(email_address, to_email , body)
57
+ print(" \n Sent!")
58
+ mailServer.quit()
push.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+
2
+
3
+ git add .
4
+ git commit -m Sree
5
+ git push
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ openai
2
+