Update app.py
Browse files
app.py
CHANGED
@@ -16,11 +16,13 @@
|
|
16 |
import os
|
17 |
import json
|
18 |
import requests
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
16 |
import os
|
17 |
import json
|
18 |
import requests
|
19 |
+
from text_generation import InferenceAPIClient
|
20 |
+
|
21 |
+
hf_api_key = os.environ.get("API_TOKEN")
|
22 |
+
if hf_api_key is None:
|
23 |
+
raise ValueError("HF_API_KEY environment variable not set, cannot use HF API to generate text.")
|
24 |
+
|
25 |
+
client = InferenceAPIClient("facebook/opt-125m", token=hf_api_key, timeout=60)
|
26 |
+
|
27 |
+
api_outputs = generate_with_api(prompt, args)
|
28 |
+
yield from api_outputs
|