Spaces:
Running
Running
Update index.html
Browse files- index.html +52 -48
index.html
CHANGED
|
@@ -1,57 +1,61 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
<body>
|
| 21 |
-
<gradio-lite>
|
| 22 |
-
<gradio-file name="app.py" entrypoint>
|
| 23 |
import gradio as gr
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
demo = gr.Interface(
|
| 32 |
-
|
| 33 |
-
"
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
)
|
| 37 |
|
| 38 |
demo.launch()
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
<gradio-file name="filters.py">
|
| 42 |
-
from skimage.color import rgb2gray
|
| 43 |
-
|
| 44 |
-
def as_gray(image):
|
| 45 |
-
return rgb2gray(image)
|
| 46 |
-
</gradio-file>
|
| 47 |
-
|
| 48 |
-
<gradio-file name="lion.jpg" url="https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/test_data/lion.jpg" />
|
| 49 |
-
<gradio-file name="logo.png" url="https://raw.githubusercontent.com/gradio-app/gradio/main/guides/assets/logo.png" />
|
| 50 |
|
| 51 |
-
|
| 52 |
-
# Same syntax as requirements.txt
|
| 53 |
-
scikit-image
|
| 54 |
-
</gradio-requirements>
|
| 55 |
-
</gradio-lite>
|
| 56 |
-
</body>
|
| 57 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Groq Summarizer - Gradio Lite</title>
|
| 7 |
+
|
| 8 |
+
<!-- Load Gradio-Lite CSS and JS -->
|
| 9 |
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>
|
| 10 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.css" />
|
| 11 |
+
</head>
|
| 12 |
+
<body>
|
| 13 |
+
|
| 14 |
+
<gradio-lite>
|
| 15 |
+
<gradio-requirements>
|
| 16 |
+
openai
|
| 17 |
+
</gradio-requirements>
|
| 18 |
+
|
| 19 |
+
<gradio-file name="app.py">
|
|
|
|
|
|
|
|
|
|
| 20 |
import gradio as gr
|
| 21 |
+
from openai import OpenAI
|
| 22 |
+
|
| 23 |
+
def summarize_text(api_key, text):
|
| 24 |
+
if not api_key:
|
| 25 |
+
return "Please provide an API key."
|
| 26 |
+
if not text:
|
| 27 |
+
return "Please provide text to summarize."
|
| 28 |
+
try:
|
| 29 |
+
client = OpenAI(
|
| 30 |
+
api_key=api_key,
|
| 31 |
+
base_url="https://api.groq.com/openai/v1"
|
| 32 |
+
)
|
| 33 |
+
response = client.chat.completions.create(
|
| 34 |
+
model="llama-3.1-8b-instant", # Use an active Groq model ID
|
| 35 |
+
messages=[
|
| 36 |
+
{"role": "system", "content": "You are a helpful assistant that summarizes text clearly and concisely."},
|
| 37 |
+
{"role": "user", "content": f"Summarize the following text:\n\n{text}"}
|
| 38 |
+
],
|
| 39 |
+
)
|
| 40 |
+
return response.choices[0].message.content
|
| 41 |
+
except Exception as e:
|
| 42 |
+
return f"An error occurred: {str(e)}"
|
| 43 |
+
|
| 44 |
+
api_key = gr.Textbox(label="API Key", type="password")
|
| 45 |
+
text = gr.Textbox(label="Text to summarize", lines=5)
|
| 46 |
+
output_text = gr.Textbox(label="Summary")
|
| 47 |
|
| 48 |
demo = gr.Interface(
|
| 49 |
+
title="Summarize a text!",
|
| 50 |
+
description="Simple app running completely in your browser via Gradio-Lite.",
|
| 51 |
+
fn=summarize_text,
|
| 52 |
+
inputs=[api_key, text],
|
| 53 |
+
outputs=[output_text]
|
| 54 |
)
|
| 55 |
|
| 56 |
demo.launch()
|
| 57 |
+
</gradio-file>
|
| 58 |
+
</gradio-lite>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
</body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
</html>
|