async def run_audios_search_api(q: Optional[str] = '', record_range: Optional[str] = '', record_density: Optional[int] = 50, index_range: Optional[str] = '', index_density: Optional[int] = 5, calc_ranges: Optional[bool] = False): # Get project project = Project() if not project.exists(): raise HTTPException(status_code=404) query = q.strip() try: syntax_error_check(query) except SyntaxError as se: raise HTTPException(status_code=400, detail={ 'name': 'SyntaxError', 'statement': se.text, 'line': se.lineno, 'offset': se.offset }) traces = project.repo.query_audios(query=query) try: record_range = str_to_range(record_range) index_range = str_to_range(index_range) except ValueError: raise HTTPException(status_code=400, detail='Invalid range format') streamer = audio_search_result_streamer(traces, record_range, record_density, index_range, index_density, calc_ranges) return StreamingResponse(streamer)
async def run_texts_batch_api(run_id: str, requested_traces: RunTracesBatchApiIn, record_range: Optional[str] = '', record_density: Optional[int] = 50, index_range: Optional[str] = '', index_density: Optional[int] = 5): # Get project project = Project() if not project.exists(): raise HTTPException(status_code=404) run = project.repo.get_run(run_id) if not run: raise HTTPException(status_code=404) try: record_range = str_to_range(record_range) index_range = str_to_range(index_range) except ValueError: raise HTTPException(status_code=400, detail='Invalid range format') traces_streamer = requested_text_traces_streamer(run, requested_traces, record_range, index_range, record_density, index_density) return StreamingResponse(traces_streamer)