Tonic commited on
Commit
dd51e9f
1 Parent(s): 74663dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -35
app.py CHANGED
@@ -6,7 +6,7 @@ if 'learning_objectives' not in st.session_state:
6
  st.session_state.learning_objectives = ""
7
 
8
  # Streamlit User Input Form
9
- st.title("Lesson Plan Generator")
10
 
11
  # API Key Input
12
  api_key = st.text_input("Enter your OpenAI API Key:", type="password")
@@ -18,65 +18,57 @@ model_choice = st.selectbox(
18
  )
19
 
20
  # Context, Subject, and Level
21
- context = "Your goal is to create an effective lesson plan."
22
- subject = st.text_input("Subject:", "Mathematics")
23
- level = st.text_input("Education Level:", "High School")
24
 
25
  # Initialize OpenAI API
26
  if api_key:
27
  openai.api_key = api_key
28
 
29
  # Learning Objectives
30
- st.write("### Learning Objectives:")
31
  # Initialize autogenerated objectives
32
- autogenerated_objectives = ""
33
  # Initialize status placeholder
34
  learning_status_placeholder = st.empty()
35
  disable_button_bool = False
36
- if subject and level and api_key and st.button("Generate Learning Objectives",key="generate_learning_objectives",disabled=disable_button_bool):
37
 
38
  # Display status message
39
  learning_status_placeholder.text("Generating learning objectives...")
40
  # API call to generate objectives
41
- learning_objectives_response = openai.ChatCompletion.create(
42
  model=model_choice,
43
  messages=[
44
- {"role": "user", "content": f"Generate learning objectives for a {level} level {subject} lesson."}
45
  ]
46
  )
47
  # Extract the generated objectives from the API response
48
- learning_objectives=learning_objectives_response['choices'][0]['message']['content']
49
 
50
  # Save generated objectives to session state
51
- st.session_state.learning_objectives = learning_objectives.strip()
52
 
53
  # Display generated objectives
54
- learning_status_placeholder.text(f"Learning objectives generated!\n{learning_objectives.strip()}")
55
 
56
  # Generate Lesson Plan Button
57
- if st.button("Generate Lesson Plan") and api_key:
58
 
59
  # Construct the prompt as a dictionary
60
  prompt_dict = {
61
  "context": context,
62
- "subject": subject,
63
- "level": level,
64
- "learning_objectives": st.session_state.learning_objectives,
65
  "tasks": [
66
- {"task": "Curate educational material", "objective": "To provide accurate and relevant information"},
67
- {"task": "Evaluate the material", "objective": "To ensure alignment with educational standards"},
68
- {"task": "Create assessment tools", "objective": "To measure student understanding and retention"},
69
- {"task": "Design interactive activities", "objective": "To facilitate active learning and engagement"}
70
  ],
71
- "output_format": """Present the lesson plan in a structured format.
72
- \nTitle:
73
- \nGrade Level: RESTATED FROM ABOVE
74
- \nSubject: RESTATED FROM ABOVE
75
- \nObjectives: RESTATED FROM ABOVE
76
- \nActivities:
77
- \nAssessment: Application of knowledge and skills through a task
78
- \nProcedure: Formatted as a list of steps and substeps
79
- \nResources:
80
  \nNotes:
81
 
82
  """
@@ -94,11 +86,11 @@ if st.button("Generate Lesson Plan") and api_key:
94
  )
95
 
96
  # Display status message
97
- lesson_plan=st.text("Generating lesson plan...")
98
 
99
- # Extract and display the lesson plan
100
- assistant_reply = lesson_plan_response['choices'][0]['message']['content']
101
- lesson_plan=st.text(assistant_reply.strip())
102
 
103
- # Citation for the GitHub repo
104
- st.markdown("<sub>This app was created by [Taylor Ennen](https://github.com/taylor-ennen/GPT-Streamlit-MVP)</sub>", unsafe_allow_html=True)
 
6
  st.session_state.learning_objectives = ""
7
 
8
  # Streamlit User Input Form
9
+ st.title("Patent Claims Extraction")
10
 
11
  # API Key Input
12
  api_key = st.text_input("Enter your OpenAI API Key:", type="password")
 
18
  )
19
 
20
  # Context, Subject, and Level
21
+ context = "You are a patent claims identifier and extractor. You will freeform text, identify any claims contained therein that may be patentable. You identify , extract, print such claims, briefly explain why each claim is patentable."
22
+ userinput = st.text_input("Input Text:", "Mathematics")
 
23
 
24
  # Initialize OpenAI API
25
  if api_key:
26
  openai.api_key = api_key
27
 
28
  # Learning Objectives
29
+ st.write("### Patentable Claims:")
30
  # Initialize autogenerated objectives
31
+ claims_extraction = ""
32
  # Initialize status placeholder
33
  learning_status_placeholder = st.empty()
34
  disable_button_bool = False
35
+ if userinput and api_key and st.button("Extract Claims",key="claims_extraction",disabled=disable_button_bool):
36
 
37
  # Display status message
38
  learning_status_placeholder.text("Generating learning objectives...")
39
  # API call to generate objectives
40
+ claims_extraction_response = openai.ChatCompletion.create(
41
  model=model_choice,
42
  messages=[
43
+ {"role": "user", "content": f"Extract any patentable claims from the following: \n {userinput}. \n extract each claim. Briefly explain why you extracted this wordphrase. Exclude any additional commentary."}
44
  ]
45
  )
46
  # Extract the generated objectives from the API response
47
+ claims_extraction=claims_extraction_response['choices'][0]['message']['content']
48
 
49
  # Save generated objectives to session state
50
+ st.session_state.claims_extraction = claims_extraction.strip()
51
 
52
  # Display generated objectives
53
+ learning_status_placeholder.text(f"Patentable Claims Extracted!\n{claims_extraction.strip()}")
54
 
55
  # Generate Lesson Plan Button
56
+ if st.button("Extract Claims") and api_key:
57
 
58
  # Construct the prompt as a dictionary
59
  prompt_dict = {
60
  "context": context,
61
+ "userinput": userinput,
62
+ "claims_extraction": st.session_state.claims_extraction,
 
63
  "tasks": [
64
+ {"task": "Extract Claims", "objective": "extract any wordphrases in the text provided that could be considered a patentable claim"},
65
+ {"task": "Extract Every Claim", "objective": "Ensure each and every wordphrase with a claim is evaluated whether or not it is patentable"},
66
+ {"task": "Explain Your Choice", "objective": "Briefly explain why you have retained each claim"},
67
+ {"task": "Check Your Work", "objective": "Check your work to assure you have not forgotten any claims"}
68
  ],
69
+ "output_format": """Present in a structured format.
70
+ \nClaim:
71
+ \nExplanation:
 
 
 
 
 
 
72
  \nNotes:
73
 
74
  """
 
86
  )
87
 
88
  # Display status message
89
+ lesson_plan=st.text("Extracting Patentable Claims...")
90
 
91
+ # Extract and display
92
+ assistant_reply = claims_extraction_response['choices'][0]['message']['content']
93
+ claims_extraction=st.text(assistant_reply.strip())
94
 
95
+ # Citation
96
+ st.markdown("<sub>This app was created by [Tonic](https://huggingface.co/tonic)</sub>", unsafe_allow_html=True)