Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import wikipediaapi
|
4 |
-
import os #
|
5 |
|
6 |
-
#
|
7 |
HUGGINGFACE_API_KEY = os.getenv("HUGGINGFACE_API_KEY")
|
8 |
|
9 |
if not HUGGINGFACE_API_KEY:
|
@@ -24,9 +24,9 @@ def chat_with_ai(person_name, user_input):
|
|
24 |
context = get_wikipedia_summary(person_name)
|
25 |
prompt = f"You are {person_name}. Based on this historical information: {context}\\n\\nUser: {user_input}\\n{person_name}:"
|
26 |
|
27 |
-
API_URL = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B"
|
28 |
headers = {"Authorization": f"Bearer {HUGGINGFACE_API_KEY}"}
|
29 |
-
|
30 |
response = requests.post(API_URL, headers=headers, json={"inputs": prompt})
|
31 |
|
32 |
if response.status_code == 200:
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import wikipediaapi
|
4 |
+
import os # For accessing environment variables
|
5 |
|
6 |
+
# Securely fetch Hugging Face API key from environment variables
|
7 |
HUGGINGFACE_API_KEY = os.getenv("HUGGINGFACE_API_KEY")
|
8 |
|
9 |
if not HUGGINGFACE_API_KEY:
|
|
|
24 |
context = get_wikipedia_summary(person_name)
|
25 |
prompt = f"You are {person_name}. Based on this historical information: {context}\\n\\nUser: {user_input}\\n{person_name}:"
|
26 |
|
27 |
+
API_URL = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.1"
|
28 |
headers = {"Authorization": f"Bearer {HUGGINGFACE_API_KEY}"}
|
29 |
+
|
30 |
response = requests.post(API_URL, headers=headers, json={"inputs": prompt})
|
31 |
|
32 |
if response.status_code == 200:
|