Jangai commited on
Commit
4e005d3
·
verified ·
1 Parent(s): 5790eb2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -15
app.py CHANGED
@@ -15,28 +15,25 @@ 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
- # Constructing a single string prompt that combines the instruction with the LinkedIn post text
19
-
20
  headers = {
21
  "Authorization": f"Bearer {ZEPHYR_API_TOKEN}",
22
  "Content-Type": "application/json",
23
  }
24
 
25
- prompt = "Prepare a prompt for Stable Diffusion for the following LinkedIn post:"
26
- conversation = [
27
- {"role": "system", "content": prompt},
28
- {"role": "user", "content": linkedin_text}
29
- ]
30
-
31
- payload = {
32
- "inputs": {
33
- "past_user_inputs": [],
34
- "generated_responses": [],
35
- "text": linkedin_text, # This might need adjustment based on the model's requirements.
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()
 
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
+ # Headers for the HTTP request
 
19
  headers = {
20
  "Authorization": f"Bearer {ZEPHYR_API_TOKEN}",
21
  "Content-Type": "application/json",
22
  }
23
 
24
+ # Constructing the conversation
25
+ prompt = "Prepare a prompt for Stable Diffusion for the following LinkedIn post:"
26
+ conversation = [
27
+ {"role": "system", "content": prompt},
28
+ {"role": "user", "content": linkedin_text}
29
+ ]
30
+
31
+ # Adjusting the payload structure based on the expected format
32
+ payload = {
33
+ "inputs": conversation,
 
 
34
  }
 
35
 
36
+ # Sending the HTTP POST request
37
  response = requests.post(ZEPHYR_API_URL, headers=headers, json=payload)
38
  if response.status_code == 200:
39
  return response.json()