refactor: rename ML model python backend folder

This commit is contained in:
nobody 2025-10-30 17:55:24 -07:00
commit 76c28bafab
Signed by: GrocerPublishAgent
GPG key ID: D460CD54A9E3AB86
9 changed files with 0 additions and 0 deletions

30
api/salience/__init__.py Normal file
View file

@ -0,0 +1,30 @@
from flask import Flask, request
import numpy as np
from .salience import extract, AVAILABLE_MODELS
import json
app = Flask(__name__)
with open('./transcript.txt', 'r') as file:
source_text = file.read().strip()
@app.route("/models")
def models_view():
return json.dumps(list(AVAILABLE_MODELS.keys()))
@app.route("/salience")
def salience_view():
model_name = request.args.get('model', 'all-mpnet-base-v2')
# Validate model name
if model_name not in AVAILABLE_MODELS:
return json.dumps({'error': f'Invalid model: {model_name}'}), 400
sentence_ranges, adjacency = extract(source_text, model_name)
return json.dumps({
'source': source_text,
'intervals': sentence_ranges,
'adjacency': np.nan_to_num(adjacency.numpy()).tolist(),
'model': model_name,
})