Kim465 commited on
Commit
1914b1c
·
verified ·
1 Parent(s): 255c46a

Fix 410 error with token + text_generation

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  from huggingface_hub import InferenceClient
3
  import os
4
 
5
- # Your secret token
6
  token = os.getenv("HF_TOKEN")
7
 
8
  # Uncensored model
@@ -11,14 +11,14 @@ model_id = "HuggingFaceH4/zephyr-7b-beta"
11
  def chat(message, history):
12
  try:
13
  client = InferenceClient(token=token)
14
- messages = [{"role": "user", "content": message}]
15
- output = client.chat_completion(
16
- messages,
17
  model=model_id,
18
- max_tokens=200,
19
- temperature=0.8
 
20
  )
21
- return output.choices[0].message.content
22
  except Exception as e:
23
  return f"Sorry, glitch: {str(e)}. Try again!"
24
 
 
2
  from huggingface_hub import InferenceClient
3
  import os
4
 
5
+ # Get your secret token for new endpoint
6
  token = os.getenv("HF_TOKEN")
7
 
8
  # Uncensored model
 
11
  def chat(message, history):
12
  try:
13
  client = InferenceClient(token=token)
14
+ response = client.text_generation(
15
+ message,
 
16
  model=model_id,
17
+ max_new_tokens=200,
18
+ temperature=0.8,
19
+ do_sample=True,
20
  )
21
+ return response
22
  except Exception as e:
23
  return f"Sorry, glitch: {str(e)}. Try again!"
24