# https://github.com/palladius/gemini-news-crawler/issues/2

post1 = "POST /v1beta/models/gemini-1.5-pro-latest:generateContent?key=[REDACTED] HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: generativelanguage.googleapis.com\r\nContent-Type: application/json\r\nContent-Length: 6411\r\n\r\n"
post2 = "{\"tools\":{\"functionDeclarations\":[{\"name\":\"news_retriever__get_everything\",\"description\":\"News Retriever: Search through millions of articles from over 150,000 large and small news sources and blogs.\",\"parameters\":{\"type\":\"object\",\"properties\":{\"q\":{\"type\":\"string\",\"description\":\"Keywords or phrases to search for in the article title and body. Surround phrases with quotes (\\\") for exact match. Alternatively you can use the AND / OR / NOT keywords, and optionally group these with parenthesis. Must be URL-encoded.\"},\"searchIn\":{\"type\":\"string\",\"description\":\"The fields to restrict your q search to.\",\"enum\":[\"title\",\"description\",\"content\"]},\"sources\":{\"type\":\"string\",\"description\":\"A comma-seperated string of identifiers (maximum 20) for the news sources or blogs you want headlines from. Use the /sources endpoint to locate these programmatically or look at the sources index.\"},\"domains\":{\"type\":\"string\",\"description\":\"A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com, engadget.com) to restrict the search to.\"},\"excludeDomains\":{\"type\":\"string\",\"description\":\"A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com, engadget.com) to remove from the results.\"},\"from\":{\"type\":\"string\",\"description\":\"A date and optional time for the oldest article allowed. This should be in ISO 8601 format.\"},\"to\":{\"type\":\"string\",\"description\":\"A date and optional time for the newest article allowed. This should be in ISO 8601 format.\"},\"language\":{\"type\":\"string\",\"description\":\"The 2-letter ISO-639-1 code of the language you want to get headlines for.\",\"enum\":[\"ar\",\"de\",\"en\",\"es\",\"fr\",\"he\",\"it\",\"nl\",\"no\",\"pt\",\"ru\",\"sv\",\"ud\",\"zh\"]},\"sortBy\":{\"type\":\"string\",\"description\":\"The order to sort the articles in.\",\"enum\":[\"relevancy\",\"popularity\",\"publishedAt\"]},\"pageSize\":{\"type\":\"integer\",\"description\":\"The number of results to return per page (request). 5 is the default, 100 is the maximum.\"},\"page\":{\"type\":\"integer\",\"description\":\"Use this to page through the results if the total results found is greater than the page size.\"}}}},{\"name\":\"news_retriever__get_top_headlines\",\"description\":\"News Retriever: Provides live top and breaking headlines for a country, specific category in a country, single source, or multiple sources. You can also search with keywords. Articles are sorted by the earliest date published first.\",\"parameters\":{\"type\":\"object\",\"properties\":{\"country\":{\"type\":\"string\",\"description\":\"The 2-letter ISO 3166-1 code of the country you want to get headlines for.\",\"enum\":[\"ae\",\"ar\",\"at\",\"au\",\"be\",\"bg\",\"br\",\"ca\",\"ch\",\"cn\",\"co\",\"cu\",\"cz\",\"de\",\"eg\",\"fr\",\"gb\",\"gr\",\"hk\",\"hu\",\"id\",\"ie\",\"il\",\"in\",\"it\",\"jp\",\"kr\",\"lt\",\"lv\",\"ma\",\"mx\",\"my\",\"ng\",\"nl\",\"no\",\"nz\",\"ph\",\"pl\",\"pt\",\"ro\",\"rs\",\"ru\",\"sa\",\"se\",\"sg\",\"si\",\"sk\",\"th\",\"tr\",\"tw\",\"ua\",\"us\",\"ve\",\"za\"]},\"category\":{\"type\":\"string\",\"description\":\"The category you want to get headlines for.\",\"enum\":[\"business\",\"entertainment\",\"general\",\"health\",\"science\",\"sports\",\"technology\"]},\"q\":{\"type\":\"string\",\"description\":\"Keywords or a phrase to search for.\"},\"pageSize\":{\"type\":\"integer\",\"description\":\"The number of results to return per page (request). 5 is the default, 100 is the maximum.\"},\"page\":{\"type\":\"integer\",\"description\":\"Use this to page through the results if the total results found is greater than the page size.\"}}}},{\"name\":\"news_retriever__get_sources\",\"description\":\"News Retriever: This endpoint returns the subset of news publishers that top headlines (/v2/top-headlines) are available from. It's mainly a convenience endpoint that you can use to keep track of the publishers available on the API, and you can pipe it straight through to your users.\",\"parameters\":{\"type\":\"object\",\"properties\":{\"country\":{\"type\":\"string\",\"description\":\"The 2-letter ISO 3166-1 code of the country you want to get headlines for. Default: all countries.\",\"enum\":[\"ae\",\"ar\",\"at\",\"au\",\"be\",\"bg\",\"br\",\"ca\",\"ch\",\"cn\",\"co\",\"cu\",\"cz\",\"de\",\"eg\",\"fr\",\"gb\",\"gr\",\"hk\",\"hu\",\"id\",\"ie\",\"il\",\"in\",\"it\",\"jp\",\"kr\",\"lt\",\"lv\",\"ma\",\"mx\",\"my\",\"ng\",\"nl\",\"no\",\"nz\",\"ph\",\"pl\",\"pt\",\"ro\",\"rs\",\"ru\",\"sa\",\"se\",\"sg\",\"si\",\"sk\",\"th\",\"tr\",\"tw\",\"ua\",\"us\",\"ve\",\"za\"]},\"category\":{\"type\":\"string\",\"description\":\"The category you want to get headlines for. Default: all categories.\",\"enum\":[\"business\",\"entertainment\",\"general\",\"health\",\"science\",\"sports\",\"technology\"]},\"language\":{\"type\":\"string\",\"description\":\"The 2-letter ISO-639-1 code of the language you want to get headlines for.\",\"enum\":[\"ar\",\"de\",\"en\",\"es\",\"fr\",\"he\",\"it\",\"nl\",\"no\",\"pt\",\"ru\",\"sv\",\"ud\",\"zh\"]}}}},{\"name\":\"article_tool__create\",\"description\":\"Article Database: Create a new article\",\"parameters\":{\"type\":\"object\",\"properties\":{\"title\":{\"type\":\"string\",\"description\":\"Article title\"},\"summary\":{\"type\":\"string\",\"description\":\"Article summary (in UTF-8)\"},\"content\":{\"type\":\"string\",\"description\":\"Article content (in UTF-8)\"},\"author\":{\"type\":\"string\",\"description\":\"Article author\"},\"link\":{\"type\":\"string\",\"description\":\"Article link\"},\"publishedDate\":{\"type\":\"string\",\"description\":\"Article published date\"},\"language\":{\"type\":\"string\",\"description\":\"Article language (2 letters)\"},\"country\":{\"type\":\"string\",\"description\":\"Country the article refers to (whatever makes more sense to you: the newspaper location, the country where they speak the language, or the country where the facts happen. If unsure, say Vatican City)\"},\"countryEmoji\":{\"type\":\"string\",\"description\":\"Country flag emoji - emoji of the country you chose in 'country' field. If unsure, emoji of vatican city.\"}},\"required\":[\"title\",\"summary\",\"content\",\"author\",\"link\",\"published_date\",\"language\"]}},{\"name\":\"article_tool__delete\",\"description\":\"Article Database: Delete an article by id\",\"parameters\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"number\",\"description\":\"Article numeric ID\"}},\"required\":[\"id\"]}},{\"name\":\"article_tool__carlessian_url\",\"description\":\"Carlessian URL: Provide an article perma-URL for gemini-news-crawler app by id\",\"parameters\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"number\",\"description\":\"Article numeric ID\"}},\"required\":[\"id\"]}}]},\"model\":\"gemini-1.5-pro-latest\",\"contents\":[{\"role\":\"user\",\"parts\":[{\"text\":\"Latest 5 news from Italy\"}]},{\"role\":\"user\",\"parts\":[{\"text\":\"Latest 5 news from Italy\"}]}],\"systemInstruction\":{\"parts\":[{\"text\":\"You are a News Assistant.\"}]},\"toolConfig\":{\"functionCallingConfig\":{\"mode\":\"AUTO\"}},\"generationConfig\":{\"temperature\":0.0}}"

post_str = post1 + post2
h = JSON.parse(post2)
