alpcansoydas commited on
Commit
512f3d4
1 Parent(s): 0c62f77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -17
app.py CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
2
  from langchain.prompts import PromptTemplate
3
  from langchain_huggingface import HuggingFaceEndpoint
4
  from langchain_core.output_parsers import JsonOutputParser
5
- from langdetect import detect
6
  import time
7
 
8
  # Initialize the LLM and other components
@@ -16,15 +15,17 @@ llm = HuggingFaceEndpoint(
16
 
17
  template_classify = '''
18
  You are an irrelevant text detector bot.
19
- In social media, there are lots of bot accounts and they produce non related text on company hashtag.
20
- You will be provided company informations such as company name, company sector and information about company and text from social media.
21
- You will classify it as RELEVANT or IRRELEVANT.
 
22
 
 
23
  Company name: {COMPANY_NAME}
24
  Company sector: {COMPANY_SECTOR}
25
  About Company: {ABOUT_COMPANY}
26
 
27
- Detect following text as RELEVANT OR IRRELEVANT:
28
 
29
  <text>
30
  {TEXT}
@@ -54,17 +55,6 @@ def classify_text(text, company_name_input, company_sector_input, about_company_
54
  ABOUT_COMPANY=about_company_input
55
  )
56
  classify = llm.invoke(formatted_prompt)
57
-
58
- '''
59
- prompt_json = PromptTemplate(
60
- template=template_json,
61
- input_variables=["RESPONSE"]
62
- )
63
- '''
64
-
65
- #formatted_prompt = template_json.format(RESPONSE=classify)
66
- #response = llm.invoke(formatted_prompt)
67
-
68
  parsed_output = json_output_parser.parse(classify)
69
  end = time.time()
70
  duration = end - start
@@ -90,4 +80,4 @@ def create_gradio_interface():
90
  iface.launch()
91
 
92
  if __name__ == "__main__":
93
- create_gradio_interface()
 
2
  from langchain.prompts import PromptTemplate
3
  from langchain_huggingface import HuggingFaceEndpoint
4
  from langchain_core.output_parsers import JsonOutputParser
 
5
  import time
6
 
7
  # Initialize the LLM and other components
 
15
 
16
  template_classify = '''
17
  You are an irrelevant text detector bot.
18
+ In social media, there are lots of bot accounts or real people and they produce irrelevant/non-related text about company and its services.
19
+ You will be provided company informations such as company name, company sector and information about company.
20
+ Using this informations about company, think about its services and sector, if given text is relevant to the company classify it as RELEVANT,
21
+ if the given text is not relevant to the company classify it as IRRELEVANT
22
 
23
+ Provided information:
24
  Company name: {COMPANY_NAME}
25
  Company sector: {COMPANY_SECTOR}
26
  About Company: {ABOUT_COMPANY}
27
 
28
+ Detect following text as RELEVANT OR IRRELEVANT based on Company Name, Company Sector, About Company:
29
 
30
  <text>
31
  {TEXT}
 
55
  ABOUT_COMPANY=about_company_input
56
  )
57
  classify = llm.invoke(formatted_prompt)
 
 
 
 
 
 
 
 
 
 
 
58
  parsed_output = json_output_parser.parse(classify)
59
  end = time.time()
60
  duration = end - start
 
80
  iface.launch()
81
 
82
  if __name__ == "__main__":
83
+ create_gradio_interface()