BrainboxAI commited on
Commit
ffc2ccb
verified
1 Parent(s): e095521

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -24,10 +24,14 @@ EXAMPLES = [
24
 
25
  def generate(message, history, temperature, max_tokens):
26
  messages = []
27
- for user_msg, assistant_msg in history:
28
- messages.append({"role": "user", "content": user_msg})
29
- if assistant_msg:
30
- messages.append({"role": "assistant", "content": assistant_msg})
 
 
 
 
31
  messages.append({"role": "user", "content": message})
32
 
33
  inputs = tokenizer.apply_chat_template(
@@ -66,13 +70,14 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), title="Code-IL E4B") as
66
  诪转诪讞讛 讘-Python, TypeScript, n8n, 讜转讜诪讱 讘注讘专讬转.
67
 
68
  > 鈿狅笍 **讚诪讜 讝讛 专抓 注诇 CPU - 讬拽讞 10-30 砖谞讬讜转 诇转砖讜讘讛.**
69
- > 诇讛专爪讛 诪讛讬专讛 讘诪讞砖讘 砖诇讱: `pip install transformers && python` 注诐 砖诪转讞转.
70
 
71
  **By [BrainboxAI](https://huggingface.co/BrainboxAI)** - Powered by Unsloth
72
  """)
73
 
74
  chat = gr.ChatInterface(
75
  fn=generate,
 
76
  examples=EXAMPLES,
77
  cache_examples=False,
78
  additional_inputs=[
 
24
 
25
  def generate(message, history, temperature, max_tokens):
26
  messages = []
27
+ for msg in history:
28
+ if isinstance(msg, dict):
29
+ messages.append({"role": msg["role"], "content": msg["content"]})
30
+ else:
31
+ user_msg, assistant_msg = msg
32
+ messages.append({"role": "user", "content": user_msg})
33
+ if assistant_msg:
34
+ messages.append({"role": "assistant", "content": assistant_msg})
35
  messages.append({"role": "user", "content": message})
36
 
37
  inputs = tokenizer.apply_chat_template(
 
70
  诪转诪讞讛 讘-Python, TypeScript, n8n, 讜转讜诪讱 讘注讘专讬转.
71
 
72
  > 鈿狅笍 **讚诪讜 讝讛 专抓 注诇 CPU - 讬拽讞 10-30 砖谞讬讜转 诇转砖讜讘讛.**
73
+ > 诇讛专爪讛 诪讛讬专讛 讘诪讞砖讘 砖诇讱: 专讗讛 讛讜专讗讜转 转讞转讬转.
74
 
75
  **By [BrainboxAI](https://huggingface.co/BrainboxAI)** - Powered by Unsloth
76
  """)
77
 
78
  chat = gr.ChatInterface(
79
  fn=generate,
80
+ type="messages",
81
  examples=EXAMPLES,
82
  cache_examples=False,
83
  additional_inputs=[