feat: add multiple models

This commit is contained in:
nobody 2025-10-30 16:26:48 -07:00
commit fee0e643e4
Signed by: GrocerPublishAgent
GPG key ID: D460CD54A9E3AB86
5 changed files with 517 additions and 32 deletions

View file

@ -1,18 +1,30 @@
from flask import Flask
from flask import Flask, request
import numpy as np
from .salience import extract
from .salience import extract, AVAILABLE_MODELS
import json
app = Flask(__name__)
with open('./transcript.txt', 'r') as file:
source_text = file.read().strip()
sentence_ranges, adjacency = extract(source_text)
@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,
})