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

Add Google Finance Integration #7289

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

joshuajyu
Copy link

@joshuajyu joshuajyu commented Nov 28, 2024

This PR ports the Google Finance Tool from LangChain Python to LangChainJS. Google Finance Tool allows your agent to utilize the Google Finance API to retrieve financial data, such as stock prices, market trends, exchange rates, and other investment-related information from Google Finance. We've added/modified the following files:

  • docs/core_docs/docs/integrations/tools/google_finance.mdx: Site docs
  • examples/src/tools/google_finance.ts: Example usage
  • libs/langchain-community/langchain.config.js: Added entrypoint for our tool
  • libs/langchain-community/src/tools/google_finance.ts: The Google Finance Tool
  • libs/langchain-community/src/tools/tests/google_finance.int.test.ts: Integration tests for the tool

Example Usage:

import { GoogleFinanceAPI } from "@langchain/community/tools/google_finance";
import { OpenAI } from "@langchain/openai";
import { initializeAgentExecutorWithOptions } from "langchain/agents";

export async function run() {
  const model = new OpenAI({
    temperature: 0,
    apiKey: process.env.OPENAI_API_KEY,
  });

  const tools = [new GoogleFinanceAPI()];

  const financeAgent = await initializeAgentExecutorWithOptions(tools, model, {
    agentType: "zero-shot-react-description",
    verbose: true,
  });

  const result = await financeAgent.invoke({
    input: "What is the price of GOOG:NASDAQ?",
  });

  console.log(result.output);
}

Sample Output:

{
  "markets": { … },
  "summary": {
    "title": "Alphabet Inc Class A",
    "stock": "GOOGL",
    "exchange": "NASDAQ",
    "price": "$89.23",
    "extracted_price": 89.23,
    "currency": "$",
    "price_movement": {
      "percentage": 1.6750242,
      "value": 1.4700012,
      "movement": "Up"
     }, … },
  "graph": [ … ],
  "knowledge_graph": { … },
  "news_results": [ … ],
  "financials": [ … ],
  "discover_more": [ … ]
} 

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Nov 28, 2024
Copy link

vercel bot commented Nov 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Dec 4, 2024 6:08am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Dec 4, 2024 6:08am

@dosubot dosubot bot added the auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features label Nov 28, 2024
@joshuajyu joshuajyu changed the title Added Google Finance Tool Added Google Finance Integration Nov 28, 2024
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Dec 4, 2024
@joshuajyu
Copy link
Author

joshuajyu commented Dec 16, 2024

Hey @jacoblee93 , sorry to bother you but do you think you could re-review this when you get a chance? Thanks in advance!

@joshuajyu joshuajyu changed the title Added Google Finance Integration Add Google Finance Integration Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants