themeetjani commited on
Commit
08e7c21
โ€ข
1 Parent(s): 1583fd0

Update pages/Auto_Report_Generation.py

Browse files
Files changed (1) hide show
  1. pages/Auto_Report_Generation.py +51 -6
pages/Auto_Report_Generation.py CHANGED
@@ -1,14 +1,59 @@
1
  import streamlit as st
2
-
 
 
 
 
 
3
  st.set_page_config(
4
  page_title="Auto_Report_Generation.py",
5
  page_icon="๐Ÿ‘‹",
6
  )
7
 
8
- st.write("# Auto Report Generation.! ๐Ÿ‘‹")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
- st.markdown(
12
- """
13
- **Work in progress!!!** """
14
- )
 
1
  import streamlit as st
2
+ import json
3
+ from io import StringIO
4
+ import openai
5
+ import json
6
+ openai.api_key = "give api key"
7
+
8
  st.set_page_config(
9
  page_title="Auto_Report_Generation.py",
10
  page_icon="๐Ÿ‘‹",
11
  )
12
 
13
+ #need to define openai key or set it as environment variable first.
14
+ #openai function with prompting to generate l1 report.
15
+ #the below code is for fetching company report.
16
+ def all_combined(company_details):
17
+ response = openai.ChatCompletion.create(
18
+ model="gpt-4-1106-preview",
19
+ messages=[
20
+ {
21
+ "role": "system",
22
+ "content": f"following details are given for the company. details : {company_details}",
23
+ },
24
+ {
25
+ "role": "user",
26
+ "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" }
27
+ ],
28
+ temperature=0.6,
29
+ max_tokens=1500,
30
+ top_p=1,
31
+ frequency_penalty=0,
32
+ presence_penalty=0
33
+ )
34
+ return response.choices[0].message.content
35
+
36
+ # if uploaded_file is not None:
37
+ # # To read file as bytes:
38
+ # bytes_data = uploaded_file.getvalue()
39
+ # st.write(bytes_data)
40
 
41
+ # # To convert to a string based IO:
42
+ # stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
43
+ # st.write(stringio)
44
+
45
+ # # To read file as string:
46
+ # string_data = stringio.read()
47
+ # st.write(string_data)
48
+
49
+ # # Can be used wherever a "file-like" object is accepted:
50
+ # dataframe = pd.read_csv(uploaded_file)
51
+ # st.write(dataframe)
52
+ st.write("# Auto Report Generation.! ๐Ÿ‘‹")
53
+ uploaded_file = st.file_uploader("Choose a file")
54
+ json_path = uploaded_file
55
+ with open(json_path, 'r') as j:
56
+ sample_jsonfile = json.loads(j.read())
57
+
58
+ print(all_combined(str(sample_jsonfile)))
59