paulbricman commited on
Commit
74ad48b
1 Parent(s): bafe7ee

fix: remove base nested folder in knowledge

Browse files

.gitignore CHANGED
@@ -1,5 +1,5 @@
1
  __pycache__/*
2
  backend/__pycache__/*
3
- knowledge/base/*
4
  backend/records.json
5
  backend/microverses.json
1
  __pycache__/*
2
  backend/__pycache__/*
3
+ knowledge/*
4
  backend/records.json
5
  backend/microverses.json
backend/main.py CHANGED
@@ -101,7 +101,7 @@ async def remove_handler(filename: str, token: str, request: Request):
101
  @app.get('/static')
102
  @limiter.limit("200/minute")
103
  async def static_handler(filename: str, token: str, request: Request):
104
- knowledge_base_path = Path('..') / 'knowledge' / 'base'
105
 
106
  auth_result = auth(token)
107
  thoughts = get_authorized_thoughts(auth_result)
101
  @app.get('/static')
102
  @limiter.limit("200/minute")
103
  async def static_handler(filename: str, token: str, request: Request):
104
+ knowledge_base_path = Path('..') / 'knowledge'
105
 
106
  auth_result = auth(token)
107
  thoughts = get_authorized_thoughts(auth_result)
backend/microverses.py CHANGED
@@ -9,7 +9,7 @@ import os
9
 
10
 
11
  def create_microverse(modality, query, auth_result, text_encoder, text_image_encoder):
12
- knowledge_base_path = Path('..') / 'knowledge' / 'base'
13
  microverses_path = Path('microverses.json')
14
 
15
  if auth_result['custodian'] == False:
@@ -59,7 +59,7 @@ def create_microverse(modality, query, auth_result, text_encoder, text_image_enc
59
 
60
  def remove_microverse(auth_result, microverse_token):
61
  microverses_path = Path('microverses.json')
62
- knowledge_base_path = Path('..') / 'knowledge' / 'base'
63
 
64
  if auth_result['custodian'] == False:
65
  return {
9
 
10
 
11
  def create_microverse(modality, query, auth_result, text_encoder, text_image_encoder):
12
+ knowledge_base_path = Path('..') / 'knowledge'
13
  microverses_path = Path('microverses.json')
14
 
15
  if auth_result['custodian'] == False:
59
 
60
  def remove_microverse(auth_result, microverse_token):
61
  microverses_path = Path('microverses.json')
62
+ knowledge_base_path = Path('..') / 'knowledge'
63
 
64
  if auth_result['custodian'] == False:
65
  return {
backend/util.py CHANGED
@@ -15,7 +15,7 @@ import time
15
 
16
  def find(modality, query, relatedness, activation, noise, return_embeddings, auth_result, text_encoder, text_image_encoder, silent=False):
17
  authorized_thoughts = get_authorized_thoughts(auth_result)
18
- knowledge_base_path = Path('..') / 'knowledge' / 'base'
19
  query_embeddings = encode(
20
  modality, query, text_encoder, text_image_encoder)
21
 
@@ -78,7 +78,7 @@ def rank(authorized_thoughts, relatedness, activation, noise):
78
 
79
 
80
  def save(modality, query, auth_result, text_encoder, text_image_encoder, silent=False):
81
- knowledge_base_path = Path('..') / 'knowledge' / 'base'
82
 
83
  if auth_result['custodian'] == False:
84
  return {
@@ -148,7 +148,7 @@ def save(modality, query, auth_result, text_encoder, text_image_encoder, silent=
148
 
149
 
150
  def remove(auth_result, filename):
151
- knowledge_base_path = Path('..') / 'knowledge' / 'base'
152
 
153
  if auth_result['custodian'] == False:
154
  return {
@@ -169,7 +169,7 @@ def remove(auth_result, filename):
169
 
170
 
171
  def get_authorized_thoughts(auth_result):
172
- metadata_path = Path('..') / 'knowledge' / 'base' / 'metadata.json'
173
 
174
  if not (metadata_path).exists():
175
  open(metadata_path, 'w').write(json.dumps([]))
@@ -226,7 +226,7 @@ def encode(modality, content, text_encoder, text_image_encoder):
226
 
227
 
228
  def get_content(thought, json_friendly=False):
229
- knowledge_base_path = Path('..') / 'knowledge' / 'base'
230
 
231
  if thought['modality'] == 'text':
232
  content = open(knowledge_base_path / thought['filename']).read()
15
 
16
  def find(modality, query, relatedness, activation, noise, return_embeddings, auth_result, text_encoder, text_image_encoder, silent=False):
17
  authorized_thoughts = get_authorized_thoughts(auth_result)
18
+ knowledge_base_path = Path('..') / 'knowledge'
19
  query_embeddings = encode(
20
  modality, query, text_encoder, text_image_encoder)
21
 
78
 
79
 
80
  def save(modality, query, auth_result, text_encoder, text_image_encoder, silent=False):
81
+ knowledge_base_path = Path('..') / 'knowledge'
82
 
83
  if auth_result['custodian'] == False:
84
  return {
148
 
149
 
150
  def remove(auth_result, filename):
151
+ knowledge_base_path = Path('..') / 'knowledge'
152
 
153
  if auth_result['custodian'] == False:
154
  return {
169
 
170
 
171
  def get_authorized_thoughts(auth_result):
172
+ metadata_path = Path('..') / 'knowledge' / 'metadata.json'
173
 
174
  if not (metadata_path).exists():
175
  open(metadata_path, 'w').write(json.dumps([]))
226
 
227
 
228
  def get_content(thought, json_friendly=False):
229
+ knowledge_base_path = Path('..') / 'knowledge'
230
 
231
  if thought['modality'] == 'text':
232
  content = open(knowledge_base_path / thought['filename']).read()
docker-compose.yml CHANGED
@@ -15,7 +15,6 @@ services:
15
  depends_on:
16
  - backend
17
  volumes:
18
- - ./frontend:/app
19
  - ./knowledge:/knowledge
20
 
21
  backend:
@@ -27,5 +26,4 @@ services:
27
  aliases:
28
  - backend.docker
29
  volumes:
30
- - ./backend:/app
31
  - ./knowledge:/knowledge
15
  depends_on:
16
  - backend
17
  volumes:
 
18
  - ./knowledge:/knowledge
19
 
20
  backend:
26
  aliases:
27
  - backend.docker
28
  volumes:
 
29
  - ./knowledge:/knowledge
knowledge/base.txt DELETED
@@ -1 +0,0 @@
1
- Git ignores empty folders.