Spaces:
Runtime error
Runtime error
File size: 735 Bytes
0e59554 da174c1 0e59554 c15f856 da174c1 c15f856 0e59554 |
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 |
from utils import create_index, get_agent_chain, get_prompt_and_tools, get_search_index
question_starters = ['who', 'why', 'what', 'how', 'where', 'when', 'which', 'whom', 'whose']
def index():
create_index()
return True
def run(question):
index = get_search_index()
prompt, tools = get_prompt_and_tools()
agent_chain = get_agent_chain(prompt, tools)
result = None
try:
result = agent_chain.run(question)
except ValueError as ve:
if "Could not parse LLM output:" in ve.args[0] and question.lower().startswith(tuple(question_starters)) and not question.lower().endswith('?'):
question = question + '?'
result = agent_chain.run(question)
return result
|