Spaces:
Running
Running
pragneshbarik
commited on
Commit
•
8b18fd0
1
Parent(s):
5c2e60f
engineered some prompt
Browse files
app.py
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
import streamlit as st
|
2 |
from mistral7b import mistral
|
3 |
|
|
|
|
|
|
|
|
|
4 |
import time
|
5 |
|
6 |
|
@@ -10,45 +14,66 @@ if "messages" not in st.session_state:
|
|
10 |
if "tokens_used" not in st.session_state:
|
11 |
st.session_state.tokens_used = 0
|
12 |
|
13 |
-
if "
|
14 |
st.session_state.inference_time = [0.00]
|
15 |
|
16 |
|
17 |
if "temp" not in st.session_state:
|
18 |
st.session_state.temp = 0.8
|
19 |
|
20 |
-
if "model_settings" not in st.session_state:
|
21 |
-
st.session_state.model_settings = {
|
22 |
-
"temp": 0.9,
|
23 |
-
"max_tokens": 512,
|
24 |
-
}
|
25 |
-
|
26 |
if "history" not in st.session_state:
|
27 |
-
st.session_state.history = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
if "top_k" not in st.session_state:
|
30 |
st.session_state.top_k = 5
|
31 |
|
|
|
|
|
32 |
with st.sidebar:
|
33 |
st.markdown("# Model Analytics")
|
|
|
34 |
st.write("Tokens used :", st.session_state['tokens_used'])
|
35 |
-
|
36 |
st.write("Average Inference Time: ", round(sum(
|
37 |
-
st.session_state["inference_time"]) / len(st.session_state["inference_time"]), 3))
|
38 |
st.write("Cost Incured :", round(
|
39 |
0.033 * st.session_state['tokens_used'] / 1000, 3), "INR")
|
|
|
|
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
st.markdown("---")
|
|
|
42 |
st.markdown("# Retrieval Settings")
|
43 |
st.slider(label="Documents to retrieve",
|
44 |
min_value=1, max_value=10, value=3)
|
45 |
-
|
46 |
-
st.markdown("# Model Settings")
|
47 |
-
selected_model = st.sidebar.radio(
|
48 |
-
'Select one:', ["Mistral 7B", "GPT 3.5 Turbo", "GPT 4", "Llama 7B"])
|
49 |
-
selected_temperature = st.slider(
|
50 |
-
label="Temperature", min_value=0.0, max_value=1.0, step=0.1, value=0.5)
|
51 |
-
st.write(" ")
|
52 |
st.info("**2023 ©️ Pragnesh Barik**")
|
53 |
|
54 |
|
@@ -66,16 +91,19 @@ for message in st.session_state.messages:
|
|
66 |
st.markdown(message["content"])
|
67 |
|
68 |
|
69 |
-
if prompt := st.chat_input("Chat with Ikigai Docs
|
70 |
st.chat_message("user").markdown(prompt)
|
71 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
72 |
|
|
|
73 |
tick = time.time()
|
74 |
-
|
75 |
-
|
|
|
76 |
tock = time.time()
|
77 |
|
78 |
st.session_state.inference_time.append(tock - tick)
|
|
|
79 |
response = response.replace("</s>", "")
|
80 |
len_response = len(response.split())
|
81 |
|
|
|
1 |
import streamlit as st
|
2 |
from mistral7b import mistral
|
3 |
|
4 |
+
st.set_page_config(
|
5 |
+
page_title="Ikigai Chat",
|
6 |
+
)
|
7 |
+
|
8 |
import time
|
9 |
|
10 |
|
|
|
14 |
if "tokens_used" not in st.session_state:
|
15 |
st.session_state.tokens_used = 0
|
16 |
|
17 |
+
if "inference_time" not in st.session_state:
|
18 |
st.session_state.inference_time = [0.00]
|
19 |
|
20 |
|
21 |
if "temp" not in st.session_state:
|
22 |
st.session_state.temp = 0.8
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
if "history" not in st.session_state:
|
25 |
+
st.session_state.history = [["""
|
26 |
+
You are not mistral AI, but rather a chat bot trained at Ikigai Labs, when ever asked you need to answer as ikigai Labs' assistant.
|
27 |
+
Ikigai helps modern analysts and operations teams automate data-intensive business, finance, analytics, and supply-chain operations.
|
28 |
+
The company's Inventory Ops automates inventory tracking and monitoring by creating a single, real-time view of inventory across all locations and channels.""",
|
29 |
+
"""
|
30 |
+
Yes, you are correct. Ikigai Labs is a company that specializes in helping
|
31 |
+
modern analysts and operations teams automate data-intensive business, finance, analytics,
|
32 |
+
and supply chain operations. One of their products is Inventory Ops, which automates inventory
|
33 |
+
tracking and monitoring by creating a single, real-time view of inventory across all locations and channels.
|
34 |
+
This helps businesses optimize their inventory levels and reduce costs.
|
35 |
+
Is there anything else you would like to know about Ikigai Labs or their products?
|
36 |
+
|
37 |
+
|
38 |
+
"""]]
|
39 |
|
40 |
if "top_k" not in st.session_state:
|
41 |
st.session_state.top_k = 5
|
42 |
|
43 |
+
if "repetion_penalty" not in st.session_state :
|
44 |
+
st.session_state.repetion_penalty = 1
|
45 |
with st.sidebar:
|
46 |
st.markdown("# Model Analytics")
|
47 |
+
|
48 |
st.write("Tokens used :", st.session_state['tokens_used'])
|
|
|
49 |
st.write("Average Inference Time: ", round(sum(
|
50 |
+
st.session_state["inference_time"]) / len(st.session_state["inference_time"]), 3), "Secs")
|
51 |
st.write("Cost Incured :", round(
|
52 |
0.033 * st.session_state['tokens_used'] / 1000, 3), "INR")
|
53 |
+
|
54 |
+
st.markdown("---")
|
55 |
|
56 |
+
st.markdown("# Model Settings")
|
57 |
+
|
58 |
+
selected_model = st.sidebar.radio(
|
59 |
+
'Select one:', ["Mistral 7B","Llama 7B" ,"GPT 3.5 Turbo", "GPT 4" ])
|
60 |
+
st.session_state.temp = st.slider(
|
61 |
+
label="Temperature", min_value=0.0, max_value=1.0, step=0.1, value=0.9)
|
62 |
+
|
63 |
+
st.session_state.max_tokens = st.slider(
|
64 |
+
label="New tokens to generate", min_value = 64, max_value=1048, step= 123, value=256
|
65 |
+
)
|
66 |
+
|
67 |
+
st.session_state.repetion_penalty = st.slider(
|
68 |
+
label="Repetion Penalty", min_value=0., max_value=1., step=0.1, value=1.
|
69 |
+
)
|
70 |
+
|
71 |
st.markdown("---")
|
72 |
+
|
73 |
st.markdown("# Retrieval Settings")
|
74 |
st.slider(label="Documents to retrieve",
|
75 |
min_value=1, max_value=10, value=3)
|
76 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
st.info("**2023 ©️ Pragnesh Barik**")
|
78 |
|
79 |
|
|
|
91 |
st.markdown(message["content"])
|
92 |
|
93 |
|
94 |
+
if prompt := st.chat_input("Chat with Ikigai Docs..."):
|
95 |
st.chat_message("user").markdown(prompt)
|
96 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
97 |
|
98 |
+
# st.write("ing")
|
99 |
tick = time.time()
|
100 |
+
with st.spinner("Generating response...") :
|
101 |
+
response = mistral(prompt, st.session_state.history,
|
102 |
+
temperature=st.session_state.temp, max_new_tokens=st.session_state.max_tokens)
|
103 |
tock = time.time()
|
104 |
|
105 |
st.session_state.inference_time.append(tock - tick)
|
106 |
+
|
107 |
response = response.replace("</s>", "")
|
108 |
len_response = len(response.split())
|
109 |
|