Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,13 +9,12 @@ genai.configure(api_key="AIzaSyBPQF0g5EfEPzEiGRzA3iNzJZK4jDukMvE")
|
|
| 9 |
# Initialize the model
|
| 10 |
model = genai.GenerativeModel('gemini-pro')
|
| 11 |
|
| 12 |
-
|
| 13 |
-
@lru_cache(maxsize=100)
|
| 14 |
def get_coding_exercise(topic, difficulty):
|
| 15 |
"""Generate a coding exercise based on the given topic and difficulty."""
|
| 16 |
prompt = f"Briefly create a {difficulty} Python coding exercise about {topic}. Include a concise problem statement and expected output. Keep it under 100 words."
|
| 17 |
try:
|
| 18 |
-
response = model.generate_content(prompt
|
| 19 |
return response.text
|
| 20 |
except Exception as e:
|
| 21 |
return f"Error generating exercise: {str(e)}"
|
|
@@ -32,7 +31,7 @@ def evaluate_code(exercise, user_code):
|
|
| 32 |
If there are errors, explain them. Suggest improvements. Keep the response under 150 words.
|
| 33 |
"""
|
| 34 |
try:
|
| 35 |
-
response = model.generate_content(prompt
|
| 36 |
return response.text
|
| 37 |
except Exception as e:
|
| 38 |
return f"Error evaluating code: {str(e)}"
|
|
|
|
| 9 |
# Initialize the model
|
| 10 |
model = genai.GenerativeModel('gemini-pro')
|
| 11 |
|
| 12 |
+
|
|
|
|
| 13 |
def get_coding_exercise(topic, difficulty):
|
| 14 |
"""Generate a coding exercise based on the given topic and difficulty."""
|
| 15 |
prompt = f"Briefly create a {difficulty} Python coding exercise about {topic}. Include a concise problem statement and expected output. Keep it under 100 words."
|
| 16 |
try:
|
| 17 |
+
response = model.generate_content(prompt)
|
| 18 |
return response.text
|
| 19 |
except Exception as e:
|
| 20 |
return f"Error generating exercise: {str(e)}"
|
|
|
|
| 31 |
If there are errors, explain them. Suggest improvements. Keep the response under 150 words.
|
| 32 |
"""
|
| 33 |
try:
|
| 34 |
+
response = model.generate_content(prompt)
|
| 35 |
return response.text
|
| 36 |
except Exception as e:
|
| 37 |
return f"Error evaluating code: {str(e)}"
|