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

Improve performance and precision on movies AI #177

Merged
merged 1 commit into from
Oct 2, 2024
Merged

Conversation

fjsj
Copy link
Member

@fjsj fjsj commented Oct 2, 2024

@fjsj fjsj requested a review from pamella October 2, 2024 20:40
@@ -180,6 +180,7 @@
# Example specific settings:

WEATHER_API_KEY = os.getenv("WEATHER_API_KEY") # get for free at https://www.weatherapi.com/
JINA_API_KEY = os.getenv("JINA_API_KEY") # get for free at https://jina.ai/
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With API key we get larger limits. It's free.

)
name = "IMDb Scraper"
model = "gpt-4o-mini"
structured_output = IMDbMovie
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

structured_output is slower, and not necessary here.

)
name = "IMDb Scraper"
model = "gpt-4o-mini"
structured_output = IMDbMovie
tool_max_concurrency = 4
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With RateLimitedBraveSearch, we can run tools concurrently and get faster responses. Thanks to this, we can have responses overall from 5 to 30 seconds.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

"Authorization": "Bearer " + settings.JINA_API_KEY,
},
timeout=20,
).text[:30000]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more text doesn't affect performance.

"Help the user find movies to watch and manage their movie backlogs. "
"Use the provided functions to answer questions and run operations.\n"
"Use the provided functions to answer queries and run operations.\n"
"Use the search function to find movie recommendations based on user's query.\n"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to add this line to force search. In some cases it was hallucinating URLs. For more popular movies, it gets them right, though.

Copy link
Collaborator

@pamella pamella Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was hallucinating URLs.

I noticed that too when I asked a similar thing for the tour guide example.

IMDbScraper().as_tool(
description="IMDb Scraper to get the IMDb data a given movie. "
"Given a movie name (in English), "
"finds the movie URL, rating, and scrapes the IMDb page (as Markdown)."
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better description to the IMDbScraper tool helps the AI to call it more.

"""Add a movie to user's backlog. Must pass the movie_name, imdb_url, and imdb_rating."""
"""
Add a movie to user's backlog. Must pass the movie_name, imdb_url, and imdb_rating.
Set imdb_rating to 0.0 if not available.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Facilitates adding not launched movies.

Copy link
Collaborator

@pamella pamella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@fjsj fjsj merged commit 26d20d5 into main Oct 2, 2024
18 checks passed
@fjsj fjsj deleted the fix/improve-movie-perf branch October 2, 2024 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants