Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import asyncio
|
|
| 7 |
import os
|
| 8 |
import json
|
| 9 |
|
| 10 |
-
ENDPOINT_URL = "https://xzup8268xrmmxcma.us-east-1.aws.endpoints.huggingface.cloud"
|
| 11 |
hf_token = os.getenv("HF_TOKEN")
|
| 12 |
|
| 13 |
asr = pipeline("automatic-speech-recognition", "facebook/wav2vec2-base-960h")
|
|
@@ -33,21 +33,17 @@ def generate(prompt, history, temperature=0.1, max_new_tokens=2048):
|
|
| 33 |
|
| 34 |
formatted_prompt = format_prompt(prompt, history)
|
| 35 |
|
| 36 |
-
headers = {
|
| 37 |
-
"Authorization": f"Bearer {hf_token}",
|
| 38 |
-
"Content-Type": "application/json"
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
payload = {
|
| 42 |
-
"
|
| 43 |
-
"
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
}
|
| 48 |
|
| 49 |
try:
|
| 50 |
-
response = requests.post(
|
| 51 |
|
| 52 |
if response.status_code == 200:
|
| 53 |
result = response.json()
|
|
|
|
| 7 |
import os
|
| 8 |
import json
|
| 9 |
|
| 10 |
+
ENDPOINT_URL = "https://xzup8268xrmmxcma.us-east-1.aws.endpoints.huggingface.cloud/invocations"
|
| 11 |
hf_token = os.getenv("HF_TOKEN")
|
| 12 |
|
| 13 |
asr = pipeline("automatic-speech-recognition", "facebook/wav2vec2-base-960h")
|
|
|
|
| 33 |
|
| 34 |
formatted_prompt = format_prompt(prompt, history)
|
| 35 |
|
| 36 |
+
headers = {"Authorization": f"Bearer {hf_token}", "Content-Type": "application/json"}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
payload = {
|
| 38 |
+
"inputs": prompt,
|
| 39 |
+
"parameters": {
|
| 40 |
+
"temperature": temperature,
|
| 41 |
+
"max_new_tokens": max_new_tokens
|
| 42 |
+
}
|
| 43 |
}
|
| 44 |
|
| 45 |
try:
|
| 46 |
+
response = requests.post(ENDPOINT_URL, headers=headers, json=payload)
|
| 47 |
|
| 48 |
if response.status_code == 200:
|
| 49 |
result = response.json()
|