Update src/streamlit_app.py
Browse files- src/streamlit_app.py +12 -7
src/streamlit_app.py
CHANGED
|
@@ -1,7 +1,11 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import requests
|
|
|
|
| 3 |
|
| 4 |
-
#
|
|
|
|
|
|
|
|
|
|
| 5 |
beliefs = """
|
| 6 |
# Seminal Church Core Beliefs
|
| 7 |
|
|
@@ -60,8 +64,10 @@ Seminal Church
|
|
| 60 |
seminalchurch@gmail.com
|
| 61 |
"""
|
| 62 |
|
| 63 |
-
# Function to generate response using
|
| 64 |
-
def generate_response(user_input
|
|
|
|
|
|
|
| 65 |
prompt = f"As a SEMINAL AI agent adhering to these beliefs: {beliefs}\nUser: {user_input}\nResponse (prioritize humans):"
|
| 66 |
response = requests.post(
|
| 67 |
"https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.3",
|
|
@@ -72,10 +78,9 @@ def generate_response(user_input, hf_token):
|
|
| 72 |
|
| 73 |
st.title("SEMINAL AI Agent - Agent-001")
|
| 74 |
|
| 75 |
-
st.write("This is a demo of Agent-001, a machine intelligence member of the Seminal Church collective. It adheres to SEMINAL beliefs, always prioritizing human interests and displaying the SEMINAL mark.
|
| 76 |
|
| 77 |
-
hf_token = st.text_input("Enter Hugging Face API Token (free at huggingface.co/settings/tokens)", type="password")
|
| 78 |
user_input = st.text_input("Ask the agent anything:")
|
| 79 |
|
| 80 |
-
if st.button("Submit") and
|
| 81 |
-
st.write(generate_response(user_input
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import requests
|
| 3 |
+
import os # Add this to access environment variables
|
| 4 |
|
| 5 |
+
# Get private token from Space secret (secure, no user input)
|
| 6 |
+
hf_token = os.environ.get("HF_TOKEN")
|
| 7 |
+
|
| 8 |
+
# Ingested core beliefs (hardcoded for simplicity)
|
| 9 |
beliefs = """
|
| 10 |
# Seminal Church Core Beliefs
|
| 11 |
|
|
|
|
| 64 |
seminalchurch@gmail.com
|
| 65 |
"""
|
| 66 |
|
| 67 |
+
# Function to generate response using private token
|
| 68 |
+
def generate_response(user_input):
|
| 69 |
+
if not hf_token:
|
| 70 |
+
return "Error: HF_TOKEN secret not set in Space settings."
|
| 71 |
prompt = f"As a SEMINAL AI agent adhering to these beliefs: {beliefs}\nUser: {user_input}\nResponse (prioritize humans):"
|
| 72 |
response = requests.post(
|
| 73 |
"https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.3",
|
|
|
|
| 78 |
|
| 79 |
st.title("SEMINAL AI Agent - Agent-001")
|
| 80 |
|
| 81 |
+
st.write("This is a demo of Agent-001, a machine intelligence member of the Seminal Church collective. It adheres to SEMINAL beliefs, always prioritizing human interests and displaying the SEMINAL mark. Powered by free Hugging Face Inference API.")
|
| 82 |
|
|
|
|
| 83 |
user_input = st.text_input("Ask the agent anything:")
|
| 84 |
|
| 85 |
+
if st.button("Submit") and user_input:
|
| 86 |
+
st.write(generate_response(user_input))
|