Jangai commited on
Commit
b3fb41e
·
verified ·
1 Parent(s): 2b25af2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
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
- # Since your original approach doesn't directly use the transformers library, you need to construct the payload manually.
27
- # Adjust the payload to mimic the structure needed for chat interactions.
28
- payload = json.dumps({"inputs": {"past_user_inputs": [], "generated_responses": [], "text": linkedin_text, "conversation": messages}})
29
- response = requests.post(ZEPHYR_API_URL, headers=headers, data=payload)
 
 
 
 
 
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 = {