Spaces:
Paused
Paused
Update app.py
Browse files211 unmodified lines21221321421521621710 unmodified lines2282292302312322335 unmodified lines23924024124224324417 unmodified lines26226326426526626713 unmodified lines281282283284285286211 unmodified linestry:with gr.Progress() as progress:progress(0, "Preparing to send to model...")# Basic input validationif model_selection not in ["Clipboard only", "HuggingFace Inference", "Groq API", "OpenAI ChatGPT"]:10 unmodified lines# Call implementation with error handlingprogress(0.5, "Processing with model...")try:summary, download_file = send_to_model_impl(prompt=prompt.strip(),model_selection=model_selection,5 unmodified linesopenai_api_key=openai_api_key,openai_model_choice=openai_model_choice)if summary is None or not isinstance(summary, str):return "Error: No response from model", None17 unmodified linesdef send_to_model_impl(prompt, model_selection, hf_model_choice, hf_custom_model, hf_api_key,groq_model_choice, groq_api_key, openai_api_key, openai_model_choice):"""Implementation of model sending with improved error handling."""if model_selection == "Clipboard only":return "Text copied to clipboard. Use paste for processing.", None13 unmodified linesreturn "Error: Invalid model selection", None# Validate responseif not summary or not isinstance(summary, str):return "Error: Invalid response from model", None211 unmodified lines21221321421521621721810 unmodified lines2292302312322332342355 unmodified lines24124224324424524624717 unmodified lines26526626726826927027113 unmodified lines285286287288289290291292211 unmodified linestry:with gr.Progress() as progress:progress(0, "Preparing to send to model...")logging.info("sending to model preparation.")# Basic input validationif model_selection not in ["Clipboard only", "HuggingFace Inference", "Groq API", "OpenAI ChatGPT"]:10 unmodified lines# Call implementation with error handlingprogress(0.5, "Processing with model...")try:logging.info("calling send_to_model_impl.")summary, download_file = send_to_model_impl(prompt=prompt.strip(),model_selection=model_selection,5 unmodified linesopenai_api_key=openai_api_key,openai_model_choice=openai_model_choice)logging.info("summary received:", summary)if summary is None or not isinstance(summary, str):return "Error: No response from model", None17 unmodified linesdef send_to_model_impl(prompt, model_selection, hf_model_choice, hf_custom_model, hf_api_key,groq_model_choice, groq_api_key, openai_api_key, openai_model_choice):"""Implementation of model sending with improved error handling."""logging.info("send to model impl commencing...")if model_selection == "Clipboard only":return "Text copied to clipboard. Use paste for processing.", None13 unmodified linesreturn "Error: Invalid model selection", None# Validate responselogging.info("model told us:", summary)if not summary or not isinstance(summary, str):return "Error: Invalid response from model", None
app.py+6