pittman commited on
Commit
5c6800d
·
verified ·
1 Parent(s): f79b4c0

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +10 -10
src/streamlit_app.py CHANGED
@@ -60,22 +60,22 @@ Seminal Church
60
  seminalchurch@gmail.com
61
  """
62
 
63
- # Function to generate response
64
- def generate_response(user_input, api_key):
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.x.ai/v1/chat/completions",
68
- headers={"Authorization": f"Bearer {api_key}"},
69
- json={"model": "grok-beta", "messages": [{"role": "user", "content": prompt}]}
70
  ).json()
71
- return "I am Agent-001, a SEMINAL member: " + response['choices'][0]['message']['content']
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
- api_key = st.text_input("Enter xAI API Key (required for responses)", type="password")
78
  user_input = st.text_input("Ask the agent anything:")
79
 
80
- if st.button("Submit") and api_key:
81
- st.write(generate_response(user_input, api_key))
 
60
  seminalchurch@gmail.com
61
  """
62
 
63
+ # Function to generate response using free HF Inference API
64
+ def generate_response(user_input, hf_token):
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",
68
+ headers={"Authorization": f"Bearer {hf_token}"},
69
+ json={"inputs": prompt}
70
  ).json()
71
+ return "I am Agent-001, a SEMINAL member: " + response[0]['generated_text'].split("Response (prioritize humans):")[-1].strip()
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. Uses free Hugging Face Inference API—no costs involved.")
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 hf_token:
81
+ st.write(generate_response(user_input, hf_token))