Update v1.txt
Browse files
v1.txt
CHANGED
|
@@ -37,7 +37,7 @@ def generate_systematic_review(pdf_files, review_question, include_tables=True):
|
|
| 37 |
openai.api_key = api_key
|
| 38 |
|
| 39 |
# Create the system message with systematic review guidelines
|
| 40 |
-
system_prompt = """
|
| 41 |
Step 1: Identify a Research Field
|
| 42 |
The first step in writing a systematic review paper is to identify a research field. This involves selecting a specific area of study that you are interested in and want to explore further.
|
| 43 |
|
|
@@ -105,12 +105,21 @@ def generate_systematic_review(pdf_files, review_question, include_tables=True):
|
|
| 105 |
response = openai.ChatCompletion.create(
|
| 106 |
model="gpt-4.1",
|
| 107 |
messages=messages,
|
| 108 |
-
temperature=
|
| 109 |
top_p=1,
|
| 110 |
-
max_tokens=
|
| 111 |
)
|
| 112 |
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
except Exception as e:
|
| 116 |
return f"Error generating systematic review: {str(e)}"
|
|
@@ -130,12 +139,39 @@ def save_uploaded_files(files):
|
|
| 130 |
|
| 131 |
return saved_paths
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
# Gradio UI Layout
|
| 134 |
-
with gr.Blocks() as demo:
|
| 135 |
gr.Markdown("# Systematic Review Generator for Research Papers")
|
| 136 |
|
| 137 |
with gr.Accordion("How to Use This App", open=True):
|
| 138 |
-
gr.Markdown("""
|
| 139 |
### Getting Started:
|
| 140 |
1. Enter your OpenAI API key in the field below and click "Set API Key"
|
| 141 |
2. Upload multiple PDF research papers (2 or more recommended)
|
|
@@ -160,12 +196,12 @@ with gr.Blocks() as demo:
|
|
| 160 |
with gr.Row():
|
| 161 |
with gr.Column():
|
| 162 |
pdf_files = gr.File(label="Upload PDF Research Papers", file_count="multiple", type="binary")
|
| 163 |
-
review_question = gr.Textbox(label="Review Question or Topic",
|
| 164 |
include_tables = gr.Checkbox(label="Include Comparison Tables", value=True)
|
| 165 |
generate_button = gr.Button("Generate Systematic Review", elem_id="generate_button")
|
| 166 |
|
| 167 |
# Output
|
| 168 |
-
review_output = gr.
|
| 169 |
|
| 170 |
# Button actions
|
| 171 |
api_key_button.click(set_api_key, inputs=[api_key_input], outputs=[api_key_output])
|
|
@@ -196,32 +232,6 @@ with gr.Blocks() as demo:
|
|
| 196 |
outputs=[review_output]
|
| 197 |
)
|
| 198 |
|
| 199 |
-
# Add CSS styling
|
| 200 |
-
css = """
|
| 201 |
-
<style>
|
| 202 |
-
#generate_button {
|
| 203 |
-
background: linear-gradient(135deg, #4a00e0 0%, #8e2de2 100%); /* Purple gradient */
|
| 204 |
-
color: white;
|
| 205 |
-
font-weight: bold;
|
| 206 |
-
}
|
| 207 |
-
#generate_button:hover {
|
| 208 |
-
background: linear-gradient(135deg, #5b10f1 0%, #9f3ef3 100%); /* Slightly lighter */
|
| 209 |
-
}
|
| 210 |
-
#api_key_button {
|
| 211 |
-
background: linear-gradient(135deg, #68d391 0%, #48bb78 100%); /* Green gradient */
|
| 212 |
-
color: white;
|
| 213 |
-
font-weight: bold;
|
| 214 |
-
margin-top: 27px;
|
| 215 |
-
}
|
| 216 |
-
#api_key_button:hover {
|
| 217 |
-
background: linear-gradient(135deg, #38a169 0%, #68d391 100%); /* Slightly darker green */
|
| 218 |
-
}
|
| 219 |
-
.gradio-container {
|
| 220 |
-
max-width: 1200px !important;
|
| 221 |
-
}
|
| 222 |
-
</style>
|
| 223 |
-
"""
|
| 224 |
-
|
| 225 |
# Launch the app
|
| 226 |
if __name__ == "__main__":
|
| 227 |
demo.launch(share=True)
|
|
|
|
| 37 |
openai.api_key = api_key
|
| 38 |
|
| 39 |
# Create the system message with systematic review guidelines
|
| 40 |
+
system_prompt = """You are an expert academic assistant. Create a systematic review in HTML format using <h2>, <h3>, <p>, <ul>, and <table> tags. The Systematic Review must be in great details. Structure it using these steps:
|
| 41 |
Step 1: Identify a Research Field
|
| 42 |
The first step in writing a systematic review paper is to identify a research field. This involves selecting a specific area of study that you are interested in and want to explore further.
|
| 43 |
|
|
|
|
| 105 |
response = openai.ChatCompletion.create(
|
| 106 |
model="gpt-4.1",
|
| 107 |
messages=messages,
|
| 108 |
+
temperature=0.7,
|
| 109 |
top_p=1,
|
| 110 |
+
max_tokens=16384
|
| 111 |
)
|
| 112 |
|
| 113 |
+
# Format the response in HTML
|
| 114 |
+
review_content = response["choices"][0]["message"]["content"]
|
| 115 |
+
|
| 116 |
+
# Create a basic HTML structure
|
| 117 |
+
html_output = f"""
|
| 118 |
+
<h2>Systematic Review</h2>
|
| 119 |
+
<p>{review_content}</p>
|
| 120 |
+
"""
|
| 121 |
+
|
| 122 |
+
return html_output
|
| 123 |
|
| 124 |
except Exception as e:
|
| 125 |
return f"Error generating systematic review: {str(e)}"
|
|
|
|
| 139 |
|
| 140 |
return saved_paths
|
| 141 |
|
| 142 |
+
# Add CSS styling
|
| 143 |
+
custom_css = """
|
| 144 |
+
<style>
|
| 145 |
+
#generate_button {
|
| 146 |
+
background: linear-gradient(135deg, #4a00e0 0%, #8e2de2 100%); /* Purple gradient */
|
| 147 |
+
color: white;
|
| 148 |
+
font-weight: bold;
|
| 149 |
+
}
|
| 150 |
+
#generate_button:hover {
|
| 151 |
+
background: linear-gradient(135deg, #5b10f1 0%, #9f3ef3 100%); /* Slightly lighter */
|
| 152 |
+
}
|
| 153 |
+
#api_key_button {
|
| 154 |
+
background: linear-gradient(135deg, #68d391 0%, #48bb78 100%); /* Green gradient */
|
| 155 |
+
color: white;
|
| 156 |
+
font-weight: bold;
|
| 157 |
+
margin-top: 27px;
|
| 158 |
+
}
|
| 159 |
+
#api_key_button:hover {
|
| 160 |
+
background: linear-gradient(135deg, #38a169 0%, #68d391 100%); /* Slightly darker green */
|
| 161 |
+
}
|
| 162 |
+
.gradio-container {
|
| 163 |
+
font-family: 'Arial', sans-serif;
|
| 164 |
+
background-color: #f0f4f8;
|
| 165 |
+
}
|
| 166 |
+
</style>
|
| 167 |
+
"""
|
| 168 |
+
|
| 169 |
# Gradio UI Layout
|
| 170 |
+
with gr.Blocks(css=custom_css) as demo:
|
| 171 |
gr.Markdown("# Systematic Review Generator for Research Papers")
|
| 172 |
|
| 173 |
with gr.Accordion("How to Use This App", open=True):
|
| 174 |
+
gr.Markdown("""
|
| 175 |
### Getting Started:
|
| 176 |
1. Enter your OpenAI API key in the field below and click "Set API Key"
|
| 177 |
2. Upload multiple PDF research papers (2 or more recommended)
|
|
|
|
| 196 |
with gr.Row():
|
| 197 |
with gr.Column():
|
| 198 |
pdf_files = gr.File(label="Upload PDF Research Papers", file_count="multiple", type="binary")
|
| 199 |
+
review_question = gr.Textbox(label="Review Question or Topic", value="Please Generate a systematic review of the following papers.")
|
| 200 |
include_tables = gr.Checkbox(label="Include Comparison Tables", value=True)
|
| 201 |
generate_button = gr.Button("Generate Systematic Review", elem_id="generate_button")
|
| 202 |
|
| 203 |
# Output
|
| 204 |
+
review_output = gr.HTML(label="Systematic Review")
|
| 205 |
|
| 206 |
# Button actions
|
| 207 |
api_key_button.click(set_api_key, inputs=[api_key_input], outputs=[api_key_output])
|
|
|
|
| 232 |
outputs=[review_output]
|
| 233 |
)
|
| 234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
# Launch the app
|
| 236 |
if __name__ == "__main__":
|
| 237 |
demo.launch(share=True)
|