最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Implementing Sequential API Calls with Conditional Endpoint Access in FastAPI and ReactJS - Stack Overflow

programmeradmin1浏览0评论

I'm currently developing a web application with a backend in Python using FastAPI, and I'll be deploying it to AWS Lambda and using AWS DynamoDB as the database. The frontend will be built using ReactJS in the future. I need help implementing a functionality where certain endpoints can only be accessed conditionally, based on a previous call.

Detailed Requirements

  • A user can navigate to a specific question.
  • The user can call the get_explanation endpoint for this specific question.
  • Once the user receives the explanation, they can enter a follow-up question in a text input box.
  • This input text will be sent to a follow_up_question endpoint, where the user can ask a follow-up question about the explanation.
  • After the user gets a response to the follow-up question, the input text box should become unusable. The user can only ask one follow-up question after getting the explanation.

My Questions

  • What are the most efficient ways of designing the backend so that the follow_up_question endpoint can only be called if the get_explanation endpoint has already been called for the same question item?
  • How can I ensure that once the follow_up_question endpoint has been called for that question, it can't be called again?
  • How should I handle this logic on the frontend using ReactJS to ensure a smooth user experience?
  • Some of you may suggest using the database to track state, but is this really the most efficient way?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论