cleopatro commited on
Commit
4065d67
β€’
1 Parent(s): 2d9731a

Let's Test

Browse files
Files changed (2) hide show
  1. requirements.txt +13 -0
  2. stream_lit.py +80 -0
requirements.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ anyio==3.6.2
2
+ click==8.1.3
3
+ colorama==0.4.6
4
+ fastapi==0.95.1
5
+ h11==0.14.0
6
+ idna==3.4
7
+ pydantic==1.10.7
8
+ python-dotenv==1.0.0
9
+ sniffio==1.3.0
10
+ starlette==0.26.1
11
+ textrazor==1.4.0
12
+ typing_extensions==4.5.0
13
+ uvicorn==0.22.0
stream_lit.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ # from main import make_output
3
+ # from summarization import make_summary
4
+ import textrazor
5
+ from dotenv import load_dotenv
6
+ import os
7
+ import pandas as pd
8
+ import replicate
9
+
10
+
11
+ load_dotenv()
12
+ REPLICATE_API_TOKEN = os.getenv("REPLICATE_API_TOKEN")
13
+
14
+ # text_ = """Alice: Hi there, is this Bob?
15
+ # Bob: Yes, speaking. Who's calling?
16
+ # Alice: Hey Bob, it's Alice from Acme Inc. We met at the conference last month.
17
+ # Bob: Oh, hey Alice! Good to hear from you. How can I help you today?
18
+ # Alice: Well, I was just calling because I wanted to touch base with you about that project we discussed at the conference. I was hoping we could set up a meeting to talk about it in more detail.
19
+ # Bob: Absolutely, I'd be happy to. When were you thinking?
20
+ # Alice: How about next Tuesday at 10 am?
21
+ # Bob: That works for me. Where should we meet?
22
+ # Alice: We can meet at our office in downtown. Here's the address: 123 Main St. Suite 400.
23
+ # Bob: Great. And just to confirm, your mobile number is still (555) 123-4567, right?
24
+ # Alice: Yes, that's correct.
25
+ # Bob: Perfect. I'll put the meeting in my calendar and send you a confirmation email with all the details.
26
+ # Alice: Sounds good, thanks Bob. Looking forward to it!"""
27
+
28
+ replicate.Client(api_token=REPLICATE_API_TOKEN)
29
+
30
+ def make_summary(text_):
31
+ output = replicate.run(
32
+ "replicate/flan-t5-xl:7a216605843d87f5426a10d2cc6940485a232336ed04d655ef86b91e020e9210",
33
+ input={"prompt": """Write the summary extract any useful information like name, number, and organization of the following conversation {text_to_summarize} """.format(text_to_summarize = text_)},
34
+ max_length = 500,
35
+ temperature = 0.7,
36
+ top_p = 0.95,
37
+ repetition_penalty = 1,
38
+ )
39
+ return " ".join(output)
40
+
41
+ load_dotenv()
42
+ textrazor.api_key = os.getenv("TEXT_RAZOR_API_KEY")
43
+
44
+ client = textrazor.TextRazor(extractors=["entities", "topics"])
45
+
46
+ def make_output(text:str):
47
+ response = client.analyze(text=text)
48
+ df = pd.DataFrame()
49
+ for entity in response.entities():
50
+ output_dict = {"id": "".join(list(entity.id or "None")),
51
+ "type": ", ".join(list(entity.dbpedia_types or "None")),
52
+ "wiki link": "".join(list(entity.wikipedia_link or "None"))}
53
+ df2 = pd.DataFrame.from_records([output_dict])
54
+ # df = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True)
55
+ df = pd.concat([df, df2], ignore_index=True)
56
+ # print(entity.id)
57
+ df = df.drop_duplicates()
58
+ return(df)
59
+
60
+ st.title("CultureScout NLP Tool πŸ€–")
61
+
62
+ # taking user inputs for context search
63
+ st.write("Enter Text You Need Help With:")
64
+ user_input = st.text_input("Text Here:", "")
65
+
66
+ if st.button("πŸ”Ž Search It!"):
67
+ def predict_sentiment(data:str):
68
+ ans = make_output(user_input)
69
+ return ans
70
+ st.table(predict_sentiment(user_input))
71
+
72
+ # taking user inputs for summarization
73
+ st.write("Enter Text You Need to Summarize:")
74
+ user_input1 = st.text_area("Text Here:", "")
75
+
76
+ if st.button("πŸͺ„ Summarize"):
77
+ def summarize(data:str):
78
+ ans1 = make_summary(user_input1)
79
+ return ans1
80
+ st.write(summarize(user_input1))