Skip to content

Commit

Permalink
[DH-4983] Document response endpoint in Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jcjc712 committed Nov 10, 2023
1 parent 6b019cb commit 9af213d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,23 @@ curl -X 'POST' \
}'
```

### Create new response based on a previously created question
After utilizing the `questions` endpoint, you have the option to generate a new response associated with a specific question_id.
You can modify the `sql_query` to produce an alternative `sql_query_result` and a distinct response. In the event that you do not
specify a `sql_query`, the system will reprocess the question to generate the `sql_query`, execute the `sql_query_result`, and subsequently
generate the response.

```
curl -X 'POST' \
'<host>/api/v1/responses?run_evaluator=true&sql_response_only=false&generate_csv=false' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"question_id": "11fa1e419fe93d137536fe99",
"sql_query": "select * from sales order by created_at DESC limit 10"
}'
```

### Run scripts
Within the `scripts` folder located inside the `dataherald` directory, you have the ability to upgrade your versions.
For instance, if you are currently using version 0.0.3 and wish to switch to version 0.0.4, simply execute the following command:
Expand Down
3 changes: 3 additions & 0 deletions dataherald/api/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ def create_response(
question_repository = QuestionRepository(self.storage)
response_repository = ResponseRepository(self.storage)
user_question = question_repository.find_by_id(query_request.question_id)
if not user_question:
raise HTTPException(status_code=404, detail="Question not found")

db_connection_repository = DatabaseConnectionRepository(self.storage)
database_connection = db_connection_repository.find_by_id(
user_question.db_connection_id
Expand Down

0 comments on commit 9af213d

Please sign in to comment.