Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added environment variable to select different OpenAI models. #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
OPENAI_API_KEY=your_openai_api_key_here
FINANCIAL_DATASETS_API_KEY=your_financial_datasets_api_key_here
OPENAI_MODEL="gpt-4o" # Specify which OpenAI model to use. Examples: gpt-4, gpt-4o, gpt-3.5-turbo-0125 https://openai.com/api/pricing/
9 changes: 8 additions & 1 deletion src/agents/market_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@

from datetime import datetime

llm = ChatOpenAI(model="gpt-4o")
from dotenv import load_dotenv
import os

# Load environment variables from the .env file
load_dotenv()

# Invoke the LLM
llm = ChatOpenAI(model=os.getenv("OPENAI_MODEL"), api_key=os.getenv("OPENAI_API_KEY"))

def market_data_agent(state: AgentState):
"""Responsible for gathering and preprocessing market data"""
Expand Down
8 changes: 7 additions & 1 deletion src/agents/portfolio_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from agents.state import AgentState, show_agent_reasoning

from dotenv import load_dotenv
import os

##### Portfolio Management Agent #####
def portfolio_management_agent(state: AgentState):
Expand Down Expand Up @@ -107,8 +109,12 @@ def portfolio_management_agent(state: AgentState):
"portfolio_stock": portfolio["stock"]
}
)

# Load environment variables from the .env file
load_dotenv()

# Invoke the LLM
llm = ChatOpenAI(model="gpt-4o")
llm = ChatOpenAI(model=os.getenv("OPENAI_MODEL"), api_key=os.getenv("OPENAI_API_KEY"))
result = llm.invoke(prompt)

# Create the portfolio management message
Expand Down