Spaces:
Runtime error
Runtime error
Commit ·
7236da8
1
Parent(s): 539b69e
Created app.py (initial committ)
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
def get_bard_response(text):
|
| 4 |
+
url = "https://api.huggingface.co/models/bard/generate"
|
| 5 |
+
headers = {
|
| 6 |
+
"Authorization": "Bearer YOUR_TOKEN"
|
| 7 |
+
}
|
| 8 |
+
data = {
|
| 9 |
+
"text": text
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
response = requests.post(url, headers=headers, data=data)
|
| 13 |
+
return response.json()
|
| 14 |
+
|
| 15 |
+
def main():
|
| 16 |
+
text = input("Enter your text here: ")
|
| 17 |
+
response = get_bard_response(text)
|
| 18 |
+
print(response["generated_text"])
|
| 19 |
+
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
main()
|