AI Agents content ideator team, prompt config
This commit is contained in:
@@ -331,10 +331,11 @@ def get_suggestions_for_keyword(search_term):
|
||||
pd.set_option('display.max_rows', expanded_results_df.shape[0]+1)
|
||||
expanded_results_df.drop_duplicates('Keywords', inplace=True)
|
||||
table = tabulate(expanded_results_df, headers=['Keywords', 'Relevance'], tablefmt='fancy_grid')
|
||||
try:
|
||||
save_in_file(table)
|
||||
except Exception as save_results_err:
|
||||
logger.error(f"Failed to save search results: {save_results_err}")
|
||||
# FIXME: Too much data for LLM context window. We will need to embed it.
|
||||
#try:
|
||||
# save_in_file(table)
|
||||
#except Exception as save_results_err:
|
||||
# logger.error(f"Failed to save search results: {save_results_err}")
|
||||
return expanded_results_df
|
||||
except Exception as e:
|
||||
logger.error(f"get_suggestions_for_keyword: Error in main: {e}")
|
||||
|
||||
@@ -67,12 +67,12 @@ def do_google_serp_search(search_keywords):
|
||||
# Not failing, as tavily would do same and then GPT-V to search.
|
||||
|
||||
|
||||
def do_tavily_ai_search(search_keywords):
|
||||
def do_tavily_ai_search(search_keywords, max_results=10):
|
||||
""" Common function to do Tavily AI web research."""
|
||||
try:
|
||||
# FIXME: Include the follow-up questions as blog FAQs.
|
||||
logger.info(f"Doing Tavily AI search for: {search_keywords}")
|
||||
t_results = get_tavilyai_results(search_keywords)
|
||||
t_results = get_tavilyai_results(search_keywords, max_results)
|
||||
t_titles = tavily_extract_information(t_results, 'titles')
|
||||
t_answer = tavily_extract_information(t_results, 'answer')
|
||||
return(t_results, t_titles, t_answer)
|
||||
|
||||
@@ -49,7 +49,7 @@ from tenacity import retry, stop_after_attempt, wait_random_exponential
|
||||
|
||||
|
||||
@retry(wait=wait_random_exponential(min=1, max=60), stop=stop_after_attempt(6))
|
||||
def get_tavilyai_results(keywords):
|
||||
def get_tavilyai_results(keywords, max_results=10):
|
||||
"""
|
||||
Get Tavily AI search results based on specified keywords and options.
|
||||
|
||||
@@ -86,13 +86,13 @@ def get_tavilyai_results(keywords):
|
||||
tavily_search_result = client.search(keywords,
|
||||
search_depth="advanced",
|
||||
include_answer=True,
|
||||
max_results=10,
|
||||
max_results=max_results,
|
||||
include_domains=include_urls)
|
||||
else:
|
||||
tavily_search_result = client.search(keywords,
|
||||
search_depth = "advanced",
|
||||
include_answer=True,
|
||||
max_results=10)
|
||||
max_results=max_results)
|
||||
|
||||
print_result_table(tavily_search_result)
|
||||
return(tavily_search_result)
|
||||
|
||||
Reference in New Issue
Block a user