Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ if not HF_API_TOKEN:
|
|
10 |
# Hugging Face API URLs and headers for Gemma models
|
11 |
GEMMA_7B_API_URL = "https://api-inference.huggingface.co/models/google/gemma-1.1-7b-it"
|
12 |
GEMMA_27B_API_URL = "https://api-inference.huggingface.co/models/google/gemma-2-27b-it"
|
|
|
13 |
|
14 |
HEADERS = {"Authorization": f"Bearer {HF_API_TOKEN}"}
|
15 |
|
@@ -29,10 +30,10 @@ st.write("Gemma Chatbot Interface")
|
|
29 |
if "conversation" not in st.session_state:
|
30 |
st.session_state.conversation = []
|
31 |
if "model_history" not in st.session_state:
|
32 |
-
st.session_state.model_history = {model: [] for model in ["Gemma-1.1-7B", "Gemma-2-27B"]}
|
33 |
|
34 |
# Dropdown for Gemma model selection
|
35 |
-
gemma_selection = st.selectbox("Select Gemma Model", ["Gemma-1.1-7B", "Gemma-2-27B"])
|
36 |
|
37 |
# User input for question
|
38 |
question = st.text_input("Question", placeholder="Enter your question here...")
|
@@ -46,6 +47,8 @@ if st.button("Send") and question:
|
|
46 |
response = query_model(GEMMA_7B_API_URL, {"inputs": chat_history})
|
47 |
elif gemma_selection == "Gemma-2-27B":
|
48 |
response = query_model(GEMMA_27B_API_URL, {"inputs": chat_history})
|
|
|
|
|
49 |
|
50 |
answer = response.get("generated_text", "No response") if isinstance(response, dict) else response[0].get("generated_text", "No response") if isinstance(response, list) else "No response"
|
51 |
add_message_to_conversation(question, answer, gemma_selection)
|
|
|
10 |
# Hugging Face API URLs and headers for Gemma models
|
11 |
GEMMA_7B_API_URL = "https://api-inference.huggingface.co/models/google/gemma-1.1-7b-it"
|
12 |
GEMMA_27B_API_URL = "https://api-inference.huggingface.co/models/google/gemma-2-27b-it"
|
13 |
+
CODEGEMMA_7B_API_URL = "https://api-inference.huggingface.co/models/google/codegemma-7b"
|
14 |
|
15 |
HEADERS = {"Authorization": f"Bearer {HF_API_TOKEN}"}
|
16 |
|
|
|
30 |
if "conversation" not in st.session_state:
|
31 |
st.session_state.conversation = []
|
32 |
if "model_history" not in st.session_state:
|
33 |
+
st.session_state.model_history = {model: [] for model in ["Gemma-1.1-7B", "Gemma-2-27B", "codegemma-7b"]}
|
34 |
|
35 |
# Dropdown for Gemma model selection
|
36 |
+
gemma_selection = st.selectbox("Select Gemma Model", ["Gemma-1.1-7B", "Gemma-2-27B", "codegemma-7b"])
|
37 |
|
38 |
# User input for question
|
39 |
question = st.text_input("Question", placeholder="Enter your question here...")
|
|
|
47 |
response = query_model(GEMMA_7B_API_URL, {"inputs": chat_history})
|
48 |
elif gemma_selection == "Gemma-2-27B":
|
49 |
response = query_model(GEMMA_27B_API_URL, {"inputs": chat_history})
|
50 |
+
elif gemma_selection == "codegemma-7b":
|
51 |
+
response = query_model(CODEGEMMA_7B_API_URL, {"inputs": chat_history})
|
52 |
|
53 |
answer = response.get("generated_text", "No response") if isinstance(response, dict) else response[0].get("generated_text", "No response") if isinstance(response, list) else "No response"
|
54 |
add_message_to_conversation(question, answer, gemma_selection)
|