Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,7 +74,7 @@ def _ai_should_extract_painpoint(client: Mistral, title: str, selftext: str) ->
|
|
| 74 |
)
|
| 75 |
|
| 76 |
resp = client.chat.parse(
|
| 77 |
-
model="
|
| 78 |
messages=[
|
| 79 |
{"role": "system", "content": content},
|
| 80 |
{"role": "user", "content": user_text},
|
|
@@ -101,14 +101,14 @@ def _ai_generate_title_summary(client: Mistral, title: str, selftext: str) -> Pa
|
|
| 101 |
)
|
| 102 |
|
| 103 |
resp = client.chat.parse(
|
| 104 |
-
model="
|
| 105 |
messages=[
|
| 106 |
{"role": "system", "content": content},
|
| 107 |
{"role": "user", "content": user_text},
|
| 108 |
],
|
| 109 |
response_format=PainPointGenerated,
|
| 110 |
temperature=0,
|
| 111 |
-
max_tokens=
|
| 112 |
)
|
| 113 |
|
| 114 |
return resp.choices[0].message.parsed # type: ignore[return-value, attr-defined]
|
|
@@ -124,7 +124,6 @@ def scan_mistralai_pain_points(limit: int = 50, min_score: int = 0) -> List[Pain
|
|
| 124 |
- limit: Maximum posts to scan (<=100)
|
| 125 |
- min_score: Minimum Reddit score to include
|
| 126 |
|
| 127 |
-
Requires MISTRAL_API_KEY in environment.
|
| 128 |
"""
|
| 129 |
raw_posts = _fetch_subreddit_new("MistralAI", max(1, min(limit, 100)))
|
| 130 |
client = _get_mistral_client()
|
|
@@ -140,6 +139,7 @@ def scan_mistralai_pain_points(limit: int = 50, min_score: int = 0) -> List[Pain
|
|
| 140 |
|
| 141 |
try:
|
| 142 |
should = _ai_should_extract_painpoint(client, title, selftext)
|
|
|
|
| 143 |
except Exception:
|
| 144 |
# On AI failure, skip the post to avoid false positives
|
| 145 |
continue
|
|
@@ -155,6 +155,8 @@ def scan_mistralai_pain_points(limit: int = 50, min_score: int = 0) -> List[Pain
|
|
| 155 |
# If generation fails, fall back to minimal safe defaults
|
| 156 |
ai_title = title
|
| 157 |
ai_summary = (selftext or title)[:240]
|
|
|
|
|
|
|
| 158 |
|
| 159 |
permalink = post.get("permalink") or ""
|
| 160 |
full_url = f"https://www.reddit.com{permalink}" if permalink else post.get("url_overridden_by_dest") or post.get("url") or ""
|
|
|
|
| 74 |
)
|
| 75 |
|
| 76 |
resp = client.chat.parse(
|
| 77 |
+
model="mistral-medium-2508",
|
| 78 |
messages=[
|
| 79 |
{"role": "system", "content": content},
|
| 80 |
{"role": "user", "content": user_text},
|
|
|
|
| 101 |
)
|
| 102 |
|
| 103 |
resp = client.chat.parse(
|
| 104 |
+
model="mistral-medium-2508",
|
| 105 |
messages=[
|
| 106 |
{"role": "system", "content": content},
|
| 107 |
{"role": "user", "content": user_text},
|
| 108 |
],
|
| 109 |
response_format=PainPointGenerated,
|
| 110 |
temperature=0,
|
| 111 |
+
max_tokens=300,
|
| 112 |
)
|
| 113 |
|
| 114 |
return resp.choices[0].message.parsed # type: ignore[return-value, attr-defined]
|
|
|
|
| 124 |
- limit: Maximum posts to scan (<=100)
|
| 125 |
- min_score: Minimum Reddit score to include
|
| 126 |
|
|
|
|
| 127 |
"""
|
| 128 |
raw_posts = _fetch_subreddit_new("MistralAI", max(1, min(limit, 100)))
|
| 129 |
client = _get_mistral_client()
|
|
|
|
| 139 |
|
| 140 |
try:
|
| 141 |
should = _ai_should_extract_painpoint(client, title, selftext)
|
| 142 |
+
print("SHOULD ? ", should)
|
| 143 |
except Exception:
|
| 144 |
# On AI failure, skip the post to avoid false positives
|
| 145 |
continue
|
|
|
|
| 155 |
# If generation fails, fall back to minimal safe defaults
|
| 156 |
ai_title = title
|
| 157 |
ai_summary = (selftext or title)[:240]
|
| 158 |
+
print("title : ",ai_title)
|
| 159 |
+
print("ai_summary : ",ai_summary)
|
| 160 |
|
| 161 |
permalink = post.get("permalink") or ""
|
| 162 |
full_url = f"https://www.reddit.com{permalink}" if permalink else post.get("url_overridden_by_dest") or post.get("url") or ""
|