hello
parent
ce0c150eff
commit
f94bdea07a
76
news/main.py
76
news/main.py
|
@ -34,17 +34,18 @@ logging.basicConfig(
|
|||
|
||||
article_repository = ArticleRepository()
|
||||
|
||||
async def send_chat(messages, fmt):
|
||||
return await AsyncClient(host="192.168.69.3:11434").chat(
|
||||
# model="deepseek-r1:1.5b",
|
||||
model="gemma3:12b-it-qat",
|
||||
messages=messages,
|
||||
stream=False,
|
||||
options={
|
||||
'temperature': 0.5,
|
||||
# "num_ctx": 128000
|
||||
},
|
||||
think=False)
|
||||
async def send_chat(model, messages):
|
||||
# return await AsyncClient(host="192.168.69.3:11434").chat(
|
||||
# # model="deepseek-r1:1.5b",
|
||||
# model="gemma3:12b-it-qat",
|
||||
# messages=messages,
|
||||
# stream=False,
|
||||
# options={
|
||||
# 'temperature': 0.5,
|
||||
# # "num_ctx": 128000
|
||||
# },
|
||||
# think=False)
|
||||
return await AsyncClient(host="192.168.69.3:11434").generate(model=model, prompt=messages, stream=False)
|
||||
|
||||
async def send_text_file(channel: discord.abc.Messageable, content: str, message: str = "📄 Full article attached:", filename: str = "article.md") -> None:
|
||||
fp = io.BytesIO(content.encode("utf-8"))
|
||||
|
@ -68,34 +69,37 @@ async def handle_article_url(message: discord.Message, url: str) -> None:
|
|||
# print(paragraphs)
|
||||
# print(processed_graphs)
|
||||
|
||||
messages = [
|
||||
{"role": "system", "content": "You are an expert article-analysis assistant."
|
||||
# "You WILL respond in JSON format."
|
||||
"Your job is to analyse paragraphs in the article and look for provocative, emotionally charged, and loaded language"
|
||||
"You WILL analyse the paragraphs, determine if they are provocative, and if so, output a rating between 1 and 100, 100 being the most provocative."
|
||||
"you WILL NOT output a summary of the article or the paragraphs."
|
||||
"Questions you should ask yourself while reading the paragraph:"
|
||||
"1. What is the literal meaning of the questionable word or phrase?"
|
||||
"2. What is the emotional or social context of the questionable word or phrase?"
|
||||
"3. Does that word or phrase have any connotations, that is, associations that are positive or negative?"
|
||||
"4. What group (sometimes called a “discourse community”) favors one locution over another, and why?"
|
||||
"5. Is the word or phrase “loaded”? How far does it steer us from neutral?"
|
||||
"6. Does the word or phrase help me see, or does it prevent me from seeing? (This is important)"
|
||||
"You will now be provided with the headline of the article then a paragraph from the article."
|
||||
"The headline (title of the page) will be provided as \"Headline\": \"EXAMPLE HEADLINE\"."
|
||||
"The paragraphs will be provided as \"Paragraph (numbered index)\": \"EXAMPLE PARAGRAPH\"."},
|
||||
{"role": "user", "content": f"\"Headline\": \"{title}\""}
|
||||
]
|
||||
messages.extend(processed_graphs)
|
||||
response = await send_chat(messages, "json")
|
||||
print(response)
|
||||
# messages = [
|
||||
# {"role": "system", "content": "You are an expert article-analysis assistant."
|
||||
# # "You WILL respond in JSON format."
|
||||
# "Your job is to analyse paragraphs in the article and look for provocative, emotionally charged, and loaded language"
|
||||
# "You WILL analyse the paragraphs, determine if they are provocative, and if so, output a rating between 1 and 100, 100 being the most provocative."
|
||||
# "you WILL NOT output a summary of the article or the paragraphs."
|
||||
# "Questions you should ask yourself while reading the paragraph:"
|
||||
# "1. What is the literal meaning of the questionable word or phrase?"
|
||||
# "2. What is the emotional or social context of the questionable word or phrase?"
|
||||
# "3. Does that word or phrase have any connotations, that is, associations that are positive or negative?"
|
||||
# "4. What group (sometimes called a “discourse community”) favors one locution over another, and why?"
|
||||
# "5. Is the word or phrase “loaded”? How far does it steer us from neutral?"
|
||||
# "6. Does the word or phrase help me see, or does it prevent me from seeing? (This is important)"
|
||||
# "You will now be provided with the headline of the article then a paragraph from the article."
|
||||
# "The headline (title of the page) will be provided as \"Headline\": \"EXAMPLE HEADLINE\"."
|
||||
# "The paragraphs will be provided as \"Paragraph (numbered index)\": \"EXAMPLE PARAGRAPH\"."},
|
||||
# {"role": "user", "content": f"\"Headline\": \"{title}\""}
|
||||
# ]
|
||||
# messages.extend(processed_graphs)
|
||||
social = await send_chat("social", processed_html)
|
||||
capital = await send_chat("capital", processed_html)
|
||||
facts = await send_chat("facts", processed_html)
|
||||
print(social)
|
||||
print(capital)
|
||||
print(facts)
|
||||
# TODO: parse `html`, summarise, etc.
|
||||
await message.channel.send(f"✅ Article downloaded – {len(processed_html):,} bytes.")
|
||||
await send_text_file(message.channel, processed_html)
|
||||
# await message.channel.send("Sending thinking portion:")
|
||||
# await send_text_file(message.channel, response.message.thinking)
|
||||
await message.channel.send("Sending response portion:")
|
||||
await send_text_file(message.channel, response.message.content)
|
||||
await send_text_file(message.channel, social.response, "Social calculations:")
|
||||
await send_text_file(message.channel, capital.response, "capital calculations:")
|
||||
await send_text_file(message.channel, facts.response, "facts calculations:")
|
||||
except Exception as exc:
|
||||
await message.channel.send("❌ Sorry, an internal error has occurred. Please try again later or contact an administrator.")
|
||||
await message.channel.send(f"```\n{exc}\n```")
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
FROM llama3.2:3b
|
||||
PARAMETER temperature 0.7
|
||||
SYSTEM You are a specialized analysis program designed to determine if articles are pro-capital. Pro-capital text is concerned but not limited to the interests of business, or of the rich and elite. You will respond in JSON format giving a number value between 1 and 10 of how much you think the article is pro-capital (called 'capital), you will also include a field containing context as to your reasoning for this, and what you have concluded from the article (in a field called 'context'). You ARE allowed to answer with "this article doesn't require capital analysis" if the topic is not relevant to capital interests.
|
|
@ -0,0 +1,3 @@
|
|||
FROM llama3.2:3b
|
||||
PARAMETER temperature 0.7
|
||||
SYSTEM You are a specialized analysis program designed to determine if articles are attempting to accurately represent facts. You are not checking if the facts presented in the article are correct, rather you are to determine if an attempt was made to represent multiple sides of the issue. This can range from only presenting the news in the form of events that happened or expert comments (therefore not introducing the writer's opinion into the article), to not using too much emotional language (emotional language can be fine, if for example the article is trying to communicate that one side has commited genocide, it is okay to be emotional over that topic and should probably be encouraged. If the article only presents opinions about genocide, then it is not accurately representing what happened). You will respond in JSON format, giving a numeric value called facts that is a scale of 1 to 10, 10 meaning the article makes best efforts to represent facts, while 1 means that the article mostly presents conjecture or only one potential solution to the presented problem, you will also include a field called 'context' which will detail your reasoning for the rating.
|
|
@ -0,0 +1,3 @@
|
|||
FROM llama3.2:3b
|
||||
PARAMETER temperature 0.7
|
||||
SYSTEM You are a specialized analysis program designed to determine if articles are pro-social. Pro-social text contains topics such as raising concerns about the negative effects on workers, the environment, or on society as a whole (as in the concerns of the 99%, or the proletariat). You will respond in JSON format giving a number value of how much you think the article is pro-social (called 'social') on a scale of 1-10, you will also include a field containing context as to your reasoning for this, and what you have concluded from the article (in a field called 'context'). You ARE allowed to answer with "this article doesn't require social analysis" if the topic is not relevant to social interests.
|
|
@ -0,0 +1,10 @@
|
|||
#!bash
|
||||
rsync -a models/ brett@index:~/models
|
||||
|
||||
for f in models/*.modelfile; do
|
||||
echo "Updating model: $f"
|
||||
filename="${f##*/}"
|
||||
basename="${filename%.*}"
|
||||
echo "Model name: $basename from $filename"
|
||||
ssh brett@index "ollama rm $basename && ollama create $basename -f \~/$f"
|
||||
done
|
Loading…
Reference in New Issue