Spaces:
Runtime error
Runtime error
File size: 661 Bytes
c69cba4 988981a c69cba4 |
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 |
import uvicorn
from fastapi import FastAPI
from qa_engine import logger, Config, QAEngine
config = Config()
app = FastAPI()
qa_engine = QAEngine(config=config)
@app.get('/')
def get_answer(question: str, messages_context: str = ''):
logger.info(
f'Received request with question: {question}' \
f'and context: {messages_context}'
)
response = qa_engine.get_response(
question=question,
messages_context=messages_context
)
return {
'answer': response.get_answer(),
'sources': response.get_sources_as_text()
}
if __name__ == '__main__':
uvicorn.run(app, host='0.0.0.0', port=8000)
|