Update index.py
Browse files
index.py
CHANGED
|
@@ -1,7 +1,11 @@
|
|
| 1 |
import re
|
|
|
|
|
|
|
| 2 |
|
| 3 |
def zeta(q):
|
| 4 |
db = [
|
|
|
|
|
|
|
| 5 |
"Artificial intelligence, or AI, is a technology that allows computers to learn, think, and make decisions like humans. Today, AI is used in many parts of our daily lives. It helps us find information online, recommends songs we might like, and even drives cars automatically.AI can understand language, recognize faces, and solve problems faster than people in some cases. However, AI still needs humans to guide it and make sure it is used safely. Many scientists believe that AI will continue to grow and improve, making our future smarter and more efficient. The key is to use it responsibly and for the benefit of everyone.",
|
| 6 |
"Developing AI systems requires a mix of math, programming, and creativity. Engineers begin by collecting data, which helps the AI learn patterns and make predictions. They then design a model, usually using machine-learning frameworks like TensorFlow or PyTorch. After training the model, developers test it to make sure it works correctly and safely.AI development is not only about making machines smart—it also involves careful decision-making. Developers must think about privacy, fairness, and how their technology will be used. Building AI responsibly ensures that it can help people while avoiding harmful effects. As the field grows, AI developers continue to create new tools that push technology forward and open the door to future innovations.",
|
| 7 |
"Cybersecurity is the practice of protecting computers, networks, and data from unauthorized access or attacks. In today's digital world, people store a lot of personal information online, from bank accounts to social media. Hackers can try to steal this information or cause damage.To stay safe, organizations and individuals use strong passwords, firewalls, and encryption. Regular software updates and careful behavior online are also important. Cybersecurity is not just about technology—it is about awareness and responsibility. By following good practices, we can reduce risks and keep our digital world safe.",
|
|
@@ -16,25 +20,53 @@ def zeta(q):
|
|
| 16 |
raw = raw.split(" ")
|
| 17 |
res = ""
|
| 18 |
token = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
if raw[0] == "do" or raw[0] == "what" or raw[0] == "who" or raw[0] == "which" or raw[0] == "where" or raw[0] == "when" or raw[0] == "was" or raw[0] == "were" or raw[0] == "is" or raw[0] == "are":
|
| 21 |
raw.pop(0)
|
| 22 |
token += 1
|
| 23 |
|
| 24 |
raw = [word for word in raw if word not in ["is", "are", "the"]]
|
| 25 |
-
|
| 26 |
keyword = raw[0] if raw else "nothing"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
keyword = re.sub(r'[^a-zA-Z\s]', '', keyword)
|
| 28 |
catc = ""
|
| 29 |
-
|
| 30 |
for i in range(len(db)):
|
| 31 |
-
if keyword in db[i].lower():
|
| 32 |
catc += db[i]
|
| 33 |
token += len(db[i])
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
res += q + ", about " + keyword + "...\n"
|
| 36 |
res += catc + "\n"
|
| 37 |
res += f"{keyword}, a good discuss for us."
|
| 38 |
token += 5
|
| 39 |
-
|
| 40 |
-
return {"token": token, "model": "zeta-
|
|
|
|
| 1 |
import re
|
| 2 |
+
import math
|
| 3 |
+
|
| 4 |
|
| 5 |
def zeta(q):
|
| 6 |
db = [
|
| 7 |
+
"Who am I? I'm a model trained by NeuralNexusLab and developed by NeuralNexusLab. I can use article to answer you or computation math.",
|
| 8 |
+
"Who are you? I don't know who are you but I know you are my best friend! I can explain what is AI to you, or computation math.",
|
| 9 |
"Artificial intelligence, or AI, is a technology that allows computers to learn, think, and make decisions like humans. Today, AI is used in many parts of our daily lives. It helps us find information online, recommends songs we might like, and even drives cars automatically.AI can understand language, recognize faces, and solve problems faster than people in some cases. However, AI still needs humans to guide it and make sure it is used safely. Many scientists believe that AI will continue to grow and improve, making our future smarter and more efficient. The key is to use it responsibly and for the benefit of everyone.",
|
| 10 |
"Developing AI systems requires a mix of math, programming, and creativity. Engineers begin by collecting data, which helps the AI learn patterns and make predictions. They then design a model, usually using machine-learning frameworks like TensorFlow or PyTorch. After training the model, developers test it to make sure it works correctly and safely.AI development is not only about making machines smart—it also involves careful decision-making. Developers must think about privacy, fairness, and how their technology will be used. Building AI responsibly ensures that it can help people while avoiding harmful effects. As the field grows, AI developers continue to create new tools that push technology forward and open the door to future innovations.",
|
| 11 |
"Cybersecurity is the practice of protecting computers, networks, and data from unauthorized access or attacks. In today's digital world, people store a lot of personal information online, from bank accounts to social media. Hackers can try to steal this information or cause damage.To stay safe, organizations and individuals use strong passwords, firewalls, and encryption. Regular software updates and careful behavior online are also important. Cybersecurity is not just about technology—it is about awareness and responsibility. By following good practices, we can reduce risks and keep our digital world safe.",
|
|
|
|
| 20 |
raw = raw.split(" ")
|
| 21 |
res = ""
|
| 22 |
token = 0
|
| 23 |
+
|
| 24 |
+
def evalMath(input):
|
| 25 |
+
match = re.search(r'[\d+\-*/()^\.]+', input)
|
| 26 |
+
if not match:
|
| 27 |
+
return False
|
| 28 |
+
expr = match.group(0)
|
| 29 |
+
expr = expr.replace("^", "**")
|
| 30 |
+
|
| 31 |
+
try:
|
| 32 |
+
if not re.match(r'^[\d+\-*/().\s*]+$', expr):
|
| 33 |
+
return False
|
| 34 |
+
result = eval(expr)
|
| 35 |
+
if isinstance(result, (int, float)) and math.isfinite(result):
|
| 36 |
+
return result
|
| 37 |
+
return False
|
| 38 |
+
except:
|
| 39 |
+
return False
|
| 40 |
+
|
| 41 |
|
| 42 |
if raw[0] == "do" or raw[0] == "what" or raw[0] == "who" or raw[0] == "which" or raw[0] == "where" or raw[0] == "when" or raw[0] == "was" or raw[0] == "were" or raw[0] == "is" or raw[0] == "are":
|
| 43 |
raw.pop(0)
|
| 44 |
token += 1
|
| 45 |
|
| 46 |
raw = [word for word in raw if word not in ["is", "are", "the"]]
|
| 47 |
+
|
| 48 |
keyword = raw[0] if raw else "nothing"
|
| 49 |
+
|
| 50 |
+
if keyword == "you" or keyword == "your":
|
| 51 |
+
keyword = "i"
|
| 52 |
+
else:
|
| 53 |
+
if keyword == "i" or keyword == "me":
|
| 54 |
+
keyword = "you"
|
| 55 |
+
|
| 56 |
keyword = re.sub(r'[^a-zA-Z\s]', '', keyword)
|
| 57 |
catc = ""
|
| 58 |
+
|
| 59 |
for i in range(len(db)):
|
| 60 |
+
if keyword.lower() in db[i].lower():
|
| 61 |
catc += db[i]
|
| 62 |
token += len(db[i])
|
| 63 |
+
|
| 64 |
+
if evalMath(q) != False:
|
| 65 |
+
catc += f'"{q}", the computation\'s answer is {evalMath(q)}.'
|
| 66 |
|
| 67 |
res += q + ", about " + keyword + "...\n"
|
| 68 |
res += catc + "\n"
|
| 69 |
res += f"{keyword}, a good discuss for us."
|
| 70 |
token += 5
|
| 71 |
+
|
| 72 |
+
return {"token": token, "model": "zeta-xf", "return": res}
|