Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,19 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import pipeline
|
3 |
|
4 |
-
# Configure the Hugging Face API key
|
5 |
HF_API_KEY = st.secrets['huggingface_api_key']
|
6 |
|
7 |
-
#
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Function to get response from the Hugging Face model
|
11 |
def get_chatbot_response(user_input):
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
+
# Configure the Hugging Face API key (no need to pass it in the pipeline call)
|
5 |
HF_API_KEY = st.secrets['huggingface_api_key']
|
6 |
|
7 |
+
# Ensure you're logged in using the Hugging Face CLI if using private models
|
8 |
+
# huggingface-cli login
|
9 |
+
|
10 |
+
# Initialize the Hugging Face model and tokenizer
|
11 |
+
model_name = 'gpt2-medium' # or another GPT-2 version you want to use
|
12 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
13 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
14 |
+
|
15 |
+
# Initialize the text generation pipeline
|
16 |
+
generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
|
17 |
|
18 |
# Function to get response from the Hugging Face model
|
19 |
def get_chatbot_response(user_input):
|