padufour commited on
Commit
8057342
Β·
verified Β·
1 Parent(s): 283086e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -38
app.py CHANGED
@@ -1,14 +1,15 @@
1
  import gradio as gr
2
- from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import re
4
 
5
  print("πŸ”„ Chargement du modΓ¨le...")
6
 
7
- # CHARGER SANS QUANTIZATION
8
  model = AutoModelForCausalLM.from_pretrained(
9
  "padufour/mistral-accor-emails",
10
  low_cpu_mem_usage=True,
11
- quantization_config=None # ← Ignore la config 4-bit du modΓ¨le
 
12
  )
13
 
14
  tokenizer = AutoTokenizer.from_pretrained("padufour/mistral-accor-emails")
@@ -63,51 +64,32 @@ Important: Ne pas inclure de placeholders [], ne pas mentionner le segment, ne p
63
  email = re.sub(r'\n\s*\n\s*\n', '\n\n', email)
64
  return email.strip()
65
 
66
- with gr.Blocks(theme=gr.themes.Soft(), title="ACCOR Email Generator") as demo:
67
-
68
- gr.Markdown("# 🎯 ACCOR Email Generator\n**Powered by Mistral-7B Fine-tuned**")
69
 
70
  with gr.Row():
71
  with gr.Column():
72
  email_type = gr.Dropdown(
73
- choices=["Newsletter", "New offers", "theme", "solution"],
74
- value="Newsletter",
75
- label="Email Type"
76
- )
77
- segment = gr.Dropdown(
78
- choices=["MICE", "AHBO", "leisure group"],
79
- value="MICE",
80
- label="Segment"
81
  )
82
  client_name = gr.Textbox(label="Client Name", value="Marie Dupont")
83
- company = gr.Textbox(label="Company", value="Event Solutions SA")
84
- objective = gr.Textbox(label="Objective", value="Promote winter events", lines=2)
85
 
86
- with gr.Accordion("Advanced Options", open=False):
87
- priority = gr.Radio(["High", "Medium", "Low"], value="High", label="Priority")
88
- history = gr.Textbox(label="Client History", value="New customer")
89
- style = gr.Textbox(label="Style", value="Professional")
90
- language = gr.Radio(["ENGLISH", "FRENCH"], value="ENGLISH", label="Language")
91
 
92
- generate_btn = gr.Button("πŸš€ Generate Email", variant="primary")
93
 
94
  with gr.Column():
95
- output = gr.Textbox(label="Generated Email", lines=25, show_copy_button=True)
96
 
97
- generate_btn.click(
98
- fn=generate_email,
99
- inputs=[email_type, client_name, company, objective, segment, priority, history, style, language],
100
- outputs=output
101
- )
102
-
103
- gr.Examples(
104
- examples=[
105
- ["Newsletter", "Marie Dupont", "Event Solutions", "Promote events", "MICE", "High", "New", "Professional", "ENGLISH"],
106
- ["New offers", "John Smith", "Travel Corp", "Summer deals", "leisure group", "Medium", "Regular", "Friendly", "ENGLISH"],
107
- ],
108
- inputs=[email_type, client_name, company, objective, segment, priority, history, style, language],
109
- outputs=output,
110
- fn=generate_email,
111
- )
112
 
113
  demo.launch()
 
1
  import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
3
  import re
4
 
5
  print("πŸ”„ Chargement du modΓ¨le...")
6
 
7
+ # IGNORER LA QUANTIZATION avec un objet vide
8
  model = AutoModelForCausalLM.from_pretrained(
9
  "padufour/mistral-accor-emails",
10
  low_cpu_mem_usage=True,
11
+ device_map=None, # Pas de device_map auto
12
+ trust_remote_code=True
13
  )
14
 
15
  tokenizer = AutoTokenizer.from_pretrained("padufour/mistral-accor-emails")
 
64
  email = re.sub(r'\n\s*\n\s*\n', '\n\n', email)
65
  return email.strip()
66
 
67
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
68
+ gr.Markdown("# 🎯 ACCOR Email Generator\n**Powered by Mistral-7B**")
 
69
 
70
  with gr.Row():
71
  with gr.Column():
72
  email_type = gr.Dropdown(
73
+ ["Newsletter", "New offers", "theme", "solution"],
74
+ value="Newsletter", label="Email Type"
 
 
 
 
 
 
75
  )
76
  client_name = gr.Textbox(label="Client Name", value="Marie Dupont")
77
+ company = gr.Textbox(label="Company", value="Event Solutions")
78
+ objective = gr.Textbox(label="Objective", value="Promote events", lines=2)
79
 
80
+ segment = gr.Dropdown(["MICE", "AHBO", "leisure group"], value="MICE", label="Segment")
81
+ priority = gr.Radio(["High", "Medium", "Low"], value="High", label="Priority")
82
+ history = gr.Textbox(label="History", value="New customer")
83
+ style = gr.Textbox(label="Style", value="Professional")
84
+ language = gr.Radio(["ENGLISH", "FRENCH"], value="ENGLISH")
85
 
86
+ btn = gr.Button("πŸš€ Generate", variant="primary")
87
 
88
  with gr.Column():
89
+ output = gr.Textbox(label="Email", lines=30, show_copy_button=True)
90
 
91
+ btn.click(generate_email,
92
+ [email_type, client_name, company, objective, segment, priority, history, style, language],
93
+ output)
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
  demo.launch()