Skip to content

Commit

Permalink
critical analysis: attempt 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudhendra committed Oct 22, 2024
1 parent ae62add commit e4fe698
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions mindmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ def generate_mindmap(query: str) -> str:
st.error(f"Error generating mindmap: {str(e)}")
return "# Error\n## Sorry, I couldn't generate a mindmap at this time."

def generate_analysis(mindmap_content: str) -> str:
try:
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a medical expert specializing in USMLE Step 1 content. Provide a critical analysis report based on the given mindmap, expanding upon the topics to help USMLE Step 1 students understand this topic immediately."},
{"role": "user", "content": f"Based on the following mindmap, provide a critical analysis report for USMLE Step 1 students:\n\n{mindmap_content}"}
],
max_tokens=1500,
n=1,
stop=None,
temperature=0.3,
)
return response.choices[0].message.content.strip()
except Exception as e:
st.error(f"Error generating analysis: {str(e)}")
return "Sorry, I couldn't generate an analysis at this time."

def display_mindmap(mindmap_content: str):
# Display the raw markdown content
st.subheader("Markdown Content:")
Expand All @@ -44,21 +62,24 @@ def mindmap_tab_content():
# Create a progress bar
progress_bar = st.progress(0)

# Generate the mindmap
mindmap = generate_mindmap(query)

# Simulate progress while generating the mindmap
for i in range(100):
# Update progress bar
progress_bar.progress(i + 1)

if i == 0:
# Start generating the mindmap
mindmap = generate_mindmap(query)

# Add a small delay to make the progress bar visible
time.sleep(0.05)

# Display the generated mindmap
display_mindmap(mindmap)

# Generate and display the analysis
st.subheader("Analysis")
with st.spinner("Generating analysis..."):
analysis = generate_analysis(mindmap)
st.markdown(analysis)

# Remove the progress bar
progress_bar.empty()
else:
Expand Down

0 comments on commit e4fe698

Please sign in to comment.