Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import re
|
|
| 3 |
import tempfile
|
| 4 |
import requests
|
| 5 |
import gradio as gr
|
|
|
|
|
|
|
| 6 |
from PyPDF2 import PdfReader
|
| 7 |
import logging
|
| 8 |
import webbrowser
|
|
@@ -627,19 +629,42 @@ with gr.Blocks(css="""
|
|
| 627 |
first_model = list(ctx_size.keys())[0]
|
| 628 |
ctx_size = ctx_size[first_model]
|
| 629 |
|
| 630 |
-
#
|
| 631 |
if choice == "OpenAI ChatGPT":
|
| 632 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 633 |
elif choice == "HuggingFace Inference":
|
| 634 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 635 |
elif choice == "Groq API":
|
| 636 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 637 |
|
|
|
|
| 638 |
return [
|
| 639 |
-
gr.update(visible=
|
| 640 |
-
gr.update(visible=
|
| 641 |
-
gr.update(visible=
|
| 642 |
-
gr.update(value=
|
|
|
|
| 643 |
]
|
| 644 |
|
| 645 |
# PDF Processing Handlers
|
|
@@ -784,7 +809,8 @@ with gr.Blocks(css="""
|
|
| 784 |
hf_options,
|
| 785 |
groq_options,
|
| 786 |
openai_options,
|
| 787 |
-
context_size
|
|
|
|
| 788 |
]
|
| 789 |
)
|
| 790 |
|
|
|
|
| 3 |
import tempfile
|
| 4 |
import requests
|
| 5 |
import gradio as gr
|
| 6 |
+
print(f"Gradio version: {gr.__version__}")
|
| 7 |
+
|
| 8 |
from PyPDF2 import PdfReader
|
| 9 |
import logging
|
| 10 |
import webbrowser
|
|
|
|
| 629 |
first_model = list(ctx_size.keys())[0]
|
| 630 |
ctx_size = ctx_size[first_model]
|
| 631 |
|
| 632 |
+
# Prepare dropdown choices based on provider
|
| 633 |
if choice == "OpenAI ChatGPT":
|
| 634 |
+
model_choices = list(MODEL_CONTEXT_SIZES["OpenAI ChatGPT"].keys())
|
| 635 |
+
return [
|
| 636 |
+
gr.update(visible=False), # hf_options
|
| 637 |
+
gr.update(visible=False), # groq_options
|
| 638 |
+
gr.update(visible=True), # openai_options
|
| 639 |
+
gr.update(value=ctx_size), # context_size
|
| 640 |
+
gr.Dropdown(choices=model_choices, value=first_model) # openai_model
|
| 641 |
+
]
|
| 642 |
elif choice == "HuggingFace Inference":
|
| 643 |
+
model_choices = list(model_registry.hf_models.keys())
|
| 644 |
+
return [
|
| 645 |
+
gr.update(visible=True), # hf_options
|
| 646 |
+
gr.update(visible=False), # groq_options
|
| 647 |
+
gr.update(visible=False), # openai_options
|
| 648 |
+
gr.update(value=ctx_size), # context_size
|
| 649 |
+
gr.Dropdown(choices=model_choices, value="Phi-3 Mini 4K") # openai_model (not used)
|
| 650 |
+
]
|
| 651 |
elif choice == "Groq API":
|
| 652 |
+
model_choices = list(model_registry.groq_models.keys())
|
| 653 |
+
return [
|
| 654 |
+
gr.update(visible=False), # hf_options
|
| 655 |
+
gr.update(visible=True), # groq_options
|
| 656 |
+
gr.update(visible=False), # openai_options
|
| 657 |
+
gr.update(value=ctx_size), # context_size
|
| 658 |
+
gr.Dropdown(choices=model_choices, value=model_choices[0] if model_choices else None) # openai_model (not used)
|
| 659 |
+
]
|
| 660 |
|
| 661 |
+
# Default return for "Clipboard only" or other options
|
| 662 |
return [
|
| 663 |
+
gr.update(visible=False), # hf_options
|
| 664 |
+
gr.update(visible=False), # groq_options
|
| 665 |
+
gr.update(visible=False), # openai_options
|
| 666 |
+
gr.update(value=4096), # context_size
|
| 667 |
+
gr.Dropdown(choices=[]) # openai_model (not used)
|
| 668 |
]
|
| 669 |
|
| 670 |
# PDF Processing Handlers
|
|
|
|
| 809 |
hf_options,
|
| 810 |
groq_options,
|
| 811 |
openai_options,
|
| 812 |
+
context_size,
|
| 813 |
+
openai_model
|
| 814 |
]
|
| 815 |
)
|
| 816 |
|