File size: 2,494 Bytes
6060e42
b3417f2
08e7c21
 
 
 
0caa034
 
08e7c21
6060e42
 
 
 
 
08e7c21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6060e42
08e7c21
 
 
 
 
 
 
 
 
 
 
 
 
7fe00f9
 
 
 
 
105b3e9
 
 
 
e7a366d
7fe00f9
6060e42
105b3e9
 
 
e7a366d
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
import streamlit as st
from streamlit import session_state
import json
from io import StringIO
import openai
import json
import os
openai.api_key = os.getenv("OPENAI_API_KEY")

st.set_page_config(
    page_title="Auto_Report_Generation.py",
    page_icon="👋",
)

#need to define openai key or set it as environment variable first.
#openai function with prompting to generate l1 report.
#the below code is for fetching company report.
def all_combined(company_details):
    response = openai.ChatCompletion.create(
      model="gpt-4-1106-preview",
      messages=[
         {
      "role": "system",
      "content": f"following details are given for the company. details : {company_details}",
         },
          {
      "role": "user",
      "content": "Generate a detailed report out of this content. Please include all the details. Don't leave out any information. Give very detailed information about adverse media. And give very detailed report structure wise. Give contact details and employee details in a table. Please don't mention confirmed status or client in the table. Also give nice introduction first.<<REMEMBER>>\n mention that the information is provided by client. Don't mention the identifier tools. Mask it with some unknown source. Also mention number of confirmed sources by analyst" } 
         ],
      temperature=0.6,
      max_tokens=1500,
      top_p=1,
      frequency_penalty=0,
      presence_penalty=0
    )
    return response.choices[0].message.content

# if uploaded_file is not None:
#     # To read file as bytes:
#     bytes_data = uploaded_file.getvalue()
#     st.write(bytes_data)

#     # To convert to a string based IO:
#     stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
#     st.write(stringio)

#     # To read file as string:
#     string_data = stringio.read()
#     st.write(string_data)

#     # Can be used wherever a "file-like" object is accepted:
#     dataframe = pd.read_csv(uploaded_file)
#     st.write(dataframe)
st.write("# Auto Report Generation.! 👋")
uploaded_file = st.file_uploader("Choose a file")
if uploaded_file is not None:

    # To convert to a string based IO:
    fileee = StringIO(uploaded_file.getvalue().decode("utf-8"))
    st.write(fileee)
    
if 'report' not in session_state:
    session_state['report']= ""
    
def classify():
    session_state['report'] = all_combined(fileee)


st.text_area("result", value=session_state['report'])

st.button("Generate a Report", on_click=classify)