deepakchawla-cb commited on
Commit
1ea7ab0
·
1 Parent(s): 20a0847

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -0
app.py CHANGED
@@ -5,6 +5,81 @@ from transformers import pipeline
5
  model = whisper.load_model("base")
6
  sentiment_analysis = pipeline("sentiment-analysis", framework="pt", model="SamLowe/roberta-base-go_emotions")
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  def analyze_sentiment(text):
9
  results = sentiment_analysis(text)
10
  sentiment_results = {result['label']: result['score'] for result in results}
 
5
  model = whisper.load_model("base")
6
  sentiment_analysis = pipeline("sentiment-analysis", framework="pt", model="SamLowe/roberta-base-go_emotions")
7
 
8
+
9
+ import gradio as gr
10
+ import whisper
11
+ from transformers import pipeline
12
+ import gradio as gr
13
+ import pandas as pd
14
+ from io import StringIO
15
+ import os,re
16
+ from langchain.llms import OpenAI
17
+ import pandas as pd
18
+
19
+ from langchain.document_loaders import UnstructuredPDFLoader
20
+
21
+ from langchain.prompts import PromptTemplate
22
+ from langchain.chains import LLMChain
23
+
24
+ from langchain.embeddings.openai import OpenAIEmbeddings
25
+ from langchain.vectorstores import Chroma
26
+ from langchain.text_splitter import CharacterTextSplitter
27
+ from langchain.llms import OpenAI
28
+ from langchain.chains import RetrievalQA
29
+ from langchain.document_loaders import TextLoader
30
+ from langchain.prompts import PromptTemplate
31
+ from langchain.callbacks.stdout import StdOutCallbackHandler
32
+ from langchain.chat_models.openai import ChatOpenAI
33
+ from langchain.prompts.prompt import PromptTemplate
34
+
35
+ from langchain.llms import OpenAI
36
+ from langchain.prompts import PromptTemplate
37
+ from langchain.chains import LLMChain
38
+ model = whisper.load_model("base")
39
+ sentiment_analysis = pipeline("sentiment-analysis", framework="pt", model="SamLowe/roberta-base-go_emotions")
40
+
41
+ def predict(text):
42
+
43
+ prompt_template = """Ignore all previous instructions. You are the world's hearing aid company markerting agent.
44
+ I am going to give you a text of a customer. Analyze it and you have 4 products in list which you have to suggest to the customer:
45
+ ampli-mini it is mainly works for Maximum comfort and discretion, ampli-connect it is mainly works for Connected to the things you love,
46
+ ampli-energy it is mainly works for Full of energy, like you, ampli-easy it is mainly works for Allow yourself to hear well.
47
+ You can also be creative, funny, or show emotions at time.
48
+ also share the book a appointment link of your company https://www.amplifon.com/uk/book-an-appointment
49
+ Question: {question}
50
+ Product details:"""
51
+
52
+ prompt_template_lang = """
53
+ You are the world's best languages translator. Will give you some text or paragraph which you have to convert into Tamil, Hindi, Kannada
54
+ and French.
55
+ Input Text: {text}
56
+ Tamil:
57
+ Hindi:
58
+ Kannada:
59
+ French:
60
+ """
61
+ PROMPT = PromptTemplate(
62
+ template=prompt_template, input_variables=["question"]
63
+ )
64
+ PROMPT_lang = PromptTemplate(
65
+ template=prompt_template_lang, input_variables=["text"]
66
+ )
67
+
68
+ llm = OpenAI()
69
+
70
+ chain = LLMChain(llm=llm, prompt=PROMPT)
71
+ chain_lang = LLMChain(llm=llm, prompt=PROMPT_lang)
72
+
73
+ resp = chain.run(question=text)
74
+ resp_lang = chain_lang.run(text=resp)
75
+
76
+
77
+
78
+
79
+ return [resp, resp_lang]
80
+
81
+
82
+
83
  def analyze_sentiment(text):
84
  results = sentiment_analysis(text)
85
  sentiment_results = {result['label']: result['score'] for result in results}