|
import streamlit as st |
|
from gradio_client import Client |
|
|
|
|
|
TITLE = "Llama2 70B Chatbot" |
|
DESCRIPTION = """ |
|
This Space demonstrates model [Llama-2-70b-chat-hf](https://huggingface.co/meta-llama/Llama-2-70b-chat-hf) by Meta, |
|
a Llama 2 model with 70B parameters fine-tuned for chat instructions. |
|
""" |
|
|
|
|
|
client = Client("https://ysharma-explore-llamav2-with-tgi.hf.space/") |
|
|
|
|
|
def predict(message, system_prompt="", temperature=0.9, max_new_tokens=4096): |
|
return client.predict( |
|
message, |
|
system_prompt, |
|
temperature, |
|
max_new_tokens, |
|
0.3, |
|
1, |
|
api_name="/chat" |
|
) |
|
|
|
|
|
st.title(TITLE) |
|
st.write(DESCRIPTION) |
|
|
|
prompt = st.chat_input("Ask llama 2...") |
|
if prompt: |
|
with st.chat_message("assistant"): |
|
st.write(prompt) |
|
with st.chat_message("llama", avatar='🦙'): |
|
st.write(predict(prompt, '',0.7,4096)) |
|
|