Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,39 +8,32 @@ TOGETHER_API_KEY = os.getenv('TOGETHER_API_KEY')
|
|
8 |
# Streamlit UI
|
9 |
st.title("Movie Review Sentiment Analysis")
|
10 |
|
11 |
-
# User input for
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
15 |
|
16 |
# Together API endpoint
|
17 |
endpoint = 'https://api.together.xyz/inference'
|
18 |
|
19 |
-
# Determine the prompt based on user input
|
20 |
-
if st.button("Analyze Zero-shot"):
|
21 |
-
prompt = zero_shot_prompt
|
22 |
-
elif st.button("Analyze One-shot"):
|
23 |
-
prompt = one_shot_prompt
|
24 |
-
elif st.button("Analyze Few-shot"):
|
25 |
-
prompt_options = few_shot_prompt.split(',')
|
26 |
-
prompt = '\n'.join([f"Option {i + 1}: {option.strip()}" for i, option in enumerate(prompt_options)])
|
27 |
-
else:
|
28 |
-
prompt = ""
|
29 |
-
|
30 |
# Make a request to Together API if a prompt is provided
|
31 |
-
if
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
8 |
# Streamlit UI
|
9 |
st.title("Movie Review Sentiment Analysis")
|
10 |
|
11 |
+
# User input for prompting technique
|
12 |
+
prompting_technique = st.selectbox("Select prompting technique:", ["Zero-shot", "One-shot", "Few-shot"])
|
13 |
+
|
14 |
+
# Dynamic textbox based on user selection
|
15 |
+
prompt = st.text_area(f"Enter {prompting_technique} prompt:", "")
|
16 |
|
17 |
# Together API endpoint
|
18 |
endpoint = 'https://api.together.xyz/inference'
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
# Make a request to Together API if a prompt is provided
|
21 |
+
if st.button(f"Analyze {prompting_technique}"):
|
22 |
+
if prompt:
|
23 |
+
response = requests.post(endpoint, json={
|
24 |
+
"model": 'togethercomputer/RedPajama-INCITE-7B-Base',
|
25 |
+
"prompt": prompt,
|
26 |
+
"top_p": 1,
|
27 |
+
"top_k": 40,
|
28 |
+
"temperature": 0.8,
|
29 |
+
"max_tokens": 1,
|
30 |
+
"repetition_penalty": 1,
|
31 |
+
}, headers={
|
32 |
+
"Authorization": f"Bearer {TOGETHER_API_KEY}"
|
33 |
+
})
|
34 |
|
35 |
+
# Display the output
|
36 |
+
st.text("Sentiment Analysis Result:")
|
37 |
+
st.text(response.json()['output']['choices'][0]['text'])
|
38 |
+
else:
|
39 |
+
st.warning("Please enter a prompt.")
|