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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -15,24 +15,27 @@ 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
- # 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:
 
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 = {
19
  "Authorization": f"Bearer {ZEPHYR_API_TOKEN}",
20
  "Content-Type": "application/json",
21
  }
22
 
23
+ # Adapting the conversational format from the pipeline example
24
  prompt = "Prepare a prompt for Stable Diffusion for the following LinkedIn post:"
25
+ messages = [
26
  {"role": "system", "content": prompt},
27
  {"role": "user", "content": linkedin_text}
28
  ]
29
 
30
+ # Structuring the payload for a conversational input
31
  payload = {
32
+ "inputs": {
33
+ "past_user_inputs": [],
34
+ "generated_responses": [],
35
+ "text": linkedin_text, # or possibly serialize the messages list if needed
36
+ "conversation": messages, # This might need to be adjusted based on Zephyr's API requirements
37
+ }
38
  }
 
39
  # Sending the HTTP POST request
40
  response = requests.post(ZEPHYR_API_URL, headers=headers, json=payload)
41
  if response.status_code == 200: