gnosis / prediction-market-agent

GNU Lesser General Public License v3.0
22 stars 4 forks source link

Use stored tavily results as a cache #388

Closed evangriffiths closed 3 days ago

evangriffiths commented 1 month ago

Follow-on from https://github.com/gnosis/prediction-market-agent-tooling/pull/337

Motivation is to save tavily credits.

instead of tavily_search should take some extra arg (or maybe fold intit args of TavilyStorage) to configure when how to search saved results for a cache hit, otherwise do a new search.

evangriffiths commented 3 weeks ago

Depends on https://github.com/gnosis/prediction-market-agent/pull/381

kongzii commented 3 weeks ago

So far, it doesn't look like there is much to get from cache, but agents were bugging out because of insufficient database instance, so I'll check again at the end of the week:

Screenshot by Dropbox Capture

kongzii commented 2 weeks ago

Based on this SQL

select sum(count) from (
    SELECT 
        COUNT(DISTINCT agent_id) AS unique_agent_count,
        query,
        count(*) as count
    FROM tavily_response
    group by query
    having count(*) > 1
) as X;

Out of 1317 records, 151 could come from the cache, that's 11%.

That's not bad, but I expected more.

We have 18k credits left this month, and it's only a week to the end; I'd revert the agents to be executed more often, and let's see what it does.

kongzii commented 3 days ago

Added to PMAT in https://github.com/gnosis/prediction-market-agent-tooling/pull/380/files and because we already provide TavilyStorage everywhere, it will come from cache if possible.