Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,9 @@ import os
|
|
| 5 |
from groq import Groq
|
| 6 |
import gradio as gr
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
client = Groq(api_key=api_key)
|
| 10 |
|
| 11 |
def encode_image(image_path):
|
|
@@ -63,8 +65,9 @@ def feifeichat(image):
|
|
| 63 |
}
|
| 64 |
]
|
| 65 |
|
|
|
|
| 66 |
response = client.chat.completions.create(
|
| 67 |
-
model="
|
| 68 |
messages=messages,
|
| 69 |
response_format={"type": "json_object"},
|
| 70 |
stream=True
|
|
@@ -78,7 +81,7 @@ def feifeichat(image):
|
|
| 78 |
|
| 79 |
except Exception as e:
|
| 80 |
print(f"Error: {e}")
|
| 81 |
-
yield "An error occurred while processing your request"
|
| 82 |
|
| 83 |
with gr.Blocks() as demo:
|
| 84 |
gr.Markdown("Image To Flux Prompt")
|
|
|
|
| 5 |
from groq import Groq
|
| 6 |
import gradio as gr
|
| 7 |
|
| 8 |
+
# FIX: Read the key name from your Hugging Face Environment Variables secrets configuration
|
| 9 |
+
# Make sure you set a secret named "GROQ_API_KEY" in your Hugging Face Space settings interface.
|
| 10 |
+
api_key = os.getenv("GROQ_API_KEY", "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")
|
| 11 |
client = Groq(api_key=api_key)
|
| 12 |
|
| 13 |
def encode_image(image_path):
|
|
|
|
| 65 |
}
|
| 66 |
]
|
| 67 |
|
| 68 |
+
# FIX: Changed model to Groq's official high-speed multimodal vision model identifier
|
| 69 |
response = client.chat.completions.create(
|
| 70 |
+
model="llama-3.2-11b-vision-preview",
|
| 71 |
messages=messages,
|
| 72 |
response_format={"type": "json_object"},
|
| 73 |
stream=True
|
|
|
|
| 81 |
|
| 82 |
except Exception as e:
|
| 83 |
print(f"Error: {e}")
|
| 84 |
+
yield f"An error occurred while processing your request: {e}"
|
| 85 |
|
| 86 |
with gr.Blocks() as demo:
|
| 87 |
gr.Markdown("Image To Flux Prompt")
|