Ultronprime commited on
Commit
44edc4c
·
verified ·
1 Parent(s): e508eb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -7,11 +7,18 @@ def generate_text(input_text, history):
7
  # Initialize the pipeline with specified parameters
8
  pipe = pipeline("text-generation", model="ngxson/MiniThinky-v2-1B-Llama-3.2", max_new_tokens=1024, temperature=0.7, do_sample=True)
9
 
 
 
 
10
  # Generate response
11
- response = pipe(input_text, max_new_tokens=1024, temperature=0.7, do_sample=True)
 
 
 
12
 
13
  # Append user and assistant messages to history
14
- history.append((input_text, response[0]['generated_text']))
 
15
 
16
  # Return updated history
17
  return history
@@ -24,7 +31,7 @@ demo = gr.Interface(
24
  gr.JSON(value=[], visible=False)
25
  ],
26
  outputs=[
27
- gr.Chatbot(label="Chat History")
28
  ],
29
  title="MiniThinky Text Generator"
30
  )
 
7
  # Initialize the pipeline with specified parameters
8
  pipe = pipeline("text-generation", model="ngxson/MiniThinky-v2-1B-Llama-3.2", max_new_tokens=1024, temperature=0.7, do_sample=True)
9
 
10
+ # Prepare the messages
11
+ messages = [{"role": "user", "content": input_text}]
12
+
13
  # Generate response
14
+ response = pipe(messages)
15
+
16
+ # Extract the generated text
17
+ response_text = response[0]["generated_text"]
18
 
19
  # Append user and assistant messages to history
20
+ history.append({"role": "user", "content": input_text})
21
+ history.append({"role": "assistant", "content": response_text})
22
 
23
  # Return updated history
24
  return history
 
31
  gr.JSON(value=[], visible=False)
32
  ],
33
  outputs=[
34
+ gr.Chatbot(type='messages')
35
  ],
36
  title="MiniThinky Text Generator"
37
  )