alex-abb commited on
Commit
cc11b4b
·
verified ·
1 Parent(s): fe257b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -15,7 +15,7 @@ def query(payload):
15
 
16
 
17
  def analyze_sentiment(text):
18
- output = query({
19
  "inputs": f'''<|begin_of_text|>
20
  <|start_header_id|>system<|end_header_id|>
21
  you are a feeling analyser and you'll say only "positive" if i'm feeling positive and "negativ" if i'm feeling sad or bad <|eot_id|>
@@ -23,12 +23,17 @@ you are a feeling analyser and you'll say only "positive" if i'm feeling positiv
23
  {text}
24
  <|eot_id|>
25
  <|start_header_id|>assistant<|end_header_id|>
 
 
 
 
 
26
  '''
27
  })
28
 
29
  # Assurez-vous de gérer correctement la sortie de l'API
30
  if isinstance(output, list) and len(output) > 0:
31
- return output[0].get('generated_text', 'Err eur: Réponse inattendue')
32
  else:
33
  return "Erreur: Réponse inattendue de l'API"
34
 
 
15
 
16
 
17
  def analyze_sentiment(text):
18
+ output = query({
19
  "inputs": f'''<|begin_of_text|>
20
  <|start_header_id|>system<|end_header_id|>
21
  you are a feeling analyser and you'll say only "positive" if i'm feeling positive and "negativ" if i'm feeling sad or bad <|eot_id|>
 
23
  {text}
24
  <|eot_id|>
25
  <|start_header_id|>assistant<|end_header_id|>
26
+
27
+ "parameters": {
28
+ "max_new_tokens": 1,
29
+ "return_full_text": False
30
+ }
31
  '''
32
  })
33
 
34
  # Assurez-vous de gérer correctement la sortie de l'API
35
  if isinstance(output, list) and len(output) > 0:
36
+ return output[0].get('generated_text', 'Erreur: Réponse inattendue')
37
  else:
38
  return "Erreur: Réponse inattendue de l'API"
39