Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,8 @@ import uuid
|
|
| 4 |
from huggingface_hub import InferenceClient
|
| 5 |
|
| 6 |
# Initialize the HuggingFace inference client
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
INIT_PROMPT = """
|
| 10 |
\n\nHuman: You are DarijaBot, a helpful assistant that can converse in both Latin and Arabic alphabet Darija. You will help the users learn about Wardley Mapping.
|
|
@@ -41,7 +42,7 @@ st.sidebar.markdown("Using HuggingFaceH4/zephyr-7b-beta API")
|
|
| 41 |
st.sidebar.markdown(st.session_state.session_id)
|
| 42 |
st.sidebar.divider()
|
| 43 |
|
| 44 |
-
#
|
| 45 |
user_huggingface_api_key = st.sidebar.text_input("Enter your HuggingFace API Key:", placeholder="hf_...", type="password")
|
| 46 |
|
| 47 |
if "messages" not in st.session_state:
|
|
@@ -52,7 +53,7 @@ if "all_prompts" not in st.session_state:
|
|
| 52 |
st.session_state["all_prompts"] = INIT_PROMPT + TRAINING_PROMPT
|
| 53 |
|
| 54 |
if user_huggingface_api_key:
|
| 55 |
-
client =
|
| 56 |
else:
|
| 57 |
st.warning("Please enter your HuggingFace API key", icon="⚠️")
|
| 58 |
|
|
|
|
| 4 |
from huggingface_hub import InferenceClient
|
| 5 |
|
| 6 |
# Initialize the HuggingFace inference client
|
| 7 |
+
def initialize_client(api_key):
|
| 8 |
+
return InferenceClient(model="HuggingFaceH4/zephyr-7b-beta", token=api_key)
|
| 9 |
|
| 10 |
INIT_PROMPT = """
|
| 11 |
\n\nHuman: You are DarijaBot, a helpful assistant that can converse in both Latin and Arabic alphabet Darija. You will help the users learn about Wardley Mapping.
|
|
|
|
| 42 |
st.sidebar.markdown(st.session_state.session_id)
|
| 43 |
st.sidebar.divider()
|
| 44 |
|
| 45 |
+
# Prompt the user for the API key
|
| 46 |
user_huggingface_api_key = st.sidebar.text_input("Enter your HuggingFace API Key:", placeholder="hf_...", type="password")
|
| 47 |
|
| 48 |
if "messages" not in st.session_state:
|
|
|
|
| 53 |
st.session_state["all_prompts"] = INIT_PROMPT + TRAINING_PROMPT
|
| 54 |
|
| 55 |
if user_huggingface_api_key:
|
| 56 |
+
client = initialize_client(user_huggingface_api_key)
|
| 57 |
else:
|
| 58 |
st.warning("Please enter your HuggingFace API key", icon="⚠️")
|
| 59 |
|