Spaces:
Build error
Build error
Commit ·
8b18fd0
1
Parent(s): 5c2e60f
engineered some prompt
Browse files1234563 unmodified lines10111213141516171819202122232425262728293031323334353637383940414243444546474849505152535411 unmodified lines66676869707172737475767778798081import streamlit as stfrom mistral7b import mistralimport time3 unmodified linesif "tokens_used" not in st.session_state:st.session_state.tokens_used = 0if "inference_tipipme" not in st.session_state:st.session_state.inference_time = [0.00]if "temp" not in st.session_state:st.session_state.temp = 0.8if "model_settings" not in st.session_state:st.session_state.model_settings = {"temp": 0.9,"max_tokens": 512,}if "history" not in st.session_state:st.session_state.history = []if "top_k" not in st.session_state:st.session_state.top_k = 5with st.sidebar:st.markdown("# Model Analytics")st.write("Tokens used :", st.session_state['tokens_used'])st.write("Average Inference Time: ", round(sum(st.session_state["inference_time"]) / len(st.session_state["inference_time"]), 3))st.write("Cost Incured :", round(0.033 * st.session_state['tokens_used'] / 1000, 3), "INR")st.markdown("---")st.markdown("# Retrieval Settings")st.slider(label="Documents to retrieve",min_value=1, max_value=10, value=3)st.markdown("---")st.markdown("# Model Settings")selected_model = st.sidebar.radio('Select one:', ["Mistral 7B", "GPT 3.5 Turbo", "GPT 4", "Llama 7B"])selected_temperature = st.slider(label="Temperature", min_value=0.0, max_value=1.0, step=0.1, value=0.5)st.write(" ")st.info("**2023 ©️ Pragnesh Barik**")11 unmodified linesst.markdown(message["content"])if prompt := st.chat_input("Chat with Ikigai Docs?"):st.chat_message("user").markdown(prompt)st.session_state.messages.append({"role": "user", "content": prompt})tick = time.time()response = mistral(prompt, st.session_state.history,temperature=st.session_state.model_settings["temp"], max_new_tokens=st.session_state.model_settings["max_tokens"])tock = time.time()st.session_state.inference_time.append(tock - tick)response = response.replace("</s>", "")len_response = len(response.split())123456789103 unmodified lines14151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787911 unmodified lines919293949596979899100101102103104105106107108109import streamlit as stfrom mistral7b import mistralst.set_page_config(page_title="Ikigai Chat",)import time3 unmodified linesif "tokens_used" not in st.session_state:st.session_state.tokens_used = 0if "inference_time" not in st.session_state:st.session_state.inference_time = [0.00]if "temp" not in st.session_state:st.session_state.temp = 0.8if "history" not in st.session_state:st.session_state.history = [["""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.Ikigai helps modern analysts and operations teams automate data-intensive business, finance, analytics, and supply-chain operations.The company's Inventory Ops automates inventory tracking and monitoring by creating a single, real-time view of inventory across all locations and channels.""","""Yes, you are correct. Ikigai Labs is a company that specializes in helpingmodern analysts and operations teams automate data-intensive business, finance, analytics,and supply chain operations. One of their products is Inventory Ops, which automates inventorytracking and monitoring by creating a single, real-time view of inventory across all locations and channels.This helps businesses optimize their inventory levels and reduce costs.Is there anything else you would like to know about Ikigai Labs or their products?"""]]if "top_k" not in st.session_state:st.session_state.top_k = 5if "repetion_penalty" not in st.session_state :st.session_state.repetion_penalty = 1with st.sidebar:st.markdown("# Model Analytics")st.write("Tokens used :", st.session_state['tokens_used'])st.write("Average Inference Time: ", round(sum(st.session_state["inference_time"]) / len(st.session_state["inference_time"]), 3), "Secs")st.write("Cost Incured :", round(0.033 * st.session_state['tokens_used'] / 1000, 3), "INR")st.markdown("---")st.markdown("# Model Settings")selected_model = st.sidebar.radio('Select one:', ["Mistral 7B","Llama 7B" ,"GPT 3.5 Turbo", "GPT 4" ])st.session_state.temp = st.slider(label="Temperature", min_value=0.0, max_value=1.0, step=0.1, value=0.9)st.session_state.max_tokens = st.slider(label="New tokens to generate", min_value = 64, max_value=1048, step= 123, value=256)st.session_state.repetion_penalty = st.slider(label="Repetion Penalty", min_value=0., max_value=1., step=0.1, value=1.)st.markdown("---")st.markdown("# Retrieval Settings")st.slider(label="Documents to retrieve",min_value=1, max_value=10, value=3)st.info("**2023 ©️ Pragnesh Barik**")11 unmodified linesst.markdown(message["content"])if prompt := st.chat_input("Chat with Ikigai Docs..."):st.chat_message("user").markdown(prompt)st.session_state.messages.append({"role": "user", "content": prompt})# st.write("ing")tick = time.time()with st.spinner("Generating response...") :response = mistral(prompt, st.session_state.history,temperature=st.session_state.temp, max_new_tokens=st.session_state.max_tokens)tock = time.time()st.session_state.inference_time.append(tock - tick)response = response.replace("</s>", "")len_response = len(response.split())
app.py+48-20