Update app.py
Browse files
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 |
-
#
|
25 |
prompt = "Prepare a prompt for Stable Diffusion for the following LinkedIn post:"
|
26 |
-
|
27 |
{"role": "system", "content": prompt},
|
28 |
{"role": "user", "content": linkedin_text}
|
29 |
]
|
30 |
|
31 |
-
#
|
32 |
payload = {
|
33 |
-
"inputs":
|
|
|
|
|
|
|
|
|
|
|
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:
|