abenkbp commited on
Commit
2544bfe
·
1 Parent(s): da75526
Files changed (1) hide show
  1. data/models/llama3-1-70b.py +6 -15
data/models/llama3-1-70b.py CHANGED
@@ -11,9 +11,8 @@ app = Flask(__name__)
11
  api_key = os.getenv("UCODE_SECRET")
12
  login(api_key,add_to_git_credential=True)
13
 
14
- client = InferenceClient()
15
-
16
  model_id = "meta-llama/Meta-Llama-3.1-70B-Instruct"
 
17
 
18
  @app.route('/chat', methods=['POST'])
19
  @spaces.GPU(enable_queue=True)
@@ -25,23 +24,15 @@ def chat_completion():
25
  temperature = data[0].get('temperature', 0.7)
26
  top_p = data[0].get('top_p', 0.95)
27
 
28
- chat = client.chat.completions.create(
29
- model=model_id,
30
- messages=user_input,
31
- stream=False,
32
- max_tokens=max_tokens,
33
- temperature=temperature,
34
- top_p=top_p
35
- )
36
-
37
  try:
38
- outputs = pipeline(
39
- user_input,
40
- max_new_tokens=max_tokens,
 
41
  temperature=temperature,
42
  top_p=top_p
43
  )
44
- return jsonify({"status": "success", "output": outputs[0]["generated_text"][-1]})
45
  except Exception as e:
46
  return jsonify({"status": "error", "message": str(e)})
47
 
 
11
  api_key = os.getenv("UCODE_SECRET")
12
  login(api_key,add_to_git_credential=True)
13
 
 
 
14
  model_id = "meta-llama/Meta-Llama-3.1-70B-Instruct"
15
+ client = InferenceClient(model=model_id,token=api_key)
16
 
17
  @app.route('/chat', methods=['POST'])
18
  @spaces.GPU(enable_queue=True)
 
24
  temperature = data[0].get('temperature', 0.7)
25
  top_p = data[0].get('top_p', 0.95)
26
 
 
 
 
 
 
 
 
 
 
27
  try:
28
+ chat = client.chat.completions.create(
29
+ messages=user_input,
30
+ stream=False,
31
+ max_tokens=max_tokens,
32
  temperature=temperature,
33
  top_p=top_p
34
  )
35
+ return jsonify({"status": "success", "output": chat})
36
  except Exception as e:
37
  return jsonify({"status": "error", "message": str(e)})
38