Spaces:
Sleeping
Sleeping
Pooja P
commited on
Commit
·
d5c17b0
1
Parent(s):
a93ab10
changed to api iinterfaceeee small version model api
Browse files
app.py
CHANGED
@@ -7,7 +7,8 @@ import gradio as gr
|
|
7 |
token = os.environ.get("OPENAI_API_KEY")
|
8 |
# generator = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", token=token)
|
9 |
|
10 |
-
API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta"
|
|
|
11 |
headers = {"Authorization": f"Bearer {token}"}
|
12 |
|
13 |
# generator = pipeline("text-generation", model="tiiuae/falcon-rw-1b")
|
@@ -49,8 +50,12 @@ def generate_blog(topic):
|
|
49 |
Make it informative and conversational.
|
50 |
"""
|
51 |
output = query({"inputs": prompt})
|
|
|
|
|
52 |
if isinstance(output, list) and "generated_text" in output[0]:
|
53 |
return output[0]["generated_text"]
|
|
|
|
|
54 |
else:
|
55 |
return "Failed to generate blog. Please try again."
|
56 |
|
|
|
7 |
token = os.environ.get("OPENAI_API_KEY")
|
8 |
# generator = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", token=token)
|
9 |
|
10 |
+
# API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta"
|
11 |
+
API_URL = "https://api-inference.huggingface.co/models/tiiuae/falcon-rw-1b"
|
12 |
headers = {"Authorization": f"Bearer {token}"}
|
13 |
|
14 |
# generator = pipeline("text-generation", model="tiiuae/falcon-rw-1b")
|
|
|
50 |
Make it informative and conversational.
|
51 |
"""
|
52 |
output = query({"inputs": prompt})
|
53 |
+
print("API Response:", output) # <-- Add this for debugging
|
54 |
+
|
55 |
if isinstance(output, list) and "generated_text" in output[0]:
|
56 |
return output[0]["generated_text"]
|
57 |
+
elif "error" in output:
|
58 |
+
return f"Error from model: {output['error']}"
|
59 |
else:
|
60 |
return "Failed to generate blog. Please try again."
|
61 |
|