Created
August 11, 2024 12:01
-
-
Save davidmezzetti/221182da1dc5839f737dbcf9a9ba5f3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install yfinance txtai | |
import yfinance as yf | |
import txtai | |
def prompt(ticker): | |
return f""" | |
Answer the following question using only the context below. Only include information | |
specifically discussed. | |
question: Analyze the following information on the stock and give a recommendation | |
context: {yf.Ticker(ticker).info} | |
""" | |
# Create LLM and run prompt for stock ticker | |
llm = txtai.LLM("hugging-quants/Meta-Llama-3.1-8B-Instruct-AWQ-INT4") | |
llm([{"content": prompt("AAPL"), "role": "user"}], maxlength=4096) | |
# Overall, Apple's strong financial performance, growing earnings, positive analyst | |
# sentiment, and strong cash position make it an attractive investment opportunity. | |
# However, as with any investment, it's essential to conduct thorough research and | |
# consider your individual financial goals and risk tolerance before making a decision. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment