python

[GPT][INVESTORGPT] Search Tool

으누아빠 2024. 5. 20. 20:34
반응형

DuckDuckGoSearch를 이용하여 해당 search에서 데이터를 가져와 답변하도록 한다.

 

 

from typing import Type
from langchain.chat_models import ChatOpenAI
from langchain.tools import BaseTool
from pydantic import BaseModel,Field
from langchain.agents import initialize_agent, AgentType
from langchain.utilities import DuckDuckGoSearchAPIWrapper

llm = ChatOpenAI(
    temperature=0.1,
)

class StockMarketSymbolSearchToolArgsSchema(BaseModel):
    query: str = Field(description="The query you will search for.Example query: Stock Market Symbol for Apple Company")

class StockMarketSymbolSearchTool(BaseTool):
    name = "StockMarketSymbolSearchTool"
    description = """
    Use this tool to find the stock market symbol for a company.
    It takes a query as an argument.
    Example query: Stock Market Symbol for Apple Company
    """

    args_schem: Type[StockMarketSymbolSearchToolArgsSchema] = StockMarketSymbolSearchToolArgsSchema

    def _run(self, query):
        ddg = DuckDuckGoSearchAPIWrapper()
        return ddg.run(query)

agent = initialize_agent(
    llm=llm,
    verbose=True,
    agent=AgentType.OPENAI_FUNCTIONS,
    handle_parsing_erros=True,
    tools=[
        StockMarketSymbolSearchTool(),
    ],
)

prompt = "Give me information on Cloudflare's stock and help me analyze if it's a potential good investment. Also tell me what symbol does the stock have."

agent.invoke(prompt)
 

 

[결과]

> Entering new AgentExecutor chain... Invoking: `StockMarketSymbolSearchTool` with `Cloudflare` Read the latest posts from Cloudflare's official blog, covering topics such as security, DNS, email, AI, developer tools, and more. Learn about Cloudflare's features, innovations, acquisitions, and events from the source. Following its initial announcement in September 2022, Cloudflare Calls is now in open beta and available in your Cloudflare Dashboard.Cloudflare Calls lets developers build real-time audio/video apps using WebRTC, and it abstracts away the complexity by turning the Cloudflare network into a singular SFU.In this post, we dig into how we make this possible. Cloudflare's Year in Review revealed that in 2023 alone, there was a 25% increase in global traffic, with no signs of slowing. This growth underscores the dependency on Internet services to facilitate and underpin vital systems and tasks such as supporting global digital economies, enabling the operations of healthcare networks, maintaining ... Press Releases 2024. Press Releases. 2024. US Department of Treasury, Pacific Northwest National Laboratory, and Cloudflare Partner to Share Early Warning Threat Intelligence for Financial Institutions. May 09, 2024. Cloudflare Announces Unified Risk Posture to Provide Comprehensive and Continuous Risk Management at Scale—for Free. May 07, 2024. Finally, because Cloudflare also operates a CDN, websites that are already on Cloudflare will be given a "hot-path," and will load faster. We at Cloudflare are always striving to bring more privacy options to the open Internet, and we are excited to provide more private and secure browsing to Edge users.The stock market symbol for Cloudflare is NET. As for analyzing if Cloudflare is a potential good investment, it's important to consider various factors such as the company's financial performance, growth potential, competitive landscape, and market trends. Here are some points to consider: 1. **Financial Performance**: Look at Cloudflare's revenue growth, profitability, and cash flow. Analyze their quarterly and annual financial reports to understand their financial health. 2. **Growth Potential**: Evaluate Cloudflare's market position, product offerings, and expansion plans. Consider if they are in a growing industry and have the potential for future growth. 3. **Competitive Landscape**: Assess Cloudflare's competitors and how they differentiate themselves in the market. Look at their market share and competitive advantages. 4. **Market Trends**: Consider industry trends, technological advancements, and regulatory changes that could impact Cloudflare's business. 5. **Risk Factors**: Identify any potential risks that could affect Cloudflare's stock performance, such as cybersecurity threats, regulatory challenges, or economic downturns. It's recommended to consult with a financial advisor or do further research to make an informed decision on whether Cloudflare is a good investment for you. > Finished chain.

 

{'input': "Give me information on Cloudflare's stock and help me analyze if it's a potential good investment. Also tell me what symbol does the stock have.", 'output': "The stock market symbol for Cloudflare is NET. \n\nAs for analyzing if Cloudflare is a potential good investment, it's important to consider various factors such as the company's financial performance, growth potential, competitive landscape, and market trends. Here are some points to consider:\n\n1. **Financial Performance**: Look at Cloudflare's revenue growth, profitability, and cash flow. Analyze their quarterly and annual financial reports to understand their financial health.\n\n2. **Growth Potential**: Evaluate Cloudflare's market position, product offerings, and expansion plans. Consider if they are in a growing industry and have the potential for future growth.\n\n3. **Competitive Landscape**: Assess Cloudflare's competitors and how they differentiate themselves in the market. Look at their market share and competitive advantages.\n\n4. **Market Trends**: Consider industry trends, technological advancements, and regulatory changes that could impact Cloudflare's business.\n\n5. **Risk Factors**: Identify any potential risks that could affect Cloudflare's stock performance, such as cybersecurity threats, regulatory challenges, or economic downturns.\n\nIt's recommended to consult with a financial advisor or do further research to make an informed decision on whether Cloudflare is a good investment for you."}

'python' 카테고리의 다른 글

[GPT][INVESTORGPT] OpenAI Functions Agent  (0) 2024.05.20
[GPT][INVESTORGPT] Zero-shot ReAct Agent  (0) 2024.05.20
[GPT][INVESTORGPT] Agent  (0) 2024.05.20
[GPT][MEETINGGPT] 최종 예제  (0) 2024.05.14
[GPT][MEETINGGPT] Refine Chain  (0) 2024.05.14