Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -32,11 +32,26 @@ def fetch_web_content(url):
|
|
32 |
st.error(f"Error fetching URL: {e}")
|
33 |
return ""
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
# summarize the text
|
36 |
def summarize_text(text):
|
|
|
37 |
if not text:
|
38 |
return "no content to summarize"
|
39 |
-
|
40 |
try:
|
41 |
response = openai.chat.completions.create(
|
42 |
model = "gpt-4o-mini",
|
|
|
32 |
st.error(f"Error fetching URL: {e}")
|
33 |
return ""
|
34 |
|
35 |
+
# Function to generate the messages for the OpenAI API request
|
36 |
+
def messages_for(web_content):
|
37 |
+
system_prompt = "You are an assistant that analyzes the contents of a website \
|
38 |
+
and provides a short summary, ignoring text that might be navigation related. \
|
39 |
+
Respond in markdown."
|
40 |
+
|
41 |
+
user_prompt = "The contents of this website are as follows; please provide a short summary of this website in markdown. \
|
42 |
+
If it includes news or announcements, then summarize these too.\n\n"
|
43 |
+
user_prompt += web_content
|
44 |
+
|
45 |
+
return [
|
46 |
+
{"role": "system", "content": system_prompt},
|
47 |
+
{"role": "user", "content": user_prompt}
|
48 |
+
]
|
49 |
+
|
50 |
# summarize the text
|
51 |
def summarize_text(text):
|
52 |
+
|
53 |
if not text:
|
54 |
return "no content to summarize"
|
|
|
55 |
try:
|
56 |
response = openai.chat.completions.create(
|
57 |
model = "gpt-4o-mini",
|