Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,20 +2,20 @@ import gradio as gr
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
client = InferenceClient(
|
| 6 |
-
model="google/flan-t5-base",
|
| 7 |
-
token=os.getenv("my-first-token")
|
| 8 |
-
)
|
| 9 |
|
| 10 |
def generate_caption(prompt):
|
| 11 |
prompt = f"Write 3 short luxury Instagram captions for: {prompt}. Keep them elegant and minimal."
|
| 12 |
-
|
| 13 |
-
response = client.
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 16 |
)
|
| 17 |
-
|
| 18 |
-
return response.
|
| 19 |
|
| 20 |
iface = gr.Interface(
|
| 21 |
fn=generate_caption,
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
client = InferenceClient(token=os.getenv("HF_TOKEN"))
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def generate_caption(prompt):
|
| 8 |
prompt = f"Write 3 short luxury Instagram captions for: {prompt}. Keep them elegant and minimal."
|
| 9 |
+
|
| 10 |
+
response = client.chat.completions.create(
|
| 11 |
+
model="meta-llama/Llama-3-8b-Instruct",
|
| 12 |
+
messages=[
|
| 13 |
+
{"role": "user", "content": prompt}
|
| 14 |
+
],
|
| 15 |
+
max_tokens=120
|
| 16 |
)
|
| 17 |
+
|
| 18 |
+
return response.choices[0].message.content
|
| 19 |
|
| 20 |
iface = gr.Interface(
|
| 21 |
fn=generate_caption,
|