alex-abb commited on
Commit
47f2ac0
·
verified ·
1 Parent(s): a06cfd4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -8,23 +8,22 @@ API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8
8
  headers = {"Authorization": f"Bearer {api_token}"}
9
 
10
  def query(payload):
11
- response = requests.post(API_URL, headers=headers, json=payload)
12
- return response.json()
13
-
14
- def analyze_sentiment(text):
15
- def query(payload):
16
  response = requests.post(API_URL, headers=headers, json=payload)
17
  return response.json()
 
 
 
 
18
 
19
  output = query({
20
  "inputs": {
21
- "system": "you only answer in bulgarian",
22
- "user": "hello",
 
 
23
  }
24
  })
25
 
26
- print(output)
27
-
28
  # Assurez-vous de gérer correctement la sortie de l'API
29
  if isinstance(output, list) and len(output) > 0:
30
  return output[0].get('generated_text', 'Erreur: Réponse inattendue')
 
8
  headers = {"Authorization": f"Bearer {api_token}"}
9
 
10
  def query(payload):
 
 
 
 
 
11
  response = requests.post(API_URL, headers=headers, json=payload)
12
  return response.json()
13
+
14
+
15
+ def analyze_sentiment(text):
16
+
17
 
18
  output = query({
19
  "inputs": {
20
+
21
+
22
+ "<|start_header_id|>{system}<|end_header_id|>": "you'll only answer in english",
23
+ "<|start_header_id|>{user}<|end_header_id|>": text
24
  }
25
  })
26
 
 
 
27
  # Assurez-vous de gérer correctement la sortie de l'API
28
  if isinstance(output, list) and len(output) > 0:
29
  return output[0].get('generated_text', 'Erreur: Réponse inattendue')