Spaces:
Running
Running
Create app2.py
Browse files
app2.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import requests
|
3 |
+
import os
|
4 |
+
|
5 |
+
# Get Together API key from environment variable
|
6 |
+
TOGETHER_API_KEY = os.getenv('TOGETHER_API_KEY')
|
7 |
+
|
8 |
+
# Streamlit UI
|
9 |
+
st.title("Zero Shot, Single-Shot, Few Shots Prompting Showcase")
|
10 |
+
|
11 |
+
# User input for prompt and examples
|
12 |
+
prompt_and_examples = st.text_area("Enter your prompt and examples:", """\
|
13 |
+
Label the sentences as either "positive", "negative", "mixed", or "neutral":
|
14 |
+
|
15 |
+
Sentence: I can say that there isn't anything I would change.
|
16 |
+
Label: positive
|
17 |
+
|
18 |
+
Sentence: I'm not sure about this.
|
19 |
+
Sentence: neutral
|
20 |
+
|
21 |
+
Sentence: I liked some parts but I didn't like other parts.
|
22 |
+
Label: mixed
|
23 |
+
|
24 |
+
Sentence: I think the background image could have been better.
|
25 |
+
Label: negative
|
26 |
+
|
27 |
+
Sentence: I really like it.
|
28 |
+
Label:""")
|
29 |
+
|
30 |
+
# Together API endpoint
|
31 |
+
endpoint = 'https://api.together.xyz/inference'
|
32 |
+
|
33 |
+
# Make a request to Together API
|
34 |
+
res = requests.post(endpoint, json={
|
35 |
+
"model": 'togethercomputer/RedPajama-INCITE-7B-Base',
|
36 |
+
"prompt": prompt_and_examples,
|
37 |
+
"top_p": 1,
|
38 |
+
"top_k": 40,
|
39 |
+
"temperature": 0.8,
|
40 |
+
"max_tokens": 1,
|
41 |
+
"repetition_penalty": 1,
|
42 |
+
}, headers={
|
43 |
+
"Authorization": f"Bearer {TOGETHER_API_KEY}",
|
44 |
+
"User-Agent": "<YOUR_APP_NAME>"
|
45 |
+
})
|
46 |
+
|
47 |
+
# Display the output
|
48 |
+
st.text("Output:")
|
49 |
+
st.text(res.json()['output']['choices'][0]['text'])
|