shukdevdatta123 commited on
Commit
86d55bc
·
verified ·
1 Parent(s): 70115e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -18,7 +18,7 @@ def solve_competitive_problem(problem_statement, language_choice, api_key, remem
18
  Returns:
19
  str: Step-by-step solution with code
20
  """
21
- if not api_key.strip():
22
  return "Error: Please provide your OpenRouter API key."
23
 
24
  if not problem_statement.strip():
@@ -79,12 +79,10 @@ Format your answer with clear headings and subheadings. Use markdown formatting
79
  "X-Title": "Competitive Programming Assistant",
80
  },
81
  model="open-r1/olympiccoder-7b:free",
82
- messages=[
83
- {
84
- "role": "user",
85
- "content": prompt
86
- }
87
- ],
88
  temperature=0.7,
89
  stream=True # Enable streaming for partial results
90
  )
@@ -124,7 +122,7 @@ def save_api_key(api_key, remember):
124
  """
125
  return f"""
126
  function() {{
127
- if ({str(remember).lower()}) {{
128
  localStorage.setItem('openrouter_api_key', "{api_key}");
129
  }} else {{
130
  localStorage.removeItem('openrouter_api_key');
@@ -210,7 +208,7 @@ with gr.Blocks(title="Competitive Programming Assistant", theme=light_theme, css
210
  }
211
  });
212
  """)
213
-
214
  # App header with theme toggle
215
  with gr.Row(elem_classes="responsive-padding"):
216
  gr.Markdown("""
 
18
  Returns:
19
  str: Step-by-step solution with code
20
  """
21
+ if not api_key or not api_key.strip():
22
  return "Error: Please provide your OpenRouter API key."
23
 
24
  if not problem_statement.strip():
 
79
  "X-Title": "Competitive Programming Assistant",
80
  },
81
  model="open-r1/olympiccoder-7b:free",
82
+ messages=[{
83
+ "role": "user",
84
+ "content": prompt
85
+ }],
 
 
86
  temperature=0.7,
87
  stream=True # Enable streaming for partial results
88
  )
 
122
  """
123
  return f"""
124
  function() {{
125
+ if ({str(remember).toLowerCase()}) {{
126
  localStorage.setItem('openrouter_api_key', "{api_key}");
127
  }} else {{
128
  localStorage.removeItem('openrouter_api_key');
 
208
  }
209
  });
210
  """)
211
+
212
  # App header with theme toggle
213
  with gr.Row(elem_classes="responsive-padding"):
214
  gr.Markdown("""