A new package that extracts and structures key business and financial insights from news articles or reports. The package takes unstructured text input, such as news headlines or summaries, and uses llmatch-messages to parse and extract specific details like company names, financial figures, market impacts, and strategic moves. It returns a structured output that includes the key entities involved, the nature of the announcement, potential market implications, and any notable figures or metrics mentioned.
Installation can be done via pip:
pip install fin_insight_extractExtract financial and business insights from unstructured text:
from fin_insight_extract import fin_insight_extract
user_input = "The company has announced a 20% increase in revenue for the quarter"
response = fin_insight_extract(user_input=user_input)
print(response)user_input: The unstructured text to process. (str)llm: A LangChain LLM instance to use. If not provided, the defaultChatLLM7will be used. (Optional[BaseChatModel])api_key: The API key for LLM7. If not provided, the defaultChatLLM7will be used. If provided, it will also be used for the defaultChatLLM7. (Optional[str])
You can safely pass your own LLM instance (based on https://docs(langchain.io)) if you want to use another LLM. For example, to use OpenAI:
from langchain_openai import ChatOpenAI
from fin_insight_extract import fin_insight_extract
llm = ChatOpenAI()
response = fin_insight_extract(user_input="The company has announced a 20% increase in revenue for the quarter", llm=llm)
print(response)Similarly, you can use Anthropics:
from langchain_anthropic import ChatAnthropic
from fin_insight_extract import fin_insight_extract
llm = ChatAnthropic()
response = fin_insight_extract(user_input="The company has announced a 20% increase in revenue for the quarter", llm=llm)
print(response)or Google:
from langchain_google_genai import ChatGoogleGenerativeAI
from fin_insight_extract import fin_insight_extract
llm = ChatGoogleGenerativeAI()
response = fin_insight_extract(user_input="The company has announced a 20% increase in revenue for the quarter", llm=llm)
print(response)The default rate limits for LLM7 free tier are sufficient for most use cases of this package. If you need higher rate limits, you can pass your own API key via environment variable LLM7_API_KEY or directly:
from fin_insight_extract import fin_insight_extract
response = fin_insight_extract(user_input="The company has announced a 20% increase in revenue for the quarter", api_key="your_api_key")
print(response)Get a free API key at https://token.llm7.io/
Report issues at: https://github.com/chigwell/fin-insight-extract
authored by Eugene Evstafev (hi@eugevstfev.plus)