Spaces:
Paused
Paused
Update app.py
Browse files2 unmodified lines345678618 unmodified lines627628629630631632633634635636637638639640641642643644645138 unmodified lines7847857867877887897902 unmodified linesimport tempfileimport requestsimport gradio as grfrom PyPDF2 import PdfReaderimport loggingimport webbrowser618 unmodified linesfirst_model = list(ctx_size.keys())[0]ctx_size = ctx_size[first_model]# Update model dropdown based on providerif choice == "OpenAI ChatGPT":openai_model.update(choices=list(MODEL_CONTEXT_SIZES["OpenAI ChatGPT"].keys()))elif choice == "HuggingFace Inference":hf_model.update(choices=list(MODEL_CONTEXT_SIZES["HuggingFace Inference"].keys()))elif choice == "Groq API":groq_model.update(choices=list(MODEL_CONTEXT_SIZES["Groq API"].keys()))return [gr.update(visible=choice == "HuggingFace Inference"),gr.update(visible=choice == "Groq API"),gr.update(visible=choice == "OpenAI ChatGPT"),gr.update(value=ctx_size)]# PDF Processing Handlers138 unmodified lineshf_options,groq_options,openai_options,context_size])2 unmodified lines345678910618 unmodified lines629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670138 unmodified lines8098108118128138148158162 unmodified linesimport tempfileimport requestsimport gradio as grprint(f"Gradio version: {gr.__version__}")from PyPDF2 import PdfReaderimport loggingimport webbrowser618 unmodified linesfirst_model = list(ctx_size.keys())[0]ctx_size = ctx_size[first_model]# Prepare dropdown choices based on providerif choice == "OpenAI ChatGPT":model_choices = list(MODEL_CONTEXT_SIZES["OpenAI ChatGPT"].keys())return [gr.update(visible=False), # hf_optionsgr.update(visible=False), # groq_optionsgr.update(visible=True), # openai_optionsgr.update(value=ctx_size), # context_sizegr.Dropdown(choices=model_choices, value=first_model) # openai_model]elif choice == "HuggingFace Inference":model_choices = list(model_registry.hf_models.keys())return [gr.update(visible=True), # hf_optionsgr.update(visible=False), # groq_optionsgr.update(visible=False), # openai_optionsgr.update(value=ctx_size), # context_sizegr.Dropdown(choices=model_choices, value="Phi-3 Mini 4K") # openai_model (not used)]elif choice == "Groq API":model_choices = list(model_registry.groq_models.keys())return [gr.update(visible=False), # hf_optionsgr.update(visible=True), # groq_optionsgr.update(visible=False), # openai_optionsgr.update(value=ctx_size), # context_sizegr.Dropdown(choices=model_choices, value=model_choices[0] if model_choices else None) # openai_model (not used)]# Default return for "Clipboard only" or other optionsreturn [gr.update(visible=False), # hf_optionsgr.update(visible=False), # groq_optionsgr.update(visible=False), # openai_optionsgr.update(value=4096), # context_sizegr.Dropdown(choices=[]) # openai_model (not used)]# PDF Processing Handlers138 unmodified lineshf_options,groq_options,openai_options,context_size,openai_model])
app.py+35-9