arjunanand13 commited on
Commit
f3b4544
·
verified ·
1 Parent(s): b4c64e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
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
- "model": "meta-llama/Llama-3.1-8B-Instruct",
43
- "messages": [{"role": "user", "content": formatted_prompt}],
44
- "temperature": temperature,
45
- "max_tokens": max_new_tokens,
46
- "stream": False
47
  }
48
 
49
  try:
50
- response = requests.post(f"{ENDPOINT_URL}/v1/chat/completions", headers=headers, json=payload)
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()