bentosmau commited on
Commit ·
897b829
1
Parent(s): 827185c
Add new search functionality and update response generation
Browse filesIntegrates DuckDuckGo search, refactors response handling for variation, and updates project licensing and structure.
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: e3ff2484-bbd8-4aba-bea0-1940769b874a
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 295dbfe0-1f93-4221-89b7-3c607a53b7f6
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1739408b-93a5-479b-a658-30f2493b0467/e3ff2484-bbd8-4aba-bea0-1940769b874a/gspaGFo
Replit-Helium-Checkpoint-Created: true
- LICENSE.md +15 -0
- chat-app/app.py +2 -2
- chat-app/logica.py +1 -0
- chat-app/main.py +40 -0
- chat-app/publicar_hf.py +1 -1
- chat-app/respuestas.json +1 -1
- chat-app/roblox_api.py +1 -1
- chat-app/search_call.py +61 -0
- datasets.py +10 -0
- datasets/wikivoyage.py +0 -0
- matematicas.py +0 -2
LICENSE.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# All Rights Reserved
|
| 2 |
+
# [C] Bentosmau-gif 26/All Rights Reserved
|
| 3 |
+
# Copyright (c) MDFJ 2026.
|
| 4 |
+
|
| 5 |
+
# Proyecto: EYES
|
| 6 |
+
|
| 7 |
+
All Rights Reserved.
|
| 8 |
+
|
| 9 |
+
This project, including but not limited to source code, datasets, models, documentation, and any associated content, is the exclusive property of the author.
|
| 10 |
+
|
| 11 |
+
MDFJ does not permit EYES to be copied, distributed, sold, modified, or reused in any way without the author's prior and explicit authorization.
|
| 12 |
+
|
| 13 |
+
# Consequences: Any unauthorized use of this project may result in legal action under applicable copyright laws.
|
| 14 |
+
|
| 15 |
+
To request permission, please contact the author. Thank you.
|
chat-app/app.py
CHANGED
|
@@ -20,8 +20,8 @@ def añadir_turno(historial, user_msg, bot_msg=""):
|
|
| 20 |
|
| 21 |
def stream_tokens(texto, historial):
|
| 22 |
"""
|
| 23 |
-
Emite la respuesta token por token (palabra por palabra)
|
| 24 |
-
|
| 25 |
Tokens largos = pausas ligeramente mayores (más "peso" semántico).
|
| 26 |
"""
|
| 27 |
tokens = texto.split(" ")
|
|
|
|
| 20 |
|
| 21 |
def stream_tokens(texto, historial):
|
| 22 |
"""
|
| 23 |
+
Emite la respuesta token por token (palabra por palabra)
|
| 24 |
+
el proceso de generación de un modelo de lenguaje real.
|
| 25 |
Tokens largos = pausas ligeramente mayores (más "peso" semántico).
|
| 26 |
"""
|
| 27 |
tokens = texto.split(" ")
|
chat-app/logica.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import os
|
| 2 |
import re
|
| 3 |
import json
|
|
|
|
| 1 |
+
import datasets
|
| 2 |
import os
|
| 3 |
import re
|
| 4 |
import json
|
chat-app/main.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from search_call import search_duckduckgo
|
| 2 |
+
from cleaner import clean_results
|
| 3 |
+
from summarizer import summarize
|
| 4 |
+
from reasoning import explain
|
| 5 |
+
|
| 6 |
+
# Fake model placeholder (NEO-2.0 will go here)
|
| 7 |
+
class NeoModel:
|
| 8 |
+
def generate(self, prompt:str) -> str:
|
| 9 |
+
return f"[NEO OUTPUT]\n{prompt}"
|
| 10 |
+
|
| 11 |
+
neo = NeoModel()
|
| 12 |
+
|
| 13 |
+
def neo_pipeline(query:str) -> str:
|
| 14 |
+
# Step 1: Search
|
| 15 |
+
search_results = search_duckduckgo(query)
|
| 16 |
+
|
| 17 |
+
# Step 2: Clean results
|
| 18 |
+
cleaned_results = clean_results(search_results)
|
| 19 |
+
|
| 20 |
+
# Step 3: Context
|
| 21 |
+
context = "\n".join(
|
| 22 |
+
|
| 23 |
+
return "\n".join(f"{r["title"]}: {r["text"]}" for r in cleaned
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# Step 4: Summarize
|
| 27 |
+
summary = summarize(neo, context)
|
| 28 |
+
|
| 29 |
+
# Step 5: Reasoning
|
| 30 |
+
final = explain(neo, summary)
|
| 31 |
+
|
| 32 |
+
return final
|
| 33 |
+
|
| 34 |
+
if __name__ == "__main__":
|
| 35 |
+
while True:
|
| 36 |
+
user_query = input("Enter your question (or 'exit' to quit): ")
|
| 37 |
+
if user_query.lower() == "exit":
|
| 38 |
+
break
|
| 39 |
+
answer = neo_pipeline(user_query)
|
| 40 |
+
print(f"Answer:\n{answer}\n")
|
chat-app/publicar_hf.py
CHANGED
|
@@ -35,4 +35,4 @@ upload_folder(
|
|
| 35 |
|
| 36 |
print("")
|
| 37 |
print("✅ ¡Publicado exitosamente en Hugging Face Spaces!")
|
| 38 |
-
print(f"🔗 https://huggingface.co/spaces/{REPO_ID}")
|
|
|
|
| 35 |
|
| 36 |
print("")
|
| 37 |
print("✅ ¡Publicado exitosamente en Hugging Face Spaces!")
|
| 38 |
+
print(f"🔗 https://huggingface.co/spaces/{REPO_ID}")
|
chat-app/respuestas.json
CHANGED
|
@@ -104,7 +104,7 @@
|
|
| 104 |
"no monetizar",
|
| 105 |
"sin derivadas"
|
| 106 |
],
|
| 107 |
-
"respuesta": "Aquí tienes las licencias más importantes y sus explicaciones:\n\n**COPYRIGHT:**\nEs una licencia que la mayoría de páginas web, videos, series y películas utilizan para que nadie monetice, publique u otras cosas sin autorización del creador original. (YouTube, TikTok y otras apps a veces pueden banear por copyright)\n\n*Ejemplo:* Juan sube un contenido de arte. María lo sube, pero no la dejan monetizar y avisan a Juan que un usuario subió su contenido sin acuerdos legales.\n\n---\n\n**CC (Creative Commons):**\nUna licencia donde puedes usar el contenido, adaptarlo y modificarlo.\n\nReglas de CC ⚠️:\n- **BY (Atribución):** Debes mencionar al autor original del contenido.\n- **NC (No Monetizar):** El usuario no puede usar el contenido para monetizarlo.\n- **ND (Sin derivadas):** El usuario no puede modificar el contenido.\n- **SA (Compartir):** Si modificas el contenido, tiene que tener la misma licencia
|
| 108 |
},
|
| 109 |
{
|
| 110 |
"preguntas": [
|
|
|
|
| 104 |
"no monetizar",
|
| 105 |
"sin derivadas"
|
| 106 |
],
|
| 107 |
+
"respuesta": "Aquí tienes las licencias más importantes y sus explicaciones:\n\n**COPYRIGHT:**\nEs una licencia que la mayoría de páginas web, videos, series y películas utilizan para que nadie monetice, publique u otras cosas sin autorización del creador original. (YouTube, TikTok y otras apps a veces pueden banear por copyright)\n\n*Ejemplo:* Juan sube un contenido de arte. María lo sube, pero no la dejan monetizar y avisan a Juan que un usuario subió su contenido sin acuerdos legales.\n\n---\n\n**CC (Creative Commons):**\nUna licencia donde puedes usar el contenido, adaptarlo y modificarlo.\n\nReglas de CC ⚠️:\n- **BY (Atribución):** Debes mencionar al autor original del contenido.\n- **NC (No Monetizar):** El usuario no puede usar el contenido para monetizarlo.\n- **ND (Sin derivadas):** El usuario no puede modificar el contenido.\n- **SA (Compartir):** Si modificas el contenido, tiene que tener la misma licencia. \n\n*Ejemplo:* Si una imagen tiene CC-BY, te deja usar el contenido y la única regla es mencionar al autor original.\n\n---\n\n**GPL (GNU General Public License):**\nLicencia de software libre creada por Free Software Foundation. Usada en proyectos como Linux.\n- ✅ Puedes usar el software libremente.\n- ✅ Modificarlo.\n- ✅ Distribuirlo.\n\nLa regla: Si haces una versión modificada del proyecto, es obligatorio publicarla con licencia GPL. Se llama \"copyleft\" para asegurarse de que el software siempre siga siendo libre. GPL es ideal para software y código.\n\n---\n\n**MIT:**\nUna licencia muy popular porque no tiene ninguna restricción. Los usuarios pueden:\n- ✅ Usar.\n- ✅ Vender.\n- ✅ Modificar.\n- ✅ Integrar el código en proyectos privados.\n\n---\n\n**Apache License 2.0:**\n- ✅ Similar a MIT.\n- ✅ Incluye protección contra patentes, útil para empresas.\n\n---\n\n📋 **Resumen:**\n- **GPL:** Obliga a que la versión modificada del proyecto sea abierta.\n- **MIT:** Puedes hacer casi lo que quieras con el código.\n- **Apache 2.0:** Parecido a MIT, pero con protección extra de patentes."
|
| 108 |
},
|
| 109 |
{
|
| 110 |
"preguntas": [
|
chat-app/roblox_api.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import requests
|
| 2 |
|
| 3 |
HEADERS = {
|
| 4 |
-
"User-Agent": "
|
| 5 |
"Accept": "application/json",
|
| 6 |
}
|
| 7 |
|
|
|
|
| 1 |
import requests
|
| 2 |
|
| 3 |
HEADERS = {
|
| 4 |
+
"User-Agent": "neo1/1.0",
|
| 5 |
"Accept": "application/json",
|
| 6 |
}
|
| 7 |
|
chat-app/search_call.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# /* SPDX-License-Identifier: Apache-2.0
|
| 2 |
+
# Copyright (C) MDFJ 2026
|
| 3 |
+
# Proyecto MDFJ: NEO (1)
|
| 4 |
+
# Licencia: Licencia Apache 2.0
|
| 5 |
+
|
| 6 |
+
from fastapi import Query
|
| 7 |
+
from duckduckgo_search import DDGS
|
| 8 |
+
from typing import List, Dict
|
| 9 |
+
import time
|
| 10 |
+
import random
|
| 11 |
+
|
| 12 |
+
# ====================
|
| 13 |
+
# SEARCH CACHE
|
| 14 |
+
# =====================
|
| 15 |
+
CACHE = {}
|
| 16 |
+
|
| 17 |
+
def search_duckduckgo(query: str, max_results: int = 5) -> List[Dict]:
|
| 18 |
+
"""
|
| 19 |
+
Real DuckDuckGo API wrapper with simple caching layer.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
# Check cache first
|
| 23 |
+
if query in CACHE:
|
| 24 |
+
return CACHE[query]
|
| 25 |
+
|
| 26 |
+
# Simulate slight delay (real-world API)
|
| 27 |
+
time.sleep(random.uniform(0.2, 0.8))
|
| 28 |
+
|
| 29 |
+
with DDGS() as ddgs:
|
| 30 |
+
results = ddgs.text(query, max_results=max_results)
|
| 31 |
+
|
| 32 |
+
formatted = []
|
| 33 |
+
|
| 34 |
+
for r in results:
|
| 35 |
+
formatted.append({
|
| 36 |
+
"title": r.get("title", ""),
|
| 37 |
+
"body": r.get("body", ""),
|
| 38 |
+
"url": r.get("href", "")
|
| 39 |
+
})
|
| 40 |
+
|
| 41 |
+
# Save to cache
|
| 42 |
+
CACHE[query] = formatted
|
| 43 |
+
|
| 44 |
+
return formatted
|
| 45 |
+
|
| 46 |
+
def clear_cache():
|
| 47 |
+
"""Clear search cache"""
|
| 48 |
+
global CACHE
|
| 49 |
+
CACHE = {}
|
| 50 |
+
|
| 51 |
+
# ====================
|
| 52 |
+
# Detect if it needs internet
|
| 53 |
+
# =====================
|
| 54 |
+
|
| 55 |
+
def should_search(query: str) -> bool;
|
| 56 |
+
"""
|
| 57 |
+
Decide if NEO needs to use the internet.
|
| 58 |
+
"""
|
| 59 |
+
keywords = [
|
| 60 |
+
""
|
| 61 |
+
]
|
datasets.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets import load_dataset
|
| 2 |
+
|
| 3 |
+
dataset = load_dataset("json", data_files="dataset.json")
|
| 4 |
+
|
| 5 |
+
print(dataset)
|
| 6 |
+
print(dataset["train"][0])
|
| 7 |
+
|
| 8 |
+
def to_chat_format(example);
|
| 9 |
+
return {
|
| 10 |
+
"text": f"User": {example["preguntas"][0]}
|
datasets/wikivoyage.py
ADDED
|
File without changes
|
matematicas.py
CHANGED
|
@@ -1,6 +1,4 @@
|
|
| 1 |
|
| 2 |
-
# Calculadora Inteligente de Mau 😎
|
| 3 |
-
|
| 4 |
def sumar(a, b):
|
| 5 |
print(f"Suma: {a} + {b} = {a + b}")
|
| 6 |
return a + b
|
|
|
|
| 1 |
|
|
|
|
|
|
|
| 2 |
def sumar(a, b):
|
| 3 |
print(f"Suma: {a} + {b} = {a + b}")
|
| 4 |
return a + b
|