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

Added an IMDb toolkit #14105

Closed
wants to merge 38 commits into from
Closed
Changes from 3 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fe6e99f
added IMDb base tool and movie search tool
jesseyao89 Nov 17, 2023
aa0d1be
Merge pull request #1 from Pyrunix/imdb-base-tool
Pyrunix Nov 17, 2023
734b669
Implemented plot and cast of movie. Did basic manual testing.
STalukder20 Nov 21, 2023
5e8a976
add search_keyword function
ryanWang2018 Nov 26, 2023
5174be0
Linting/formatting changes
STalukder20 Nov 28, 2023
69dac12
Added more IMDb tools
jesseyao89 Nov 28, 2023
c40aae9
Merge pull request #2 from Pyrunix/STalukder-CastPlot
jesseyao89 Nov 28, 2023
ed77afe
Merge branch 'master' into more-tools
jesseyao89 Nov 28, 2023
12610aa
add search_keyword function
ryanWang2018 Nov 28, 2023
7ce38bb
Fixed formatting and linting
jesseyao89 Nov 28, 2023
748fbe0
Updated __init__.py of imdb tools and base tools module, added commen…
jesseyao89 Nov 28, 2023
4d223f7
Linting changes, and try/catch for movie name instead of ID error.
STalukder20 Nov 28, 2023
1342f71
Merge pull request #3 from Pyrunix/STalukder-CastPlot
jesseyao89 Nov 28, 2023
37f5ebd
Merge branch 'master' into more-tools
jesseyao89 Nov 28, 2023
de9dd8e
fixed formatting
jesseyao89 Nov 28, 2023
5c4fd96
Merge pull request #4 from Pyrunix/more-tools
STalukder20 Nov 28, 2023
c28ceed
add find movie by keyword
ryanWang2018 Nov 29, 2023
1b5f44c
add file for imdbtoolkit
ryanWang2018 Nov 29, 2023
9c6b45d
merge changes from master and fix conflict
ryanWang2018 Nov 29, 2023
5a5fff4
implement toolkit for imdb
ryanWang2018 Nov 29, 2023
f393b4c
Merge pull request #5 from Pyrunix/imdb_feature
ryanWang2018 Nov 29, 2023
055c39f
toolkit cleanup
jesseyao89 Nov 30, 2023
dde91e7
added imdb.ipynb
Pyrunix Nov 30, 2023
e66fa6d
Made some changes to IMDb example notebook
jesseyao89 Nov 30, 2023
0532e64
Merge pull request #6 from Pyrunix/doc-notebook
jesseyao89 Nov 30, 2023
03d365a
Made IMDb capitalization consistent
jesseyao89 Dec 1, 2023
54459fc
Added IMDb tools to unit tests
jesseyao89 Dec 1, 2023
9e6bcbc
Added cinemagoer as poetry dependency
jesseyao89 Dec 1, 2023
d61ca1a
Ran linting and formatting
jesseyao89 Dec 1, 2023
1cf708e
Merge pull request #7 from Pyrunix/cleanup
jesseyao89 Dec 1, 2023
6200775
Merge remote-tracking branch 'upstream/master'
jesseyao89 Dec 1, 2023
a81696d
Cleanup after merge
jesseyao89 Dec 1, 2023
1806d6b
Fixed linting error
jesseyao89 Dec 1, 2023
6ae55fe
Merge remote-tracking branch 'upstream/master'
jesseyao89 Dec 4, 2023
a27dc82
Merge remote-tracking branch 'upstream/master'
STalukder20 Dec 4, 2023
21e58ca
Merge remote-tracking branch 'upstream/master'
STalukder20 Dec 5, 2023
b310591
Merge remote-tracking branch 'upstream/master'
STalukder20 Dec 6, 2023
60a37aa
Poetry lock update
STalukder20 Dec 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions libs/langchain/langchain/tools/__init__.py
Original file line number Diff line number Diff line change
@@ -293,6 +293,21 @@ def _import_ifttt() -> Any:

return IFTTTWebhook

def _import_imdb_CastOfMovieTool() -> Any:
from langchain.tools.imdb.cast_of_movie import IMDBCastOfMovie

return IMDBCastOfMovie

def _import_imdb_PlotOfMovieTool() -> Any:
from langchain.tools.imdb.plot_of_movie import IMDBPlotOfMovie

return IMDBPlotOfMovie

def _import_imdb_SearchMovieTool() -> Any:
from langchain.tools.imdb.search_movie import IMDbSearchMovie

return IMDbSearchMovie


def _import_interaction_tool() -> Any:
from langchain.tools.interaction.tool import StdInInquireTool
4 changes: 4 additions & 0 deletions libs/langchain/langchain/tools/imdb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"""Tools for querying IMDb (the Internet Movie Database)."""

from langchain.tools.imdb.cast_of_movie import IMDBCastOfMovie
from langchain.tools.imdb.plot_of_movie import IMDBPlotOfMovie
from langchain.tools.imdb.search_movie import IMDbSearchMovie

__all__ = [
"IMDbSearchMovie",
"IMDBCastOfMovie",
"IMDBPlotOfMovie",
]
2 changes: 1 addition & 1 deletion libs/langchain/langchain/tools/imdb/base.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ class IMDbBaseTool(BaseTool):
client: Any = None #: :meta private:

@root_validator
def validate_environment(cls, values: Dict) -> Dict:
def validate_environment(self, cls, values: Dict) -> Dict:
try:
from imdb import Cinemagoer
except ImportError:
26 changes: 26 additions & 0 deletions libs/langchain/langchain/tools/imdb/cast_of_movie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from typing import Optional

from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.imdb.base import IMDbBaseTool


def people_to_dicts(people):
if not people:
return people
return [{'name': p.get('name'), 'id': p.getID()} for p in people]

class IMDBCastOfMovie(IMDbBaseTool):
"""Tool to find cast of a movie given its name."""

name: str = "CastOfMovie"
description: str = (
"""Use this tool to retrieve a list of cast members for a movie, given
its IMBD movie ID."""
)

def _run(self,
id: str,
run_manager: Optional[CallbackManagerForToolRun] = None) -> str:
res_movie = self.client.get_movie(id)

return people_to_dicts(res_movie['cast'])
21 changes: 21 additions & 0 deletions libs/langchain/langchain/tools/imdb/plot_of_movie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from typing import Optional

from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.imdb.base import IMDbBaseTool


class IMDBPlotOfMovie(IMDbBaseTool):
"""Tool to find plot of a movie given its name."""

name: str = "PlotOfMovie"
description: str = (
"""Use this tool to retrieve a summary of the plot of a movie,
given its IMDB movie ID."""
)

def _run(self,
id: str,
run_manager: Optional[CallbackManagerForToolRun] = None) -> str:
res_movie = self.client.get_movie(id)

return res_movie['plot']
2 changes: 1 addition & 1 deletion libs/langchain/langchain/tools/imdb/search_movie.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Optional
import json
from typing import Optional

from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.imdb.base import IMDbBaseTool