r/AI_Agents • • 4h ago

Discussion Need Help With My First Python AI Agentic Project

Hey Guys I'm a beginner at this and recently been working on a Project. The name of the project is "Geo-Wizard". As I like geography.

What it does is :
-> It will be given a Json file containing a list of any number of countries & their continents.

-> It will return a Json file containing a list of all of those countries with their parameters.
Exact Parameters are -

  1. Language spoken
  2. Widely followed religion
  3. Capital
  4. One thing country known for
  5. One thing country invented
  6. HDI
  7. Currency
  8. Type of Government in the country.

Current Architecture :

I am using Tavily & Grok
Tavily: for searching and getting the data
Grok: for parsing the data and making a clean Json file

I am doing this because i do not have any subscription & i wanna cut on number of tokens that's why i'm using these 2.

Tavily provides 1000/Month

Problem : I cannot get the required data for all these parameters with tavily. I've tried a couple of things & I really need help.

There's this website called countriesworld which provides data for like 5 of these categories.

Here's a List of things I tried :

  1. Tavily Search Task: I tried meddling with include domains, domain prefer mode and other things but the search task isn't doing the job it only populate the result with most popular keywords and don't work.
  2. Tavily Research Task: I tried token cutting but doesn't work for Research task.
  3. Tavily Extract Task: I thought of extracting the countriesworld page that would give me 5 of those categories and then i will just use search task to get the rest & boom shit will be done. But i was wrong Tavily search task picks the popular out of those 3 and populate the results with them.

I currently have 2 json files one will be list of countries.
other is my config file where i have mentioned some rules.

Is there any way i can carry forward with my project i do not wanna take a subscription or want unlimited tokens through Omni route.

Any help is appreciated

3 Upvotes

8 comments sorted by

1

u/MobileXapps 4h ago

Search is the wrong tool for most of these fields. Language, capital, currency and region come from the REST Countries API in one call, free and with no key. HDI is a yearly table in UNDP's Human Development Report that you can download as CSV. Government type and main religion are on Wikidata, and one SPARQL query gets them for every country.

That leaves only 'known for' and 'invented', which are opinions anyway, so that's the one place to use the model. Give it the country name and ask for one short answer each. You'll burn far fewer tokens and Tavily credits, and the facts won't change between runs.

3

u/Rel_R 3h ago

i know a site called countries world it has all the fields except for Religion, Known for, invented
and i can do the things you suggested for these 3 but the thing is i want to automate that too like suppose i wanna add a category like population or something i will then have to figure out what tool would be best bet for this category.
& If i'm doing that for every category then what's the point of AI Agent

Do you know of any other way like I really appreciated your response and would surely use SPARQL for better query processing for each country

1

u/Far_Mood_487 3h ago

The agent can choose where to look when you add a field, then extract a candidate value. Your Python loop handles fetching, merging and checking it. For a new population field, try the proposed source and extraction plan on a few different countries before reusing it, and still check each returned value against its source. A source URL alone isn't verification.

With your setup, search for each missing field separately, then pass the chosen URLs to Tavily Extract. If you give Extract a `query`, it returns chunks ranked for that query, which doesn't guarantee every field in a combined request shows up: https://docs.tavily.com/documentation/api-reference/endpoint/extract

Have the parser return `value`, `source_url` and `year` where relevant, or `null` when the evidence isn't there. Decide what counts as “widely followed religion” or an invention first; those don't always have one undisputed answer. Cap search/extraction attempts per field so one difficult answer doesn't eat your allowance.

1

u/MobileXapps 36m ago

Then make Wikidata the one generic source. Almost every field is a property with an id: population is P1082, capital P36, currency P38, official language P37, form of government P122, HDI P1081, religion P140.

So when you add a new category, the model's only job is to map the name to a property id once. You save that mapping, and from then on it's a plain SPARQL query with no tokens spent. Only fields with no property behind them, like 'known for', need the model every time.

1

u/AutoModerator 4h ago

Thank you for your submission, for any questions regarding AI, please check out our wiki at https://www.reddit.com/r/ai_agents/wiki (this is currently in test and we are actively adding to the wiki)

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/SurtidaZukhra 57m ago

do you even need web search for this? almost all of those parameters are static historical or geographic facts that any base model already knows from its training data, except maybe the latest HDI numbers