File size: 3,380 Bytes
fa652ec
 
 
 
6bfcd70
 
fa652ec
6bfcd70
fa652ec
 
 
 
5879438
 
 
fa652ec
3fda2a7
 
fa652ec
 
 
 
 
 
5879438
fa652ec
 
8939a82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import streamlit as st
import openai 
import sys, getopt
from datetime import datetime
from streamlit.components.v1 import html
import boto3

from main import chatgpt_prompt, get_chatgpt_resp, generate_kyc_output, gsearch, save_to_s3

# Function to perform the search
# This is a placeholder function, replace it with your actual search implementation
def perform_search(pname, keywords, num_results):
    # record current timestamp
    start_time = datetime.now()
    
    # Google search for the person name and get the first 20 query links 
    query = pname + " " + keywords
    search_links = gsearch(query, num_results)

    # Construct the prompt 
    prompt_text = chatgpt_prompt(pname, search_links)
    #get ChatGPT response 
    resp = get_chatgpt_resp(prompt_text)
    # Create PDF with links and summary 
    rep_txt= generate_kyc_output(query, search_links, resp, start_time)
    return (rep_txt)

main_tab, help_tab = st.tabs(["Run the Bot", "Help"])

with main_tab: 
    # Streamlit app
    st.title("Adverse News Detection Assistant")

    # Input fields
    names_txt = st.text_input("Enter party name (or multiple names separated by ,)")
    plc_text = "laundering OR terrorist OR fraud OR corrupt OR criminal OR investigation OR prosecute OR evasion OR bribe OR sanction"
    keywords = st.text_input("Enter other search words:", value=plc_text)

    st.sidebar.markdown("## Controls")
    st.sidebar.markdown("Choose your **search** *parameters*")
    num_results = st.sidebar.slider("Choose the number of search results:", 5, 30, 20, 5)
    st.sidebar.markdown("## Model")
    st.sidebar.markdown("GPT v3.5")
    st.sidebar.markdown("## App")
    st.sidebar.markdown("v0.3")

    # Search button
    if st.button("Search"):
        names = names_txt.split(",")
        # Perform the search and display the results
        if names and keywords:
            search_results = ""
            for name in names:
                #print("trying for name {} \n".format(name))
                search_results += perform_search(name, keywords, num_results)

            html(f"<pre>{search_results}</pre>", height=200, scrolling=True)
            st.download_button('Download Report',search_results)
            try:
                date_time = datetime.now()
                save_to_s3(search_results,date_time )
                print ("Completed processing for {} names: {} at {} \n".format(len(names), names_txt, str(date_time)))
            except: 
                print ("Completed processing with S3 write error for {} names: {} at {} \n".format(len(names),names_txt, str(date_time)))
        else:
            st.error("Please enter your name and search keywords before searching.")

with help_tab:
    st.title("FAQ")
    
    st.markdown("Q. How do I get a count of number of adverse news?")
    st.markdown("A. This functionality isnt implemented yet. A workaround is to manually count the number of links with adverse news")

    st.markdown("Q. How do I summarise all the adverse news?")
    st.markdown("A. This functionality isnt implemented yet. A workaround is to aggregate the summary of all adverse news items manually, and get a sumary from ChatGPT (chat.openai.com")

    st.markdown("Q. Can I search in other lauguages?")
    st.markdown("A. This functionality isnt implemented yet. We are planning to test this feature out with Chinese first")