Spaces:
Sleeping
Sleeping
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 lines567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545511 unmodified lines6768697071727374757677787980818283848586874 unmodified linesimport timeif "messages" not in st.session_state:st.session_state.messages = []if "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 "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**")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"])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"]with st.chat_message("assistant"):st.markdown(response)st.session_state.history.append([prompt, response])st.session_state.messages.append({"role": "assistant", "content": response})4 unmodified lines567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575811 unmodified lines7071727374757677787980818283848586878889904 unmodified linesimport timeif "messages" not in st.session_state:st.session_state.messages = []if "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**")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"])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"]with st.chat_message("assistant"):st.markdown(response)st.session_state.history.append([prompt, response])st.session_state.messages.append({"role": "assistant", "content": response})
41 unmodified lines42434445464741 unmodified linesfor response in stream:# print(response)output += response.token["text"]# yield outputreturn output41 unmodified lines42434445464741 unmodified linesfor response in stream:# print(response)output += response.token.text# yield outputreturn output
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091altair==5.1.2attrs==23.1.0av==10.0.0bitarray==2.8.1blinker==1.6.3cachetools==5.3.1huggingface-hub==0.16.4certifi==2023.7.22charset-normalizer==3.2.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.3gitdb==4.0.10GitPython==3.1.37glob2==0.7greenlet==2.0.2huggingface-hub==0.16.4humanfriendly==10.0idna==3.4importlib-metadata==6.8.0jaraco.classes==3.3.0Jinja2==3.1.2joblib==1.3.2jsonschema==4.19.1jsonschema-specifications==2023.7.1keyring==24.2.0llvmlite==0.40.1markdown-it-py==3.0.0MarkupSafe==2.1.3mdurl==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==20230314pandas==2.1.1Pillow==10.0.0pkginfo==1.9.6protobuf==4.24.3pyarrow==13.0.0pydeck==0.8.1b0PyPDF2==3.0.1pyreadline3==3.4.1python-dotenv==1.0.0pytz==2023.3.post1readme-renderer==42.0referencing==0.30.2regex==2023.8.8requests==2.31.0requests-toolbelt==1.0.0rfc3986==2.0.0rich==13.5.2rpds-py==0.10.4safetensors==0.3.3scikit-learn==1.3.0scipy==1.11.2sentence-transformers==2.2.2sentencepiece==0.1.99smmap==5.0.1SQLAlchemy==2.0.20streamlit==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.2tqdm==4.66.1transformers==4.32.1twine==4.0.2typing_extensions==4.7.1tzdata==2023.3tzlocal==5.1urllib3==2.0.4validators==0.22.0watchdog==3.0.0zipp==3.16.212345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576altair==5.1.2asttokens==2.2.1attrs==23.1.0backcall==0.2.0blinker==1.6.3cachetools==5.3.1certifi==2023.7.22charset-normalizer==3.3.0click==8.1.7colorama==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.37huggingface-hub==0.18.0idna==3.4importlib-metadata==6.8.0ipykernel==6.23.3ipython==8.14.0jedi==0.18.2Jinja2==3.1.2jsonschema==4.19.1jsonschema-specifications==2023.7.1jupyter_client==8.3.0jupyter_core==5.3.1markdown-it-py==3.0.0MarkupSafe==2.1.3matplotlib-inline==0.1.6mdurl==0.1.2nest-asyncio==1.5.6numpy==1.26.0packaging==23.1pandas==2.1.1parso==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.1b0Pygments==2.15.1python-dateutil==2.8.2python-dotenv==1.0.0pytz==2023.3.post1pywin32==306PyYAML==6.0.1pyzmq==25.1.0referencing==0.30.2requests==2.31.0rich==13.6.0rpds-py==0.10.4six==1.16.0smmap==5.0.1stack-data==0.6.2streamlit==1.27.2tenacity==8.2.3toml==0.10.2toolz==0.12.0tornado==6.3.2tqdm==4.66.1traitlets==5.9.0typing_extensions==4.8.0tzdata==2023.3tzlocal==5.1urllib3==2.0.6validators==0.22.0watchdog==3.0.0wcwidth==0.2.6zipp==3.17.0
app.py+27-24
mistral7b.py+1-1
requirements.txt+42-57