-
Notifications
You must be signed in to change notification settings - Fork 0
/
Item_classifier.py
78 lines (68 loc) · 1.98 KB
/
Item_classifier.py
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
73
74
75
76
77
78
import openai
import streamlit as stream
stream.set_page_config(page_title="Items Classification")
stream.title("Item Classifier Model")
prompt = """
Facebook: Social media, Technology
LinkedIn: Social media, Technology, Enterprise, Careers
Uber: Transportation, Technology, Marketplace
Unilever: Conglomerate, Consumer Goods
Mcdonalds: Food, Fast Food, Logistics, Restaurants
"""
# Get your API key from "https://beta.openai.com/account/api-keys"
openai.api_key = "API KEY"
def gpt3(prompt, engine = 'davinci', temperature = 0, top_p = 1.0, frequency_penalty = 0.0, presence_penalty = 0.0, stop_seq = ["\n"]):
response = openai.Completion.create(
prompt = prompt,
engine = engine,
max_tokens = 64,
temperature = temperature,
top_p = top_p,
frequency_penalty = frequency_penalty,
presence_penalty = presence_penalty,
stop = stop_seq,
)
print(response)
result = response.choices[0]['text']
print(result)
return result
try:
form_application = stream.form(key = 'form')
command = form_application.text_input("Enter Item "+":")
submit = form_application.form_submit_button('Submit')
if submit:
stream.header("**Results**")
prompt += command
result = gpt3(prompt)
stream.header(result)
except Exception as exp:
stream.success(f'Something Went Wrong!😁 {exp}')
footer="""
<style>
a:link,
a:visited{
color: blue;
background-color: transparent;
text-decoration: underline;
}
a:hover,
a:active {
color: red;
background-color: transparent;
text-decoration: underline;
}
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: white;
color: black;
text-align: center;
}
</style>
<div class="footer">
<p>Developed with ❤ by <a style='display: block; text-align: center;' href="https://github.com/chirag-goel360" target="_blank"> Chirag Goel </a></p>
</div>
"""
stream.markdown(footer,unsafe_allow_html = True)