Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,7 +88,7 @@ def build_prompt(query_input, sampled_docs):
|
|
| 88 |
sentiment_word = doc['sentiment'].lower() if doc.get('sentiment') else "unknown"
|
| 89 |
docs_text += f"Tweet {idx+1} (Sentiment: {sentiment_word}): {doc['comment']}\n"
|
| 90 |
|
| 91 |
-
system_message = """You are an
|
| 92 |
Your task:
|
| 93 |
- Summarize both positive and negative aspects, highlighting any trends in user sentiment.
|
| 94 |
- Include an introduction, key insights, and a conclusion, reaching about 300 words.
|
|
@@ -103,11 +103,16 @@ Now produce the final report only, without reiterating these instructions or the
|
|
| 103 |
|
| 104 |
messages = [
|
| 105 |
[
|
| 106 |
-
{
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
]
|
| 110 |
-
|
| 111 |
return messages
|
| 112 |
|
| 113 |
# A helper to extract the assistant's response
|
|
@@ -275,7 +280,7 @@ def main():
|
|
| 275 |
device="cuda" if torch.cuda.is_available() else -1,
|
| 276 |
torch_dtype=torch.bfloat16,
|
| 277 |
)
|
| 278 |
-
result = pipe(prompt, max_new_tokens=256,
|
| 279 |
return result, None
|
| 280 |
except Exception as e:
|
| 281 |
return None, str(e)
|
|
|
|
| 88 |
sentiment_word = doc['sentiment'].lower() if doc.get('sentiment') else "unknown"
|
| 89 |
docs_text += f"Tweet {idx+1} (Sentiment: {sentiment_word}): {doc['comment']}\n"
|
| 90 |
|
| 91 |
+
system_message = """You are an helpful assistant. Read the Tweets with their sentiment (Negative, Neutral, Positive) provided and produce a well-structured report that answers the query question.
|
| 92 |
Your task:
|
| 93 |
- Summarize both positive and negative aspects, highlighting any trends in user sentiment.
|
| 94 |
- Include an introduction, key insights, and a conclusion, reaching about 300 words.
|
|
|
|
| 103 |
|
| 104 |
messages = [
|
| 105 |
[
|
| 106 |
+
{
|
| 107 |
+
"role": "system",
|
| 108 |
+
"content": [{"type": "text", "text": system_message}]
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"role": "user",
|
| 112 |
+
"content": [{"type": "text", "text": user_prompt}]
|
| 113 |
+
}
|
| 114 |
+
]
|
| 115 |
]
|
|
|
|
| 116 |
return messages
|
| 117 |
|
| 118 |
# A helper to extract the assistant's response
|
|
|
|
| 280 |
device="cuda" if torch.cuda.is_available() else -1,
|
| 281 |
torch_dtype=torch.bfloat16,
|
| 282 |
)
|
| 283 |
+
result = pipe(prompt, max_new_tokens=256, return_full_text=False)
|
| 284 |
return result, None
|
| 285 |
except Exception as e:
|
| 286 |
return None, str(e)
|