UmberH commited on
Commit
9bdefe6
1 Parent(s): 575277a

added the data structure part ot genai

Browse files

added the data structure probklem generation to gen ai

Files changed (1) hide show
  1. app.py +48 -3
app.py CHANGED
@@ -1,4 +1,49 @@
1
- import streamlit as st
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import langchain_helper as lch # Import custom helper module for LangChain operations
2
+ import streamlit as st # Import Streamlit for web app development
3
 
4
+ # Set up the Streamlit web page title
5
+ st.title("Data Structures Problems Generator")
6
+
7
+ # Define the list of topics for data structure problems
8
+ topic_options = [
9
+ "", "Recursion", "Stack", "Queue", "Linked List", "Priority Queue", "Hash Table", "Binary Tree", "Binary Search Tree", "Graph", "Depth-First Search", "Breadth-First Search"
10
+ ]
11
+
12
+ # Create a sidebar selection box in Streamlit for choosing a topic
13
+ topic = st.sidebar.selectbox(
14
+ "Choose a Topic for the Problem",
15
+ topic_options)
16
+
17
+ # Define the list of difficulty levels for the problems
18
+ difficulty_levels = ["", "Easy", "Medium", "Hard"]
19
+ # Create a sidebar selection box in Streamlit for choosing the difficulty level
20
+ difficulty = st.sidebar.selectbox(
21
+ "Choose a Difficulty Level",
22
+ difficulty_levels)
23
+
24
+ # Create buttons in the sidebar for submitting a problem request and for solving a problem
25
+ submit_button = st.sidebar.button("Submit")
26
+ solve_button = st.sidebar.button("Solve")
27
+
28
+ # Handle the event when the 'Submit' button is clicked
29
+ if submit_button and topic and difficulty:
30
+ # Generate a data structure problem using the selected topic and difficulty
31
+ response = lch.generate_DS_problem(
32
+ topic=topic, difficulty=difficulty)
33
+ # Store the generated problem in a variable
34
+ lch.coding_problem = response["coding_problem"]
35
+ # Display the generated problem on the web page
36
+ st.subheader("Coding problem: ")
37
+ st.markdown(lch.coding_problem)
38
+
39
+ # Handle the event when the 'Solve' button is clicked
40
+ if solve_button and lch.coding_problem:
41
+ # Generate a solution for the stored coding problem
42
+ solution = lch.generate_DS_solution(lch.coding_problem)
43
+ # Extract the solution from the response
44
+ solution = solution["coding_problem_solution"]
45
+ # Display both the problem and its solution on the web page
46
+ st.subheader("Coding problem: ")
47
+ st.markdown(lch.coding_problem)
48
+ st.subheader("Solution: ")
49
+ st.markdown(solution)