Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ from langchain_community.embeddings import HuggingFaceEmbeddings
|
|
| 6 |
from langchain_huggingface import HuggingFaceEndpoint
|
| 7 |
from langchain.prompts import PromptTemplate
|
| 8 |
from langchain.chains import LLMChain, RetrievalQA
|
| 9 |
-
from huggingface_hub import login
|
| 10 |
|
| 11 |
# Login to Hugging Face
|
| 12 |
login(token=st.secrets["HF_TOKEN"])
|
|
@@ -75,10 +75,6 @@ def chatbot_response(user_input):
|
|
| 75 |
response = qa.run(user_input)
|
| 76 |
return response
|
| 77 |
|
| 78 |
-
# Initialize the repository
|
| 79 |
-
repo_id = "mery22/testing" # Replace with your repo ID
|
| 80 |
-
repo = Repository(local_dir=".", clone_from=repo_id, token=st.secrets["HF_TOKEN"])
|
| 81 |
-
|
| 82 |
# Define function to save feedback to CSV
|
| 83 |
def save_feedback(question, response, rating, comment):
|
| 84 |
try:
|
|
@@ -93,9 +89,6 @@ def save_feedback(question, response, rating, comment):
|
|
| 93 |
writer.writeheader()
|
| 94 |
writer.writerow({'question': question, 'response': response, 'rating': rating, 'comment': comment})
|
| 95 |
|
| 96 |
-
# Push the updated file to the Hugging Face repository
|
| 97 |
-
repo.push_to_hub(commit_message="Updated feedback")
|
| 98 |
-
|
| 99 |
st.success("Thank you for your feedback! It has been saved.")
|
| 100 |
except Exception as e:
|
| 101 |
st.error(f"Error saving feedback: {e}")
|
|
|
|
| 6 |
from langchain_huggingface import HuggingFaceEndpoint
|
| 7 |
from langchain.prompts import PromptTemplate
|
| 8 |
from langchain.chains import LLMChain, RetrievalQA
|
| 9 |
+
from huggingface_hub import login
|
| 10 |
|
| 11 |
# Login to Hugging Face
|
| 12 |
login(token=st.secrets["HF_TOKEN"])
|
|
|
|
| 75 |
response = qa.run(user_input)
|
| 76 |
return response
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
# Define function to save feedback to CSV
|
| 79 |
def save_feedback(question, response, rating, comment):
|
| 80 |
try:
|
|
|
|
| 89 |
writer.writeheader()
|
| 90 |
writer.writerow({'question': question, 'response': response, 'rating': rating, 'comment': comment})
|
| 91 |
|
|
|
|
|
|
|
|
|
|
| 92 |
st.success("Thank you for your feedback! It has been saved.")
|
| 93 |
except Exception as e:
|
| 94 |
st.error(f"Error saving feedback: {e}")
|