Spaces:
Running
Running
Komalpreet Kaur commited on
fix: lower neocortex input word guard to 3 to support short statements
Browse files- app/services/neocortex.py +2 -2
- scratch/test_neocortex_logic.py +35 -0
app/services/neocortex.py
CHANGED
|
@@ -91,8 +91,8 @@ def extract_and_store_knowledge(text: str, user_id: str = "default_user"):
|
|
| 91 |
|
| 92 |
clean = _clean_text(text)
|
| 93 |
|
| 94 |
-
# Need at least
|
| 95 |
-
if len(clean.split()) <
|
| 96 |
print(f"Neocortex: Input too short ({len(clean.split())} words), skipping.")
|
| 97 |
return 0
|
| 98 |
|
|
|
|
| 91 |
|
| 92 |
clean = _clean_text(text)
|
| 93 |
|
| 94 |
+
# Need at least 3 words to extract a relationship (e.g., "I like apples")
|
| 95 |
+
if len(clean.split()) < 3:
|
| 96 |
print(f"Neocortex: Input too short ({len(clean.split())} words), skipping.")
|
| 97 |
return 0
|
| 98 |
|
scratch/test_neocortex_logic.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
import os
|
| 3 |
+
import json
|
| 4 |
+
import asyncio
|
| 5 |
+
|
| 6 |
+
# Add project root to path
|
| 7 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 8 |
+
|
| 9 |
+
# Set dummy env vars for import if needed
|
| 10 |
+
os.environ["GROQ_API_KEY"] = "dummy"
|
| 11 |
+
|
| 12 |
+
from app.services.neocortex import extract_and_store_knowledge
|
| 13 |
+
|
| 14 |
+
# Test direct extraction (mocking settings/groq if needed, but let's see what happens)
|
| 15 |
+
async def main():
|
| 16 |
+
print("Testing neocortex on clean input...")
|
| 17 |
+
# Let's inspect what happens with some inputs
|
| 18 |
+
test_inputs = [
|
| 19 |
+
"I live in Delhi",
|
| 20 |
+
"My dog Baxter loves tennis balls",
|
| 21 |
+
"I like cricket",
|
| 22 |
+
"hello",
|
| 23 |
+
]
|
| 24 |
+
for inp in test_inputs:
|
| 25 |
+
print(f"\nInput: '{inp}'")
|
| 26 |
+
# Since we might not have settings loaded properly in scratch script without proper env,
|
| 27 |
+
# let's just inspect neocortex logic or run it if credentials are set.
|
| 28 |
+
try:
|
| 29 |
+
# We can view what neocortex does
|
| 30 |
+
pass
|
| 31 |
+
except Exception as e:
|
| 32 |
+
print(f"Error: {e}")
|
| 33 |
+
|
| 34 |
+
if __name__ == "__main__":
|
| 35 |
+
asyncio.run(main())
|