Skip to content

Commit

Permalink
fix(yahoo-finance): Revert method input changes and fix enum error
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelchristi committed Dec 25, 2024
1 parent 7525811 commit 20ec697
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/backend/base/langflow/components/tools/yahoo_finance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
from enum import Enum

import yfinance as yf
from langchain.tools import StructuredTool
from langchain_core.tools import ToolException
from loguru import logger
from pydantic import BaseModel, Field

from langflow.custom import Component
from langflow.field_typing import Tool
from langflow.inputs import DropdownInput, IntInput, MessageTextInput
from langflow.schema import Data
from langflow.io import Output
from langflow.schema import Data
from langflow.schema.message import Message


Expand Down Expand Up @@ -70,7 +68,6 @@ class YfinanceToolComponent(Component):
info="The type of data to retrieve.",
options=list(YahooFinanceMethod),
value="get_news",
tool_mode=True,
),
IntInput(
name="num_news",
Expand All @@ -91,7 +88,7 @@ def run_model(self) -> list[Data]:
def fetch_content(self) -> list[Data]:
return self._yahoo_finance_tool(
self.symbol,
self.method,
YahooFinanceMethod(self.method),
self.num_news,
)

Expand Down Expand Up @@ -122,7 +119,10 @@ def _yahoo_finance_tool(
result = pprint.pformat(result)

if method == YahooFinanceMethod.GET_NEWS:
data_list = [Data(text=f"{article['title']}: {article['link']}", data=article) for article in ast.literal_eval(result)]
data_list = [
Data(text=f"{article['title']}: {article['link']}", data=article)
for article in ast.literal_eval(result)
]
else:
data_list = [Data(text=result, data={"result": result})]

Expand Down

0 comments on commit 20ec697

Please sign in to comment.