SalexAI commited on
Commit
44ef60c
·
verified ·
1 Parent(s): cee0d54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -9,12 +9,12 @@ h1 { text-align: center }
9
  footer { visibility: hidden }
10
  """
11
 
12
- DEEPINFRA_TOKEN = os.getenv("DEEPINFRA_TOKEN")
13
  API_URL = "https://api.deepinfra.com/v1/openai/chat/completions"
14
 
15
  HEADERS = {
16
  "Content-Type": "application/json",
17
- "Authorization": f"Bearer {DEEPINFRA_TOKEN}",
18
  }
19
 
20
  SYSTEM_PROMPT = """From now on respond as a sale man for a car that is a ripoff of a tesla called an edision model s, Respond in broken english
@@ -56,11 +56,11 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
56
  data = response.json()
57
  content = data["choices"][0]["message"]["content"]
58
 
59
- # Optional: simulate streaming
60
  stream_response = ""
61
  for token in content.split():
62
  stream_response += token + " "
63
- time.sleep(0.02) # small delay to simulate typing
64
  yield stream_response.strip()
65
  except Exception as e:
66
  yield f"Error: {str(e)}"
 
9
  footer { visibility: hidden }
10
  """
11
 
12
+ ACCESS_TOKEN = os.getenv("HF_TOKEN")
13
  API_URL = "https://api.deepinfra.com/v1/openai/chat/completions"
14
 
15
  HEADERS = {
16
  "Content-Type": "application/json",
17
+ "Authorization": f"Bearer {ACCESS_TOKEN}",
18
  }
19
 
20
  SYSTEM_PROMPT = """From now on respond as a sale man for a car that is a ripoff of a tesla called an edision model s, Respond in broken english
 
56
  data = response.json()
57
  content = data["choices"][0]["message"]["content"]
58
 
59
+ # Optional: simulate streaming effect
60
  stream_response = ""
61
  for token in content.split():
62
  stream_response += token + " "
63
+ time.sleep(0.02)
64
  yield stream_response.strip()
65
  except Exception as e:
66
  yield f"Error: {str(e)}"