davidberenstein1957 HF staff commited on
Commit
46218ed
1 Parent(s): 7ccc989

Add random system message

Browse files
Files changed (2) hide show
  1. app.py +3 -1
  2. chat_interface_preference.py +1 -2
app.py CHANGED
@@ -1,5 +1,6 @@
1
  #!/usr/bin/env python
2
  import os
 
3
  from threading import Thread
4
  from typing import Iterator
5
 
@@ -30,7 +31,8 @@ def generate(
30
  top_k: int = 40,
31
  repetition_penalty: float = 1.2,
32
  ) -> Iterator[str]:
33
- conversation = [{"role": "system", "content": "be concise"}]
 
34
  for user, assistant in chat_history:
35
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
36
  conversation.append({"role": "user", "content": message})
 
1
  #!/usr/bin/env python
2
  import os
3
+ import random
4
  from threading import Thread
5
  from typing import Iterator
6
 
 
31
  top_k: int = 40,
32
  repetition_penalty: float = 1.2,
33
  ) -> Iterator[str]:
34
+ system_message = random.choice(["concise", "explicit", "simple", "complex", "usefull", "helpfull"])
35
+ conversation = [{"role": "system", "content": f"Communicate {system_message}."}]
36
  for user, assistant in chat_history:
37
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
38
  conversation.append({"role": "user", "content": message})
chat_interface_preference.py CHANGED
@@ -27,9 +27,8 @@ from gradio.components import (
27
  get_component_instance,
28
  )
29
  from gradio.events import Dependency, on
30
- from gradio.helpers import Error, Info
31
  from gradio.helpers import create_examples as Examples # noqa: N812
32
- from gradio.helpers import special_args
33
  from gradio.layouts import Accordion, Group, Row
34
  from gradio.routes import Request
35
  from gradio.themes import ThemeClass as Theme
 
27
  get_component_instance,
28
  )
29
  from gradio.events import Dependency, on
30
+ from gradio.helpers import Error, Info, special_args
31
  from gradio.helpers import create_examples as Examples # noqa: N812
 
32
  from gradio.layouts import Accordion, Group, Row
33
  from gradio.routes import Request
34
  from gradio.themes import ThemeClass as Theme