Spaces:
Runtime error
Runtime error
from lib.files import * | |
from lib.memory import * | |
from lib.grapher import * | |
from lib.pipes import * | |
from lib.entropy import * | |
from lib.sonsofstars import * | |
import internetarchive | |
longMem = TextFinder("resources") | |
coreAi = AIAssistant() | |
memory = MemoriaRobotNLP(max_size=200000) | |
grapher = Grapher(memoria_nlp) | |
sensor_request = APIRequester() | |
class I: | |
def __init__(self, prompt, frases_yo, preferencias, propiedades_persona): | |
self.frases_yo = frases_yo | |
self.preferencias = preferencias | |
self.propiedades_persona = propiedades_persona | |
self.dopamina = 0.0 | |
self.frases_yo = frases_yo | |
self.preferencias = preferencias | |
self.propiedades_persona = propiedades_persona | |
self.dopamina = 0.0 | |
def obtener_paths_grafo(self, grafo_ngx): | |
# Funci贸n para obtener los paths de un grafo ngx | |
pass | |
## create questions from internet archive | |
def crear_preguntas(self,txt): | |
search = internetarchive.search_items(sys.argv[1]) | |
res = [] | |
for result in search: | |
print(result['identifier']) | |
idc=result["identifier"] | |
headers = {"accept": "application/json"} | |
## get book pages | |
req2 = requests.get("https://archive.org/stream/"+idc+"/"+idc+"_djvu.txt",headers=headers) | |
#print(req2.text) | |
try: | |
txt = req2.text.split("<pre>")[1].split("</pre>")[0].split(" <!--")[0] | |
for x in txt.split("\n"): | |
if "?" in x: | |
res.append(x) | |
except: | |
pass | |
return res | |
# generate thinks and questions over prompt data, compare with ourself datasets, return matches with sentiment analysys | |
def think_gen(self,txt): | |
think_about = longMem.find_matches(txt) | |
for T in thinkabout: | |
## get subject by entropy or pos tagger | |
subjects = coreAi.entity_pos_tagger(txt) | |
## get NC from , filtering from gramatical tags | |
subjects_low = coreAi.grammatical_pos_tagger(txt) | |
## generate questoins | |
questions=[] | |
## create cuestions from internet archive books | |
for sub in subjects: | |
questions.append(this.crear_preguntas(txt)) | |
## fast checks from gematria similarity | |
##questions_togem = | |
## gematria_search = | |
questions_subj=[] | |
for q in questoins: | |
questions_subj.append(coreAi.entity_pos_tagger(q)) | |
memoryShortTags = memory.buscar_conceptos_patron(subjects) | |
## get tags of subject | |
subj_tags = coreAi.entity_pos_tagger(T) | |
for sub in subjects: | |
memory.agregar_concepto(sub,",".(questions_subj)+",".join(memoryShortTags)) | |
memory.agregar_concepto(sub,T+",".join(memoryShortTags)) | |
## check if something is need to add to ourself datasets | |
## make sentiment analys | |
## check if dopamine prompt is true or false over the information | |
## set weight to information depending of generated dopamine | |
## add dopamine wights to the dopamine concept dataset | |
def crear_path_grafo(self,text): | |
pos_tags = assistant.grammatical_pos_tagger(text) | |
ner_results = coreAi.entity_pos_tagger(text) | |
def crear_circuito_logico(self): | |
# Funci贸n para crear un circuito l贸gico con un algoritmo espec铆fico | |
pass | |
def tomar_decision_sentimiento(self, sentimiento): | |
sentiments = coreAi.sentiment_tags(sentimiento) | |
# Funci贸n para tomar una decisi贸n booleana con un an谩lisis de sentimiento | |
similarity = coreAi.similarity_tag(self, sentenceA,sentenceB) | |
## Check by similarity over memory tag paths | |
return sentiments | |
def hacer_predicciones_texto(self, texto): | |
# Funci贸n para hacer predicciones de texto futuro por similitud | |
pass | |
def agregar_preferencia(self, preferencia): | |
# Funci贸n para a帽adir una entrada al dataset de preferencias | |
self.preferencias.append(preferencia) | |
def agregar_frase_yo(self, frase): | |
# Funci贸n para a帽adir una frase al dataset de frases de yo | |
self.frases_yo.append(frase) | |
def eliminar_preferencia(self, preferencia): | |
# Funci贸n para eliminar una entrada del dataset de preferencias | |
if preferencia in self.preferencias: | |
self.preferencias.remove(preferencia) | |
def eliminar_frase_yo(self, frase): | |
# Funci贸n para eliminar una frase del dataset de frases de yo | |
if frase in self.frases_yo: | |
self.frases_yo.remove(frase) | |
def generar_pregunta(self, prompt): | |
# Funci贸n para generar preguntas sobre un prompt | |
pregunta = prompt + " 驴Qu茅 opinas sobre esto?" | |
return pregunta | |
def responder_pregunta(self, pregunta): | |
# Funci贸n para responder preguntas | |
respuesta = "No estoy seguro de qu茅 opinar sobre eso." | |
return respuesta | |
def discriminar_y_agregar(self, informacion, dataset): | |
# Funci贸n para discriminar y agregar informaci贸n a los datasets | |
if "yo" in informacion.lower(): | |
self.agregar_frase_yo(informacion) | |
elif "preferencia" in informacion.lower(): | |
self.agregar_preferencia(informacion) | |
elif "propiedad" in informacion.lower(): | |
# Aqu铆 podr铆as agregar l贸gica para actualizar las propiedades de la persona | |
pass | |
else: | |
# Aqu铆 podr铆as manejar otros tipos de informaci贸n | |
pass | |
if __name__ == "__main__": | |
# Ejemplo de uso: | |
frases_yo = ["Yo soy inteligente", "Yo puedo lograr lo que me proponga"] | |
preferencias = ["Cine", "M煤sica", "Viajar"] | |
propiedades_persona = {"carisma": 0.8, "destreza": 0.6, "habilidad": 0.9} | |
yo = Yo(frases_yo, preferencias, propiedades_persona) | |
# Generar pregunta | |
pregunta_generada = yo.generar_pregunta("Hoy es un d铆a soleado.") | |
print("Pregunta generada:", pregunta_generada) | |
# Responder pregunta | |
respuesta = yo.responder_pregunta(pregunta_generada) | |
print("Respuesta:", respuesta) | |
# Discriminar y agregar informaci贸n | |
informacion = "Me gusta ir al cine." | |
yo.discriminar_y_agregar(informacion, yo.preferencias) | |
print("Preferencias actualizadas:", yo.preferencias) | |