Jerrz commited on
Commit
2a797f9
1 Parent(s): 2097830

trying new things out again

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -8,7 +8,7 @@ import requests
8
  """
9
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
10
  """
11
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
12
 
13
 
14
 
@@ -34,19 +34,19 @@ def respond(
34
 
35
  messages.append({"role": "user", "content": message})
36
 
37
- #response = ""
38
 
39
- # for message in client.chat_completion(
40
- # messages,
41
- # max_tokens=max_tokens,
42
- # stream=True,
43
- # temperature=temperature,
44
- # top_p=top_p,
45
- # ):
46
- # token = message.choices[0].delta.content
47
 
48
- # response += token
49
- # yield response
50
 
51
  ### doesn't work
52
  # input_ids = tokenizer.encode(message, return_tensors = 'pt')
@@ -54,14 +54,14 @@ def respond(
54
  # output_text = tokenizer.decode(output, skip_special_tokens=True)
55
  # yield output_text
56
 
57
- API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B-Instruct"
58
- headers = {"Authorization": "Bearer "+os.environ['hf_token']}
59
- response = requests.post(API_URL, headers=headers, json={"inputs":message})
60
- data = response.json()
61
- returnval = ""
62
- for item in data:
63
- returnval = returnval + item['generated_text']
64
- return returnval
65
 
66
 
67
 
 
8
  """
9
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
10
  """
11
+ client = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct")
12
 
13
 
14
 
 
34
 
35
  messages.append({"role": "user", "content": message})
36
 
37
+ response = ""
38
 
39
+ for message in client.chat_completion(
40
+ messages,
41
+ max_tokens=max_tokens,
42
+ stream=True,
43
+ temperature=temperature,
44
+ top_p=top_p,
45
+ ):
46
+ token = message.choices[0].delta.content
47
 
48
+ response += token
49
+ yield response
50
 
51
  ### doesn't work
52
  # input_ids = tokenizer.encode(message, return_tensors = 'pt')
 
54
  # output_text = tokenizer.decode(output, skip_special_tokens=True)
55
  # yield output_text
56
 
57
+ # API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B-Instruct"
58
+ # headers = {"Authorization": "Bearer "+os.environ['hf_token']}
59
+ # response = requests.post(API_URL, headers=headers, json={"inputs":message})
60
+ # data = response.json()
61
+ # returnval = ""
62
+ # for item in data:
63
+ # returnval = returnval + item['generated_text']
64
+ # yield returnval
65
 
66
 
67