Use global config and add a regenerate button to the config ui' && git push

This commit is contained in:
Saba 2021-11-28 13:28:22 -05:00
parent 34d1e4199c
commit 6f466c8d99
4 changed files with 19 additions and 8 deletions

View file

@ -19,4 +19,4 @@ search-type:
cross-encoder: cross-encoder/ms-marco-MiniLM-L-6-v2
encoder: sentence-transformers/msmarco-MiniLM-L-6-v3
image:
encoder: clip-ViT-B-32
encoder: ''

View file

@ -38,11 +38,12 @@ def config():
@app.post('/config')
async def config(updated_config: FullConfig):
print(updated_config.dict())
global config
config = updated_config
with open(config_file, 'w') as outfile:
yaml.dump(yaml.safe_load(updated_config.json(by_alias=True)), outfile)
yaml.dump(yaml.safe_load(config.json(by_alias=True)), outfile)
outfile.close()
return updated_config
return config
@app.get('/search')
def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None):
@ -91,6 +92,7 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None):
@app.get('/regenerate')
def regenerate(t: Optional[SearchType] = None):
print("-----REGENERATING----")
if (t == SearchType.Notes or t == None) and search_config.notes:
# Extract Entries, Generate Embeddings
model.notes_search = asymmetric.setup(search_config.notes, regenerate=True)
@ -124,7 +126,7 @@ def chat(q: str):
return {'status': 'ok', 'response': gpt_response}
def initialize_search(config: FullConfig, regenerate, verbose):
def initialize_search(regenerate, verbose):
model = SearchModels()
search_config = SearchConfig()
@ -151,7 +153,7 @@ def initialize_search(config: FullConfig, regenerate, verbose):
return model, search_config
def initialize_processor(config: FullConfig, verbose):
def initialize_processor(verbose):
processor_config = ProcessorConfig()
# Initialize Conversation Processor
@ -195,10 +197,10 @@ if __name__ == '__main__':
config = args.config
# Initialize Search from Config
model, search_config = initialize_search(args.config, args.regenerate, args.verbose)
model, search_config = initialize_search(args.regenerate, args.verbose)
# Initialize Processor from Config
processor_config = initialize_processor(args.config, args.verbose)
processor_config = initialize_processor(args.verbose)
# Start Application Server
if args.socket:

View file

@ -6,6 +6,7 @@
<body>
<form id="config-form">
</form>
<button id="config-regenerate">regenerate</button>
</body>
<script src="views/scripts/config.js"></script>
</html>

View file

@ -32,6 +32,14 @@ fetch("/config")
});
});
var regenerateButton = document.getElementById("config-regenerate");
regenerateButton.addEventListener("click", (event) => {
event.preventDefault();
fetch("/regenerate")
.then(response => response.json())
.then(data => console.log(data));
})
function processChildren(element, data) {
for (let key in data) {
var child = document.createElement("div");