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