Update app.py
Browse files
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 |
-
|
22 |
-
To
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
"""
|
29 |
|
30 |
def respond(
|
@@ -35,7 +46,10 @@ def respond(
|
|
35 |
temperature,
|
36 |
top_p,
|
37 |
):
|
38 |
-
|
|
|
|
|
|
|
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=
|
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(
|