Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -114,9 +114,9 @@ prompt_templates = {"All Needs Experts": "Respond as if you are combination of a
|
|
114 |
actor_description = {"All Needs Experts": "<div style='float: left;margin: 0px 5px 0px 5px;'><img src='https://na.weshareresearch.com/wp-content/uploads/2023/04/experts2.jpg' alt='needs expert image' style='width:70px;align:top;'></div>A combination of all needs assessment experts."}
|
115 |
|
116 |
|
117 |
-
from huggingface_hub import
|
118 |
|
119 |
-
api =
|
120 |
response = api(inputs="test sentence")
|
121 |
|
122 |
print("API response:", response)
|
@@ -618,7 +618,7 @@ def get_chat_response(prompt):
|
|
618 |
completion = chain.invoke({"question": prompt})
|
619 |
|
620 |
# Extract only the relevant chatbot response (not full structure)
|
621 |
-
return completion
|
622 |
|
623 |
|
624 |
|
@@ -649,16 +649,20 @@ def submit_message(prompt, prompt_template, temperature, max_tokens, context_len
|
|
649 |
completion = { "content": completion }
|
650 |
|
651 |
print("Prompt/question:", prompt)
|
652 |
-
answer = completion['content']['answer']
|
|
|
|
|
653 |
print("Answer:", answer)
|
654 |
print("Embeddings utlized:")
|
655 |
-
|
656 |
-
for document in completion['content']['source_documents']:
|
|
|
657 |
page_content = document.page_content # Use dot notation to access an attribute
|
658 |
print("Embedding_content:", page_content)
|
659 |
metadata = document.metadata # Use dot notation to access an attribute
|
660 |
print("Metadata:", metadata)
|
661 |
-
similarity_score = document.state
|
|
|
662 |
print("Similarity_score:", similarity_score)
|
663 |
print("")
|
664 |
|
|
|
114 |
actor_description = {"All Needs Experts": "<div style='float: left;margin: 0px 5px 0px 5px;'><img src='https://na.weshareresearch.com/wp-content/uploads/2023/04/experts2.jpg' alt='needs expert image' style='width:70px;align:top;'></div>A combination of all needs assessment experts."}
|
115 |
|
116 |
|
117 |
+
from huggingface_hub import InferenceClient
|
118 |
|
119 |
+
api = InferenceClient(repo_id="sentence-transformers/all-MiniLM-L6-v2", token=HF_key)
|
120 |
response = api(inputs="test sentence")
|
121 |
|
122 |
print("API response:", response)
|
|
|
618 |
completion = chain.invoke({"question": prompt})
|
619 |
|
620 |
# Extract only the relevant chatbot response (not full structure)
|
621 |
+
return completion
|
622 |
|
623 |
|
624 |
|
|
|
649 |
completion = { "content": completion }
|
650 |
|
651 |
print("Prompt/question:", prompt)
|
652 |
+
#answer = completion['content']['answer']
|
653 |
+
answer = completion.get('answer', '')
|
654 |
+
|
655 |
print("Answer:", answer)
|
656 |
print("Embeddings utlized:")
|
657 |
+
source_documents = completion.get('source_documents', [])
|
658 |
+
#for document in completion['content']['source_documents']:
|
659 |
+
for document in source_documents:
|
660 |
page_content = document.page_content # Use dot notation to access an attribute
|
661 |
print("Embedding_content:", page_content)
|
662 |
metadata = document.metadata # Use dot notation to access an attribute
|
663 |
print("Metadata:", metadata)
|
664 |
+
similarity_score = document.state.get('query_similarity_score', 0)
|
665 |
+
#similarity_score = document.state['query_similarity_score']
|
666 |
print("Similarity_score:", similarity_score)
|
667 |
print("")
|
668 |
|