Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,8 @@ if not ZEPHYR_API_TOKEN or not SD_API_TOKEN:
|
|
14 |
ZEPHYR_API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta"
|
15 |
SD_API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
|
16 |
|
17 |
-
query_zephyr(linkedin_text):
|
|
|
18 |
messages = [
|
19 |
{
|
20 |
"role": "system",
|
@@ -23,12 +24,18 @@ SD_API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-dif
|
|
23 |
{"role": "user", "content": linkedin_text},
|
24 |
]
|
25 |
headers = {"Authorization": f"Bearer {ZEPHYR_API_TOKEN}"}
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
return response.json()
|
31 |
|
|
|
32 |
def generate_image_from_prompt(prompt, negative_prompt, guidance_scale, width, height, num_inference_steps):
|
33 |
headers = {"Authorization": f"Bearer {SD_API_TOKEN}"}
|
34 |
payload = {
|
|
|
14 |
ZEPHYR_API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta"
|
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 |
+
# Ensure that all lines inside this function are indented at the same level
|
19 |
messages = [
|
20 |
{
|
21 |
"role": "system",
|
|
|
24 |
{"role": "user", "content": linkedin_text},
|
25 |
]
|
26 |
headers = {"Authorization": f"Bearer {ZEPHYR_API_TOKEN}"}
|
27 |
+
payload = {
|
28 |
+
"inputs": {
|
29 |
+
"past_user_inputs": [],
|
30 |
+
"generated_responses": [],
|
31 |
+
"text": linkedin_text,
|
32 |
+
"conversation": messages
|
33 |
+
}
|
34 |
+
}
|
35 |
+
response = requests.post(ZEPHYR_API_URL, headers=headers, json=payload)
|
36 |
return response.json()
|
37 |
|
38 |
+
|
39 |
def generate_image_from_prompt(prompt, negative_prompt, guidance_scale, width, height, num_inference_steps):
|
40 |
headers = {"Authorization": f"Bearer {SD_API_TOKEN}"}
|
41 |
payload = {
|