Update app.py
Browse files
app.py
CHANGED
|
@@ -112,8 +112,9 @@ class DocumentRAG:
|
|
| 112 |
except Exception as e:
|
| 113 |
return f"Error processing documents: {str(e)}"
|
| 114 |
|
|
|
|
| 115 |
def generate_summary(self, text, language):
|
| 116 |
-
"""Generate a summary of the provided text in the specified language."""
|
| 117 |
if not self.api_key:
|
| 118 |
return "API Key not set. Please set it in the environment variables."
|
| 119 |
try:
|
|
@@ -121,12 +122,22 @@ class DocumentRAG:
|
|
| 121 |
response = client.chat.completions.create(
|
| 122 |
model="gpt-4",
|
| 123 |
messages=[
|
| 124 |
-
{"role": "system", "content": f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
{"role": "user", "content": text[:4000]}
|
| 126 |
],
|
| 127 |
temperature=0.3
|
| 128 |
-
|
| 129 |
-
|
| 130 |
except Exception as e:
|
| 131 |
return f"Error generating summary: {str(e)}"
|
| 132 |
|
|
|
|
| 112 |
except Exception as e:
|
| 113 |
return f"Error processing documents: {str(e)}"
|
| 114 |
|
| 115 |
+
|
| 116 |
def generate_summary(self, text, language):
|
| 117 |
+
"""Generate a summary of the provided text focusing on specific sections in the specified language."""
|
| 118 |
if not self.api_key:
|
| 119 |
return "API Key not set. Please set it in the environment variables."
|
| 120 |
try:
|
|
|
|
| 122 |
response = client.chat.completions.create(
|
| 123 |
model="gpt-4",
|
| 124 |
messages=[
|
| 125 |
+
{"role": "system", "content": f"""
|
| 126 |
+
Summarize the following document focusing mainly using the following sections:
|
| 127 |
+
1. Abstract
|
| 128 |
+
2. In the introduction section, focus specifically on the portion where the key contributions of the research paper are highlighted.
|
| 129 |
+
3. Conclusion
|
| 130 |
+
4. Limitations
|
| 131 |
+
5. Future Work
|
| 132 |
+
|
| 133 |
+
Ensure the summary is concise, logically ordered, and suitable for {language}.
|
| 134 |
+
Provide 5-7 key points for discussion in a structured format."""
|
| 135 |
+
},
|
| 136 |
{"role": "user", "content": text[:4000]}
|
| 137 |
],
|
| 138 |
temperature=0.3
|
| 139 |
+
)
|
| 140 |
+
return response.choices[0].message.content
|
| 141 |
except Exception as e:
|
| 142 |
return f"Error generating summary: {str(e)}"
|
| 143 |
|