Jangai commited on
Commit
f4ea50e
·
verified ·
1 Parent(s): f49b96e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -15
app.py CHANGED
@@ -15,32 +15,23 @@ ZEPHYR_API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zeph
15
  SD_API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
16
 
17
  def query_zephyr(linkedin_text):
18
- # Construct the prompt to include the LinkedIn post with an instruction for Zephyr
19
  instruction = "Prepare a prompt for Stable Diffusion for the following LinkedIn post:"
20
- conversation = [
21
- {"role": "system", "content": instruction},
22
- {"role": "user", "content": linkedin_text}
23
- ]
 
24
 
25
  headers = {
26
  "Authorization": f"Bearer {ZEPHYR_API_TOKEN}",
27
  "Content-Type": "application/json",
28
  }
29
 
30
- # Format the payload according to the Hugging Face Inference API documentation
31
- payload = {
32
- "inputs": {
33
- "past_user_inputs": [],
34
- "generated_responses": [],
35
- "text": linkedin_text,
36
- "conversation": conversation,
37
- },
38
- }
39
-
40
  response = requests.post(ZEPHYR_API_URL, headers=headers, json=payload)
41
  if response.status_code == 200:
42
  return response.json()
43
  else:
 
44
  raise Exception(f"Failed to query Zephyr model, status code: {response.status_code}")
45
 
46
 
 
15
  SD_API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
16
 
17
  def query_zephyr(linkedin_text):
 
18
  instruction = "Prepare a prompt for Stable Diffusion for the following LinkedIn post:"
19
+ payload = {
20
+ "inputs": {
21
+ "text": instruction + " " + linkedin_text # Assuming direct instruction followed by the query
22
+ }
23
+ }
24
 
25
  headers = {
26
  "Authorization": f"Bearer {ZEPHYR_API_TOKEN}",
27
  "Content-Type": "application/json",
28
  }
29
 
 
 
 
 
 
 
 
 
 
 
30
  response = requests.post(ZEPHYR_API_URL, headers=headers, json=payload)
31
  if response.status_code == 200:
32
  return response.json()
33
  else:
34
+ print(response.text) # To get more insight into what went wrong
35
  raise Exception(f"Failed to query Zephyr model, status code: {response.status_code}")
36
 
37