Andrewstivan commited on
Commit
5849680
·
verified ·
1 Parent(s): 199e1f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -14
app.py CHANGED
@@ -1,23 +1,46 @@
1
  import gradio as gr
2
  from transformers import pipeline
 
3
 
4
- print("Loading model...")
5
- pipe = pipeline("text-generation", model="Andrewstivan/AURA", device=-1)
6
- print("Model loaded!")
 
 
 
 
 
 
 
 
 
7
 
8
  def chat(message, history):
9
- result = pipe(
10
- message,
11
- max_new_tokens=300,
12
- temperature=0.8,
13
- do_sample=True,
14
- truncation=True,
15
- max_length=512
16
- )
17
- return result[0]["generated_text"]
 
 
 
 
 
 
18
 
19
- gr.ChatInterface(
 
20
  fn=chat,
21
  title="✨ Aura — поэтичная модель",
22
  description="Пишите по-русски, модель отвечает на русском"
23
- ).launch()
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
+ import sys
4
 
5
+ print("Loading model...", flush=True)
6
+ try:
7
+ pipe = pipeline(
8
+ "text-generation",
9
+ model="Andrewstivan/AURA",
10
+ device=-1,
11
+ trust_remote_code=True
12
+ )
13
+ print("Model loaded successfully!", flush=True)
14
+ except Exception as e:
15
+ print(f"Error loading model: {e}", flush=True)
16
+ sys.exit(1)
17
 
18
  def chat(message, history):
19
+ if not message:
20
+ return ""
21
+
22
+ try:
23
+ result = pipe(
24
+ message,
25
+ max_new_tokens=300,
26
+ temperature=0.8,
27
+ do_sample=True,
28
+ truncation=True,
29
+ max_length=512
30
+ )
31
+ return result[0]["generated_text"]
32
+ except Exception as e:
33
+ return f"Ошибка: {e}"
34
 
35
+
36
+ demo = gr.ChatInterface(
37
  fn=chat,
38
  title="✨ Aura — поэтичная модель",
39
  description="Пишите по-русски, модель отвечает на русском"
40
+ )
41
+
42
+ demo.launch(
43
+ server_name="0.0.0.0",
44
+ server_port=7860,
45
+ share=False
46
+ )