Spaces:
Runtime error
Runtime error
File size: 890 Bytes
93e630a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
"""
Custom Langchain tool to ask human
"""
import time
import streamlit as st
from langchain.tools.base import BaseTool
class CustomAskHumanTool(BaseTool):
"""Tool that asks user for input."""
name = "AskHuman"
description = """Use this tool if you don't find a specific answer using KendraRetrievalTool.\
Ask the human to clarify the question or provide the missing information.\
The input should be a question for the human."""
def _run(
self,
query: str,
run_manager=None,
) -> str:
if "user_answer" not in st.session_state:
answer_container = st.chat_message("assistant", avatar="🦜")
answer_container.write(query)
answer = st.text_input("Enter your answer", key="user_answer")
while answer == "":
time.sleep(1)
return st.session_state["user_answer"]
|