Ismael1-2-3 commited on
Commit
316fef8
·
verified ·
1 Parent(s): 40bbaf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -1,14 +1,27 @@
1
  import gradio as gr
2
- from transformers import T5ForConditionalGeneration, T5Tokenizer
 
3
 
4
- model = T5ForConditionalGeneration.from_pretrained("t5-base")
5
- tokenizer = T5Tokenizer.from_pretrained("t5-base")
 
 
6
 
7
  def evaluate_password_strength(password):
8
- input_text = f"Rate the strength of the password: {password}"
9
- inputs = tokenizer(input_text, return_tensors="pt")
10
- output = model.generate(**inputs)
11
- response = tokenizer.decode(output[0], skip_special_tokens=True)
 
 
 
 
 
 
 
 
 
 
12
  return response
13
 
14
  demo = gr.Interface(
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
+ import os
4
 
5
+ client = InferenceClient(
6
+ provider="sambanova",
7
+ api_key= os.getenv("superSecretKey")
8
+ )
9
 
10
  def evaluate_password_strength(password):
11
+ messages = [
12
+ {
13
+ "role": "user",
14
+ "content": f"Rate the strength of the password: {password} as either 'Weak', 'Medium', or 'Strong'"
15
+ }
16
+ ]
17
+
18
+ completion = client.chat.completions.create(
19
+ model="meta-llama/Llama-3.1-8B-Instruct",
20
+ messages=messages,
21
+ max_tokens=500
22
+ )
23
+
24
+ response = completion.choices[0].message["content"]
25
  return response
26
 
27
  demo = gr.Interface(