Spaces:
Runtime error
Runtime error
Commit ·
6c6516f
1
Parent(s): 99ff44d
improved dependancies
Browse filesFiles changed (3)
- app.py+27-24
- mistral7b.py+1-1
- requirements.txt+42-57
4 unmodified lines56788910121112131514151617191819202221222425232425262827282931303132333435363839373839404142434344454647464748495051525354555256575811 unmodified lines7071727073747275767778757980818283808182848586878885868789904 unmodified linesimport time
if "messages" not in st.session_state: st.session_state.messages = []
if "tokens_used" not in st.session_state :if "tokens_used" not in st.session_state: st.session_state.tokens_used = 0
if "inference_time" not in st.session_state :if "inference_tipipme" not in st.session_state: st.session_state.inference_time = [0.00]
if "temp" not in st.session_state :if "temp" not in st.session_state: st.session_state.temp = 0.8
if "model_settings" not in st.session_state :if "model_settings" not in st.session_state: st.session_state.model_settings = { "temp" : 0.9, "max_tokens" : 512, "temp": 0.9, "max_tokens": 512, }
if "history" not in st.session_state :if "history" not in st.session_state: st.session_state.history = []
if "top_k" not in st.session_state :if "top_k" not in st.session_state: st.session_state.top_k = 5
with 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.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.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) 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**")
st.image("ikigai.svg")st.title("Ikigai Chat")
11 unmodified linesif 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"]) 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())
st.session_state["tokens_used"] = len_response + \ st.session_state["tokens_used"] = len_response + st.session_state["tokens_used"] with st.chat_message("assistant"): st.session_state["tokens_used"]
with st.chat_message("assistant"): st.markdown(response) st.session_state.history.append([prompt, response]) st.session_state.messages.append({"role": "assistant", "content": response})
st.session_state.messages.append( {"role": "assistant", "content": response})41 unmodified lines4243444545464741 unmodified lines
for response in stream: # print(response) output += response.token["text"] output += response.token.text # yield output return output1233445677989111213141516171810111213141516171821222319242021272223242529262732332829303132333738394041424344454634353637484950383940414243444546475354484950515752535455595661626357586566676869596071616273637576776465808166678384856869707188727374759176altair==5.1.2asttokens==2.2.1attrs==23.1.0av==10.0.0bitarray==2.8.1backcall==0.2.0blinker==1.6.3cachetools==5.3.1huggingface-hub==0.16.4certifi==2023.7.22charset-normalizer==3.2.0charset-normalizer==3.3.0click==8.1.7coloredlogs==15.0.1ctranslate2==3.19.0docutils==0.20.1filelock==3.12.3flatbuffers==23.5.26fsspec==2023.6.0ftfy==6.1.1future==0.18.3colorama==0.4.6comm==0.1.3debugpy==1.6.7decorator==5.1.1executing==1.2.0filelock==3.12.4fsspec==2023.9.2gitdb==4.0.10GitPython==3.1.37glob2==0.7greenlet==2.0.2huggingface-hub==0.16.4huggingface-hub==0.18.0humanfriendly==10.0idna==3.4importlib-metadata==6.8.0jaraco.classes==3.3.0ipykernel==6.23.3ipython==8.14.0jedi==0.18.2Jinja2==3.1.2joblib==1.3.2jsonschema==4.19.1jsonschema-specifications==2023.7.1keyring==24.2.0llvmlite==0.40.1jupyter_client==8.3.0jupyter_core==5.3.1markdown-it-py==3.0.0MarkupSafe==2.1.3matplotlib-inline==0.1.6mdurl==0.1.2mmh3==4.0.1more-itertools==10.1.0mpmath==1.3.0networkx==3.1nh3==0.2.14nltk==3.8.1numba==0.57.1numpy==1.24.4onnxruntime==1.15.1openai-whisper==20230314nest-asyncio==1.5.6numpy==1.26.0packaging==23.1pandas==2.1.1Pillow==10.0.0pkginfo==1.9.6protobuf==4.24.3parso==0.8.3pickleshare==0.7.5Pillow==10.0.1platformdirs==3.8.0prompt-toolkit==3.0.38protobuf==4.24.4psutil==5.9.5pure-eval==0.2.2pyarrow==13.0.0pydeck==0.8.1b0PyPDF2==3.0.1pyreadline3==3.4.1Pygments==2.15.1python-dateutil==2.8.2python-dotenv==1.0.0pytz==2023.3.post1readme-renderer==42.0pywin32==306PyYAML==6.0.1pyzmq==25.1.0referencing==0.30.2regex==2023.8.8requests==2.31.0requests-toolbelt==1.0.0rfc3986==2.0.0rich==13.5.2rich==13.6.0rpds-py==0.10.4safetensors==0.3.3scikit-learn==1.3.0scipy==1.11.2sentence-transformers==2.2.2sentencepiece==0.1.99six==1.16.0smmap==5.0.1SQLAlchemy==2.0.20stack-data==0.6.2streamlit==1.27.2sympy==1.12tenacity==8.2.3threadpoolctl==3.2.0tiktoken==0.3.1tokenizers==0.13.3toml==0.10.2toolz==0.12.0torch==2.0.1torchvision==0.15.2tornado==6.3.2tqdm==4.66.1transformers==4.32.1twine==4.0.2typing_extensions==4.7.1traitlets==5.9.0typing_extensions==4.8.0tzdata==2023.3tzlocal==5.1urllib3==2.0.4urllib3==2.0.6validators==0.22.0watchdog==3.0.0wcwidth==0.2.6zipp==3.16.2zipp==3.17.0app.py+27-24
mistral7b.py+1-1
requirements.txt+42-57