T-K-O-H commited on
Commit
625c56a
·
1 Parent(s): 42a6ce1
Files changed (5) hide show
  1. AI_Stock_Agent +1 -0
  2. git_push.bat +5 -0
  3. setup_git.bat +17 -0
  4. setup_remote.bat +3 -0
  5. test_agent.py +29 -0
AI_Stock_Agent ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit 218f0b86aec6c4c7c2dfdbe9baae7ae9b5c2e251
git_push.bat ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ @echo off
2
+ git remote add origin https://huggingface.co/spaces/Shipmaster1/AI_Stock_Agent
3
+ git add .
4
+ git commit -m "Update .gitignore and add all necessary files for Hugging Face Space"
5
+ git push origin main
setup_git.bat ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+ git add app.py
3
+ git add agent_graph.py
4
+ git add tools.py
5
+ git add README.md
6
+ git add Dockerfile
7
+ git add requirements.txt
8
+ git add chainlit.md
9
+ git add .gitignore
10
+ git add .chainlit/
11
+ git commit -m "Initial commit"
12
+ git branch -M main
13
+ git remote add origin https://huggingface.co/spaces/Shipmaster1/Agent_Langgraph
14
+ git remote add upstream git@github.com:T-K-O-H/Agent_Langgraph.git
15
+ git pull origin main --allow-unrelated-histories
16
+ git push -u origin main
17
+ git push -u upstream main
setup_remote.bat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ @echo off
2
+ git remote add origin https://huggingface.co/spaces/Shipmaster1/AI_Stock_Agent
3
+ git remote -v
test_agent.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.chat_models import ChatOpenAI
2
+ from langchain.agents import initialize_agent, Tool, AgentType
3
+ from tools import get_price, buying_power_tool
4
+
5
+ # Make sure OpenAI key is set in your environment
6
+ import os
7
+ os.environ["OPENAI_API_KEY"] = "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"
8
+
9
+ # Define tools
10
+ tools = [
11
+ Tool(
12
+ name="GetStockPrice",
13
+ func=get_price,
14
+ description="Get the current price of a stock by its ticker symbol, e.g., 'AAPL'"
15
+ ),
16
+ Tool(
17
+ name="BuyingPowerCalculator",
18
+ func=lambda q: buying_power_tool(q.split(',')[0], float(q.split(',')[1])),
19
+ description="Calculate how many shares you can buy. Input format: 'AAPL,5000'"
20
+ )
21
+ ]
22
+
23
+ # Create agent
24
+ llm = ChatOpenAI(model="gpt-4", temperature=0)
25
+ agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
26
+
27
+ # Run a test
28
+ response = agent.run("How much is AAPL?")
29
+ print(response)