Spaces:
Sleeping
Sleeping
Update app2.py
Browse files
app2.py
CHANGED
|
@@ -1,80 +1,23 @@
|
|
|
|
|
| 1 |
import os
|
| 2 |
-
import
|
| 3 |
-
import ctypes
|
| 4 |
import streamlit as st
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 9 |
-
output_path = os.path.join(current_dir, "SynapseControl.cpython-38-x86_64-linux-gnu.so")
|
| 10 |
-
|
| 11 |
-
# Verifique se o diret贸rio existe, se n茫o, crie-o
|
| 12 |
-
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
| 13 |
-
|
| 14 |
-
if not os.path.exists(output_path):
|
| 15 |
-
response = requests.get(url)
|
| 16 |
-
response.raise_for_status() # Para garantir que o download foi bem-sucedido
|
| 17 |
-
|
| 18 |
-
with open(output_path, 'wb') as f:
|
| 19 |
-
f.write(response.content)
|
| 20 |
-
|
| 21 |
-
st.write(f"Downloaded {url} to {output_path}")
|
| 22 |
-
else:
|
| 23 |
-
st.write(f"File already exists at {output_path}")
|
| 24 |
-
|
| 25 |
-
# Execute o download
|
| 26 |
-
download_so()
|
| 27 |
-
|
| 28 |
-
# Verifique se o arquivo foi baixado corretamente
|
| 29 |
-
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 30 |
-
output_path = os.path.join(current_dir, "SynapseControl.cpython-38-x86_64-linux-gnu.so")
|
| 31 |
-
|
| 32 |
-
if os.path.exists(output_path):
|
| 33 |
-
st.write("File downloaded successfully.")
|
| 34 |
-
else:
|
| 35 |
-
st.write("Failed to download the file.")
|
| 36 |
-
|
| 37 |
-
# Carregar a biblioteca compartilhada usando ctypes
|
| 38 |
-
try:
|
| 39 |
-
lib = ctypes.CDLL(output_path)
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
Initial_Memory = lib.Initial_Memory
|
| 44 |
-
Initial_Memory.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p]
|
| 45 |
-
Initial_Memory.restype = ctypes.c_void_p
|
| 46 |
-
st.write("Initial_Memory function loaded successfully.")
|
| 47 |
-
else:
|
| 48 |
-
st.write("Initial_Memory function not found in the library.")
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
Synapses_Active.argtypes = [ctypes.c_char_p, ctypes.c_void_p]
|
| 53 |
-
Synapses_Active.restype = ctypes.c_void_p
|
| 54 |
-
st.write("Synapses_Active function loaded successfully.")
|
| 55 |
-
else:
|
| 56 |
-
st.write("Synapses_Active function not found in the library.")
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
ExecuteModel.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p, ctypes.c_void_p]
|
| 61 |
-
ExecuteModel.restype = ctypes.c_char_p
|
| 62 |
-
st.write("ExecuteModel function loaded successfully.")
|
| 63 |
-
else:
|
| 64 |
-
st.write("ExecuteModel function not found in the library.")
|
| 65 |
-
except Exception as e:
|
| 66 |
-
st.write(f"Error loading library: {e}")
|
| 67 |
|
| 68 |
import keys as key
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
import sys
|
| 73 |
-
import os
|
| 74 |
-
import streamlit as st
|
| 75 |
-
import inspect
|
| 76 |
-
import keys as key
|
| 77 |
-
|
| 78 |
st.title("Neurocognitive Structures")
|
| 79 |
|
| 80 |
|
|
|
|
| 1 |
+
import sys
|
| 2 |
import os
|
| 3 |
+
from openai import OpenAI
|
|
|
|
| 4 |
import streamlit as st
|
| 5 |
+
import inspect
|
| 6 |
|
| 7 |
+
# Diret贸rio onde os pacotes Python s茫o instalados
|
| 8 |
+
package_dir = '/usr/local/lib/python3.10/site-packages'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Caminho absoluto para o diret贸rio neurocognitiveagent
|
| 11 |
+
neurocognitiveagent_dir = os.path.join(package_dir, 'neurocognitiveagent')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# Adiciona o diret贸rio com os arquivos compilados ao sys.path
|
| 14 |
+
sys.path.insert(0, neurocognitiveagent_dir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# Agora voc锚 pode importar seus m贸dulos compilados
|
| 17 |
+
from neurocognitiveagent.SynapseControl import Initial_Memory, Synapses_Active
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
import keys as key
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
st.title("Neurocognitive Structures")
|
| 22 |
|
| 23 |
|