Martial667 commited on
Commit
e7c53a2
·
verified ·
1 Parent(s): 566493a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -28
app.py CHANGED
@@ -11,34 +11,30 @@ def respond(
11
  top_p,
12
  hf_token: gr.OAuthToken,
13
  ):
14
- if hf_token is None:
15
- raise gr.Error("Veuillez vous connecter via le bouton dans la barre latérale.")
16
-
17
- try:
18
- client = InferenceClient(token=hf_token.token, model="deepseek-ai/DeepSeek-V3.2")
19
-
20
- messages = [{"role": "system", "content": system_message}]
21
- messages.extend(history)
22
- messages.append({"role": "user", "content": message})
23
-
24
- response = ""
25
-
26
- for message in client.chat_completion(
27
- messages,
28
- max_tokens=max_tokens,
29
- stream=True,
30
- temperature=temperature,
31
- top_p=top_p,
32
- ):
33
- choices = message.choices
34
- token = ""
35
- if len(choices) and choices[0].delta.content:
36
- token = choices[0].delta.content
37
-
38
- response += token
39
- yield response
40
- except Exception as e:
41
- raise gr.Error(f"Erreur modèle : {str(e)}")
42
 
43
 
44
  custom_theme = gr.themes.Soft(
 
11
  top_p,
12
  hf_token: gr.OAuthToken,
13
  ):
14
+
15
+ client = InferenceClient(token=hf_token.token, model="deepseek-ai/DeepSeek-V3.2")
16
+
17
+ messages = [{"role": "system", "content": system_message}]
18
+ messages.extend(history)
19
+ messages.append({"role": "user", "content": message})
20
+
21
+ response = ""
22
+
23
+ for message in client.chat_completion(
24
+ messages,
25
+ max_tokens=max_tokens,
26
+ stream=True,
27
+ temperature=temperature,
28
+ top_p=top_p,
29
+ ):
30
+ choices = message.choices
31
+ token = ""
32
+ if len(choices) and choices[0].delta.content:
33
+ token = choices[0].delta.content
34
+
35
+ response += token
36
+ yield response
37
+
 
 
 
 
38
 
39
 
40
  custom_theme = gr.themes.Soft(