Skip to content

Instantly share code, notes, and snippets.

@davidmezzetti
Created August 11, 2024 12:01
Show Gist options
  • Save davidmezzetti/221182da1dc5839f737dbcf9a9ba5f3a to your computer and use it in GitHub Desktop.
Save davidmezzetti/221182da1dc5839f737dbcf9a9ba5f3a to your computer and use it in GitHub Desktop.
# 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