Streamlit UI, Porting CLI - WIP
This commit is contained in:
@@ -3,6 +3,7 @@ import os
|
||||
import sys
|
||||
import re
|
||||
import configparser
|
||||
import streamlit as st
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from loguru import logger
|
||||
@@ -92,8 +93,10 @@ def save_in_file(table_content):
|
||||
try:
|
||||
# Save the content to the file
|
||||
with open(file_path, "a+", encoding="utf-8") as file:
|
||||
st.write(table_content)
|
||||
file.write(table_content)
|
||||
file.write("\n" * 3) # Add three newlines at the end
|
||||
logger.info(f"Search content saved to {file_path}")
|
||||
return file_path
|
||||
except Exception as e:
|
||||
logger.error(f"Error occurred while writing to the file: {e}")
|
||||
|
||||
@@ -31,6 +31,7 @@ import pandas as pd
|
||||
import json
|
||||
import requests
|
||||
from clint.textui import progress
|
||||
import streamlit as st
|
||||
|
||||
#from serpapi import GoogleSearch
|
||||
from loguru import logger
|
||||
@@ -326,6 +327,9 @@ def process_search_results(search_results, search_type="general"):
|
||||
print(combined_table)
|
||||
# Save the combined table to a file
|
||||
try:
|
||||
# Display on Alwrity UI
|
||||
st.write(organic_table)
|
||||
st.write(combined_table)
|
||||
save_in_file(organic_table)
|
||||
save_in_file(combined_table)
|
||||
except Exception as save_results_err:
|
||||
|
||||
@@ -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, max_results=10):
|
||||
def get_tavilyai_results(keywords, max_results=5):
|
||||
"""
|
||||
Get Tavily AI search results based on specified keywords and options.
|
||||
|
||||
@@ -154,16 +154,3 @@ def print_result_table(output_data):
|
||||
save_in_file(table)
|
||||
except Exception as save_results_err:
|
||||
logger.error(f"Failed to save search results: {save_results_err}")
|
||||
|
||||
|
||||
def save_in_file(table_content):
|
||||
""" Helper function to save search analysis in a file. """
|
||||
file_path = os.environ.get('SEARCH_SAVE_FILE')
|
||||
try:
|
||||
# Save the content to the file
|
||||
with open(file_path, "a", encoding="utf-8") as file:
|
||||
file.write(table_content)
|
||||
file.write("\n" * 3) # Add three newlines at the end
|
||||
logger.info(f"Search content saved to {file_path}")
|
||||
except Exception as e:
|
||||
logger.error(f"Error occurred while writing to the file: {e}")
|
||||
|
||||
Reference in New Issue
Block a user