Spaces:
Running
Running
Commit
·
3fee7c6
1
Parent(s):
ac886d3
corrected the type hints for StockAnalyst.get_stock_analyses method
Browse files
src/stock_analysis_agent.py
CHANGED
|
@@ -5,7 +5,7 @@ from IPython.display import Image, display
|
|
| 5 |
import json
|
| 6 |
from langgraph.graph import StateGraph, START # , END
|
| 7 |
from langchain_openai import ChatOpenAI
|
| 8 |
-
from langchain_core.messages import SystemMessage
|
| 9 |
from langchain_core.tools import tool
|
| 10 |
from langgraph.prebuilt import ToolNode, tools_condition
|
| 11 |
from langgraph.graph.message import add_messages
|
|
@@ -199,7 +199,7 @@ class StockAnalyst():
|
|
| 199 |
def get_stock_analyses(
|
| 200 |
self,
|
| 201 |
ticker
|
| 202 |
-
) -> List[
|
| 203 |
"""
|
| 204 |
Retrieves a list of stock analyses based on a given ticker symbol.
|
| 205 |
This function interacts with the state graph to stream events related
|
|
@@ -210,7 +210,7 @@ class StockAnalyst():
|
|
| 210 |
ticker : str
|
| 211 |
The stock symbol (ticker) of the company to get suggestions for.
|
| 212 |
Returns:
|
| 213 |
-
List[
|
| 214 |
"""
|
| 215 |
|
| 216 |
events = self.graph.stream(
|
|
@@ -220,6 +220,7 @@ class StockAnalyst():
|
|
| 220 |
},
|
| 221 |
stream_mode='values'
|
| 222 |
)
|
|
|
|
| 223 |
messages = []
|
| 224 |
for event in events:
|
| 225 |
if 'messages' in event:
|
|
|
|
| 5 |
import json
|
| 6 |
from langgraph.graph import StateGraph, START # , END
|
| 7 |
from langchain_openai import ChatOpenAI
|
| 8 |
+
from langchain_core.messages import SystemMessage, AIMessage, HumanMessage, ToolMessage
|
| 9 |
from langchain_core.tools import tool
|
| 10 |
from langgraph.prebuilt import ToolNode, tools_condition
|
| 11 |
from langgraph.graph.message import add_messages
|
|
|
|
| 199 |
def get_stock_analyses(
|
| 200 |
self,
|
| 201 |
ticker
|
| 202 |
+
) -> List[Union[HumanMessage, AIMessage, ToolMessage]]:
|
| 203 |
"""
|
| 204 |
Retrieves a list of stock analyses based on a given ticker symbol.
|
| 205 |
This function interacts with the state graph to stream events related
|
|
|
|
| 210 |
ticker : str
|
| 211 |
The stock symbol (ticker) of the company to get suggestions for.
|
| 212 |
Returns:
|
| 213 |
+
List[Union[HumanMessage, AIMessage, ToolMessage]]: A list of messages of various types.
|
| 214 |
"""
|
| 215 |
|
| 216 |
events = self.graph.stream(
|
|
|
|
| 220 |
},
|
| 221 |
stream_mode='values'
|
| 222 |
)
|
| 223 |
+
# run the events and collect the current (last emitted) messages in a list
|
| 224 |
messages = []
|
| 225 |
for event in events:
|
| 226 |
if 'messages' in event:
|