fix: pipelines

This commit is contained in:
Timothy J. Baek 2024-05-29 22:41:51 -07:00
parent 7cec88c776
commit 4715160b53
4 changed files with 185 additions and 181 deletions

View File

@ -219,7 +219,7 @@ def merge_models_lists(model_lists):
return merged_list return merged_list
async def get_all_models(): async def get_all_models(raw: bool = False):
log.info("get_all_models()") log.info("get_all_models()")
if ( if (
@ -236,6 +236,9 @@ async def get_all_models():
responses = await asyncio.gather(*tasks) responses = await asyncio.gather(*tasks)
log.debug(f"get_all_models:responses() {responses}") log.debug(f"get_all_models:responses() {responses}")
if raw:
return responses
models = { models = {
"data": merge_models_lists( "data": merge_models_lists(
list( list(

View File

@ -466,8 +466,10 @@ async def get_models(user=Depends(get_verified_user)):
@app.get("/api/pipelines/list") @app.get("/api/pipelines/list")
async def get_pipelines_list(user=Depends(get_admin_user)): async def get_pipelines_list(user=Depends(get_admin_user)):
models = await get_all_models() responses = await get_openai_models(raw=True)
urlIdxs = list(set([model["urlIdx"] for model in models if "pipeline" in model]))
print(responses)
urlIdxs = [idx for idx, response in enumerate(responses) if "pipelines" in response]
return { return {
"data": [ "data": [
@ -716,9 +718,7 @@ async def update_pipeline_valves(
pass pass
raise HTTPException( raise HTTPException(
status_code=( status_code=(r.status_code if r is not None else status.HTTP_404_NOT_FOUND),
r.status_code if r is not None else status.HTTP_404_NOT_FOUND
),
detail=detail, detail=detail,
) )

View File

@ -154,7 +154,7 @@ export const getPipelines = async (token: string, urlIdx?: string) => {
let error = null; let error = null;
const searchParams = new URLSearchParams(); const searchParams = new URLSearchParams();
if (urlIdx) { if (urlIdx !== undefined) {
searchParams.append('urlIdx', urlIdx); searchParams.append('urlIdx', urlIdx);
} }
@ -188,7 +188,7 @@ export const getPipelineValves = async (token: string, pipeline_id: string, urlI
let error = null; let error = null;
const searchParams = new URLSearchParams(); const searchParams = new URLSearchParams();
if (urlIdx) { if (urlIdx !== undefined) {
searchParams.append('urlIdx', urlIdx); searchParams.append('urlIdx', urlIdx);
} }
@ -224,7 +224,7 @@ export const getPipelineValvesSpec = async (token: string, pipeline_id: string,
let error = null; let error = null;
const searchParams = new URLSearchParams(); const searchParams = new URLSearchParams();
if (urlIdx) { if (urlIdx !== undefined) {
searchParams.append('urlIdx', urlIdx); searchParams.append('urlIdx', urlIdx);
} }
@ -265,7 +265,7 @@ export const updatePipelineValves = async (
let error = null; let error = null;
const searchParams = new URLSearchParams(); const searchParams = new URLSearchParams();
if (urlIdx) { if (urlIdx !== undefined) {
searchParams.append('urlIdx', urlIdx); searchParams.append('urlIdx', urlIdx);
} }

View File

@ -90,6 +90,7 @@
valves_spec = null; valves_spec = null;
if (PIPELINES_LIST.length > 0) { if (PIPELINES_LIST.length > 0) {
console.log(selectedPipelinesUrlIdx);
pipelines = await getPipelines(localStorage.token, selectedPipelinesUrlIdx); pipelines = await getPipelines(localStorage.token, selectedPipelinesUrlIdx);
if (pipelines.length > 0) { if (pipelines.length > 0) {
@ -143,10 +144,10 @@
console.log(PIPELINES_LIST); console.log(PIPELINES_LIST);
if (PIPELINES_LIST.length > 0) { if (PIPELINES_LIST.length > 0) {
selectedPipelinesUrlIdx = PIPELINES_LIST[0]['idx']; selectedPipelinesUrlIdx = PIPELINES_LIST[0]['idx'].toString();
} }
setPipelines(); await setPipelines();
}); });
</script> </script>
@ -182,7 +183,7 @@
> >
{#each PIPELINES_LIST as pipelines, idx} {#each PIPELINES_LIST as pipelines, idx}
<option value={pipelines.idx} class="bg-gray-100 dark:bg-gray-700" <option value={pipelines.idx.toString()} class="bg-gray-100 dark:bg-gray-700"
>{pipelines.url}</option >{pipelines.url}</option
> >
{/each} {/each}
@ -190,7 +191,6 @@
</div> </div>
</div> </div>
</div> </div>
{/if}
<div class=" my-2"> <div class=" my-2">
<div class=" mb-2 text-sm font-medium"> <div class=" mb-2 text-sm font-medium">
@ -372,6 +372,7 @@
</div> </div>
</div> </div>
{/if} {/if}
{/if}
{:else} {:else}
<div class="flex justify-center h-full"> <div class="flex justify-center h-full">
<div class="my-auto"> <div class="my-auto">