Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- server/custom_ui.py +5 -2
server/custom_ui.py
CHANGED
|
@@ -100,7 +100,7 @@ async def handle_ingestion(ref_img, clip_vids, lora, tok, prompt, param_json):
|
|
| 100 |
except Exception as e:
|
| 101 |
return f"Exception: {str(e)}\n{traceback.format_exc()}"
|
| 102 |
|
| 103 |
-
async def handle_analysis(ingestion_id, model_id, provider, max_tokens, temp):
|
| 104 |
if not ingestion_id:
|
| 105 |
return "Error: Provide an Ingestion ID first."
|
| 106 |
try:
|
|
@@ -113,6 +113,8 @@ async def handle_analysis(ingestion_id, model_id, provider, max_tokens, temp):
|
|
| 113 |
}
|
| 114 |
if model_id:
|
| 115 |
data["model_id"] = str(model_id)
|
|
|
|
|
|
|
| 116 |
|
| 117 |
async with httpx.AsyncClient() as client:
|
| 118 |
resp = await client.post(url, json=data, timeout=120.0)
|
|
@@ -152,6 +154,7 @@ def build_custom_ui(web_manager, action_fields, metadata, is_chat_env, title, qu
|
|
| 152 |
analysis_ingestion_id = gr.Textbox(label="Ingestion ID (auto-filled from step 1)")
|
| 153 |
analysis_provider = gr.Dropdown(choices=["auto", "openai", "anthropic", "huggingface", "local"], value="auto", label="LLM Provider")
|
| 154 |
analysis_model = gr.Textbox(label="Model ID (Optional formatting)", placeholder="e.g. meta-llama/Llama-3.1-70B-Instruct")
|
|
|
|
| 155 |
analysis_max_tokens = gr.Slider(minimum=64, maximum=4096, value=700, step=1, label="Max Tokens")
|
| 156 |
analysis_temp = gr.Slider(minimum=0.0, maximum=1.0, value=0.2, step=0.01, label="Temperature")
|
| 157 |
|
|
@@ -169,7 +172,7 @@ def build_custom_ui(web_manager, action_fields, metadata, is_chat_env, title, qu
|
|
| 169 |
|
| 170 |
analyze_btn.click(
|
| 171 |
handle_analysis,
|
| 172 |
-
inputs=[analysis_ingestion_id, analysis_model, analysis_provider, analysis_max_tokens, analysis_temp],
|
| 173 |
outputs=[analysis_report_out]
|
| 174 |
)
|
| 175 |
|
|
|
|
| 100 |
except Exception as e:
|
| 101 |
return f"Exception: {str(e)}\n{traceback.format_exc()}"
|
| 102 |
|
| 103 |
+
async def handle_analysis(ingestion_id, model_id, provider, api_key, max_tokens, temp):
|
| 104 |
if not ingestion_id:
|
| 105 |
return "Error: Provide an Ingestion ID first."
|
| 106 |
try:
|
|
|
|
| 113 |
}
|
| 114 |
if model_id:
|
| 115 |
data["model_id"] = str(model_id)
|
| 116 |
+
if api_key:
|
| 117 |
+
data["api_key"] = str(api_key)
|
| 118 |
|
| 119 |
async with httpx.AsyncClient() as client:
|
| 120 |
resp = await client.post(url, json=data, timeout=120.0)
|
|
|
|
| 154 |
analysis_ingestion_id = gr.Textbox(label="Ingestion ID (auto-filled from step 1)")
|
| 155 |
analysis_provider = gr.Dropdown(choices=["auto", "openai", "anthropic", "huggingface", "local"], value="auto", label="LLM Provider")
|
| 156 |
analysis_model = gr.Textbox(label="Model ID (Optional formatting)", placeholder="e.g. meta-llama/Llama-3.1-70B-Instruct")
|
| 157 |
+
analysis_api_key = gr.Textbox(label="API Key (Required for HF/OpenAI/Anthropic)", type="password", placeholder="Enter your token here...")
|
| 158 |
analysis_max_tokens = gr.Slider(minimum=64, maximum=4096, value=700, step=1, label="Max Tokens")
|
| 159 |
analysis_temp = gr.Slider(minimum=0.0, maximum=1.0, value=0.2, step=0.01, label="Temperature")
|
| 160 |
|
|
|
|
| 172 |
|
| 173 |
analyze_btn.click(
|
| 174 |
handle_analysis,
|
| 175 |
+
inputs=[analysis_ingestion_id, analysis_model, analysis_provider, analysis_api_key, analysis_max_tokens, analysis_temp],
|
| 176 |
outputs=[analysis_report_out]
|
| 177 |
)
|
| 178 |
|