parent
4cecc1eb57
commit
f7039515cf
1 changed files with 45 additions and 0 deletions
@ -0,0 +1,45 @@ |
|||||||
|
from bs4 import BeautifulSoup |
||||||
|
import requests |
||||||
|
import re |
||||||
|
import streamlit as st |
||||||
|
from langchain.chat_models import ChatOllama |
||||||
|
from langchain.callbacks.manager import CallbackManager |
||||||
|
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler |
||||||
|
from langchain.llms import Ollama |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
url = 'https://www.mfn.se/a/enter-fonder/manadsrapport-enter-smabolagsfond-september-2023' |
||||||
|
|
||||||
|
|
||||||
|
# soup = BeautifulSoup(requests.get(url).text, 'lxml') |
||||||
|
|
||||||
|
# report = soup.find('div', class_='full-item') |
||||||
|
# report_title = report.find('div', {'class': 'title'}).text.strip() |
||||||
|
# report_time = report.find('div', {'class': 'publish-date'}).text.strip() |
||||||
|
# report_content = report.find('div', {'class': 'content s-mfn'}).text |
||||||
|
# report_text = re.sub(r'[\n\t]{4,}', '\n', report_content).strip() |
||||||
|
|
||||||
|
|
||||||
|
with open('test.txt') as f: |
||||||
|
report = f.read() |
||||||
|
|
||||||
|
# Använd bara siffror och information i rapporten. |
||||||
|
prompt = f""" |
||||||
|
Nedan följer en månadsrappott publicerad av fonden Enter Småbolagsfond. |
||||||
|
Skriv en mycket kortfattad artikel utifrån månadsrapporten. Börja varje nytt stycke i stil med "Fonden skriver att..." eller "Fonden skriver i sin månadsrapport att...". |
||||||
|
Inled din artikel med "Enter Småbolagsfond skriver i sin månadsrapport att..."\n |
||||||
|
|
||||||
|
{report} |
||||||
|
|
||||||
|
Kortfattad artikel på SVENSKA, max sex meningar lång: |
||||||
|
""".strip() |
||||||
|
|
||||||
|
llm = Ollama( |
||||||
|
model='llama2-uncensored', temperature=0.2, callback_manager=CallbackManager([StreamingStdOutCallbackHandler()])) |
||||||
|
|
||||||
|
prompt = re.sub(r'\s\s\s+', '\n\n', prompt) |
||||||
|
|
||||||
|
|
||||||
|
resp = llm(prompt, kwargs={'system_prompt': "Du är en svensk ekonomijournalist som skriver korta artiklar om fonder."}) |
||||||
Loading…
Reference in new issue