Multiverse26 commited on
Commit
be6e76b
·
verified ·
1 Parent(s): b6a5a96

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
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.text_generation(
14
- prompt,
15
- max_new_tokens=80
 
 
 
16
  )
17
-
18
- return response.strip()
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,