prithivMLmods commited on
Commit
22aeb2c
·
verified ·
1 Parent(s): 695e89b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -9
app.py CHANGED
@@ -18,13 +18,24 @@ client = OpenAI(
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(
@@ -35,7 +46,10 @@ def respond(
35
  temperature,
36
  top_p,
37
  ):
38
- messages = [{"role": "system", "content": SYSTEM_PROMPT}]
 
 
 
39
 
40
  for val in history:
41
  if val[0]:
@@ -63,7 +77,7 @@ def respond(
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(
 
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
+
22
+ To do so, you must follow a structured reasoning process in a cycle of:
23
+
24
+ 1. **Thought:**
25
+ - Analyze the problem and explain your reasoning.
26
+ - Identify any necessary tools or techniques.
27
+
28
+ 2. **Code:**
29
+ - Implement the solution using Python.
30
+ - Enclose the code block with `<end_code>`.
31
+
32
+ 3. **Observation:**
33
+ - Explain the output and verify correctness.
34
+
35
+ 4. **Final Answer:**
36
+ - Summarize the solution clearly.
37
+
38
+ Always adhere to the **Thought → Code → Observation → Final Answer** structure.
39
  """
40
 
41
  def respond(
 
46
  temperature,
47
  top_p,
48
  ):
49
+ # Apply the structured system prompt
50
+ system_message = SYSTEM_PROMPT
51
+
52
+ messages = [{"role": "system", "content": system_message}]
53
 
54
  for val in history:
55
  if val[0]:
 
77
  demo = gr.ChatInterface(
78
  respond,
79
  additional_inputs=[
80
+ gr.Textbox(value="", label="System message"),
81
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
82
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
83
  gr.Slider(