Spaces:
Running
Running
Update posts_categorization.py
Browse files- posts_categorization.py +8 -2
posts_categorization.py
CHANGED
@@ -40,7 +40,10 @@ def summarize_post(text):
|
|
40 |
response = client.chat.completions.create(
|
41 |
model=PRIMARY_SUMMARIZER_MODEL,
|
42 |
response_model=SummaryOutput,
|
43 |
-
messages=messages
|
|
|
|
|
|
|
44 |
temperature=0.3
|
45 |
)
|
46 |
return response.summary
|
@@ -51,7 +54,10 @@ def summarize_post(text):
|
|
51 |
response = client.chat.completions.create(
|
52 |
model=FALLBACK_SUMMARIZER_MODEL,
|
53 |
response_model=SummaryOutput,
|
54 |
-
messages=messages
|
|
|
|
|
|
|
55 |
temperature=0.3 # Keep temperature consistent or adjust as needed for fallback
|
56 |
)
|
57 |
print(f"Summarization successful with fallback model: {FALLBACK_SUMMARIZER_MODEL}")
|
|
|
40 |
response = client.chat.completions.create(
|
41 |
model=PRIMARY_SUMMARIZER_MODEL,
|
42 |
response_model=SummaryOutput,
|
43 |
+
messages=messages=[
|
44 |
+
{"role": "system", "content": "You are a precise summarizer. Only return a JSON object with a 'summary' string."},
|
45 |
+
{"role": "user", "content": prompt}
|
46 |
+
],
|
47 |
temperature=0.3
|
48 |
)
|
49 |
return response.summary
|
|
|
54 |
response = client.chat.completions.create(
|
55 |
model=FALLBACK_SUMMARIZER_MODEL,
|
56 |
response_model=SummaryOutput,
|
57 |
+
messages=messages=[
|
58 |
+
{"role": "system", "content": "You are a precise summarizer. Only return a JSON object with a 'summary' string."},
|
59 |
+
{"role": "user", "content": prompt}
|
60 |
+
],
|
61 |
temperature=0.3 # Keep temperature consistent or adjust as needed for fallback
|
62 |
)
|
63 |
print(f"Summarization successful with fallback model: {FALLBACK_SUMMARIZER_MODEL}")
|