prithivMLmods commited on
Commit
695e89b
·
verified ·
1 Parent(s): 13c902d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -17,6 +17,16 @@ client = OpenAI(
17
  api_key=ACCESS_TOKEN,
18
  )
19
 
 
 
 
 
 
 
 
 
 
 
20
  def respond(
21
  message,
22
  history: list[tuple[str, str]],
@@ -25,7 +35,7 @@ def respond(
25
  temperature,
26
  top_p,
27
  ):
28
- messages = [{"role": "system", "content": system_message}]
29
 
30
  for val in history:
31
  if val[0]:
@@ -37,7 +47,7 @@ def respond(
37
 
38
  response = ""
39
 
40
- for message in client.chat.completions.create(
41
  model="meta-llama/Meta-Llama-3.1-8B-Instruct",
42
  max_tokens=max_tokens,
43
  stream=True,
@@ -53,7 +63,7 @@ def respond(
53
  demo = gr.ChatInterface(
54
  respond,
55
  additional_inputs=[
56
- gr.Textbox(value="", label="System message"),
57
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
58
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
59
  gr.Slider(
@@ -63,9 +73,9 @@ demo = gr.ChatInterface(
63
  step=0.05,
64
  label="Top-P",
65
  ),
66
-
67
  ],
68
  css=css
69
  )
 
70
  if __name__ == "__main__":
71
  demo.launch()
 
17
  api_key=ACCESS_TOKEN,
18
  )
19
 
20
+ SYSTEM_PROMPT = """You are an expert assistant who can solve any task using code blobs. You will be given a task to solve as best you can.
21
+ To do so, you have been given access to a list of tools: these tools are basically Python functions which you can call with code.
22
+ To solve the task, you must plan forward to proceed in a series of steps, in a cycle of 'Thought:', 'Code:', and 'Observation:' sequences.
23
+ At each step, in the 'Thought:' sequence, you should first explain your reasoning towards solving the task and the tools that you want to use.
24
+ Then in the 'Code:' sequence, you should write the code in simple Python. The code sequence must end with '<end_code>' sequence.
25
+ During each intermediate step, you can use 'print()' to save whatever important information you will then need.
26
+ These print outputs will then appear in the 'Observation:' field, which will be available as input for the next step.
27
+ In the end, you have to return a final answer using the `final_answer` tool.
28
+ """
29
+
30
  def respond(
31
  message,
32
  history: list[tuple[str, str]],
 
35
  temperature,
36
  top_p,
37
  ):
38
+ messages = [{"role": "system", "content": SYSTEM_PROMPT}]
39
 
40
  for val in history:
41
  if val[0]:
 
47
 
48
  response = ""
49
 
50
+ for message in client.chat.completions.create(
51
  model="meta-llama/Meta-Llama-3.1-8B-Instruct",
52
  max_tokens=max_tokens,
53
  stream=True,
 
63
  demo = gr.ChatInterface(
64
  respond,
65
  additional_inputs=[
66
+ gr.Textbox(value=SYSTEM_PROMPT, label="System message"),
67
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
68
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
69
  gr.Slider(
 
73
  step=0.05,
74
  label="Top-P",
75
  ),
 
76
  ],
77
  css=css
78
  )
79
+
80
  if __name__ == "__main__":
81
  demo.launch()