Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -500,11 +500,24 @@ def send_to_model_impl(prompt, model_selection, hf_model_choice, hf_custom_model
|
|
| 500 |
"""Implementation of model sending with all providers."""
|
| 501 |
logging.info("send to model impl commencing...")
|
| 502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 503 |
try:
|
| 504 |
if model_selection == "Clipboard only":
|
| 505 |
# Escape the prompt for JavaScript
|
| 506 |
escaped_prompt = prompt.replace('"', '\\"').replace("'", "\\'").replace('\n', '\\n')
|
| 507 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
# Create HTML with JavaScript using string formatting
|
| 509 |
html_template = '''
|
| 510 |
<script>
|
|
@@ -541,7 +554,12 @@ def send_to_model_impl(prompt, model_selection, hf_model_choice, hf_custom_model
|
|
| 541 |
</script>
|
| 542 |
<div id="clipboard_status" style="color: green; font-weight: bold;"></div>
|
| 543 |
'''
|
| 544 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 545 |
|
| 546 |
# Get the summary based on model selection
|
| 547 |
if model_selection == "HuggingFace Inference":
|
|
|
|
| 500 |
"""Implementation of model sending with all providers."""
|
| 501 |
logging.info("send to model impl commencing...")
|
| 502 |
|
| 503 |
+
try:
|
| 504 |
+
def send_to_model_impl(prompt, model_selection, hf_model_choice, hf_custom_model, hf_api_key,
|
| 505 |
+
groq_model_choice, groq_api_key, openai_api_key, openai_model_choice,
|
| 506 |
+
cohere_api_key=None, cohere_model=None, glhf_api_key=None, glhf_model=None,
|
| 507 |
+
glhf_custom_model=None, use_rate_limits=False):
|
| 508 |
+
"""Implementation of model sending with all providers."""
|
| 509 |
+
logging.info("send to model impl commencing...")
|
| 510 |
+
|
| 511 |
try:
|
| 512 |
if model_selection == "Clipboard only":
|
| 513 |
# Escape the prompt for JavaScript
|
| 514 |
escaped_prompt = prompt.replace('"', '\\"').replace("'", "\\'").replace('\n', '\\n')
|
| 515 |
|
| 516 |
+
# Create temporary file for download
|
| 517 |
+
with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.txt') as f:
|
| 518 |
+
f.write(prompt)
|
| 519 |
+
download_file = f.name
|
| 520 |
+
|
| 521 |
# Create HTML with JavaScript using string formatting
|
| 522 |
html_template = '''
|
| 523 |
<script>
|
|
|
|
| 554 |
</script>
|
| 555 |
<div id="clipboard_status" style="color: green; font-weight: bold;"></div>
|
| 556 |
'''
|
| 557 |
+
|
| 558 |
+
# Return all three expected outputs:
|
| 559 |
+
# 1. HTML component for status
|
| 560 |
+
# 2. Text message for summary output
|
| 561 |
+
# 3. Download file
|
| 562 |
+
return gr.HTML(html_template % escaped_prompt), "Text copied to clipboard. Use paste for processing.", download_file
|
| 563 |
|
| 564 |
# Get the summary based on model selection
|
| 565 |
if model_selection == "HuggingFace Inference":
|