faelfernandes commited on
Commit
91305fd
1 Parent(s): c9226ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -4,25 +4,22 @@ import gradio as gr
4
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
5
 
6
  def format_prompt(message, history, system_prompt=None):
7
- prompt = "<s>"
8
- for user_prompt, bot_response in history:
9
- prompt += f"[INST] {user_prompt} [/INST]"
10
- prompt += f" {bot_response}</s> "
11
- if system_prompt:
12
- prompt += f"[SYS] {system_prompt} [/SYS]"
13
- prompt += f"[INST] {message} [/INST]"
14
- return prompt
15
 
16
  def generate(
17
- prompt, history, system_prompt= “Você sempre se comunica em português brasileiro, a menos que seja solicitado a usar outro idioma.
18
- Além disso, você é um profissional com conhecimento especializado em TSM. Qualquer solicitação feita a você deve
19
- ser atendida com a expertise de um especialista no assunto.”
20
- , temperature=0.3, max_new_tokens=8192, top_p=0.9, repetition_penalty=1.0,
21
- ):
22
- temperature = float(temperature)
23
- if temperature < 1e-2:
24
- temperature = 1e-2
25
- top_p = float(top_p)
26
 
27
  generate_kwargs = dict(
28
  temperature=temperature,
 
4
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
5
 
6
  def format_prompt(message, history, system_prompt=None):
7
+ prompt = "<s>"
8
+ for user_prompt, bot_response in history:
9
+ prompt += f"[INST] {user_prompt} [/INST]"
10
+ prompt += f" {bot_response}</s> "
11
+ if system_prompt:
12
+ prompt += f"[SYS] {system_prompt} [/SYS]"
13
+ prompt += f"[INST] {message} [/INST]"
14
+ return prompt
15
 
16
  def generate(
17
+ prompt, history, system_prompt=None, temperature=0.5, max_new_tokens=8192, top_p=0.9, repetition_penalty=1.0,
18
+ ):
19
+ temperature = float(temperature)
20
+ if temperature < 1e-2:
21
+ temperature = 1e-2
22
+ top_p = float(top_p)
 
 
 
23
 
24
  generate_kwargs = dict(
25
  temperature=temperature,