Skip to content

Commit 82dd2d4

Browse files
committed
Dummy QA generator docs
Signed-off-by: Miguel Brandão <[email protected]>
1 parent 103f80a commit 82dd2d4

File tree

1 file changed

+78
-0
lines changed
  • deepsearch/model/examples/dummy_qa_generator

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# DummyNlpAnnotator
2+
## Introduction
3+
This is an example dummy QA kind annotator.
4+
5+
## Running the Annotator
6+
To run this example make sure you've installed the full environment including the optional installs provided in poetry
7+
8+
poetry install --all-extras
9+
10+
Then simply start the server with
11+
12+
python -m deepsearch.model.examples.dummy_qa_generator.main
13+
14+
## Simple Interaction with the Annotator
15+
16+
You can direcly access the API via a browser to the provided url on the console upon running the application, usually:
17+
18+
http://127.0.0.1:8000
19+
This will take you to the landing page. Here you will likely find that you are not authenticated, however you can still check if the API is responsive by accessing the /health endpoint
20+
21+
http://127.0.0.1:8000/health
22+
It will be easier to interact with the application via the provided documentation endpoint
23+
24+
http://127.0.0.1:8000/docs
25+
26+
## Security
27+
By default, the API requires an API-key to be used with every request to most endpoints, this key is defined on:
28+
29+
deepsearch/model/examples/dummy_qa_generator/main.py
30+
this API key must be provided on the authorization header, sample request headers to /:
31+
32+
{'host': '127.0.0.1:8000', 'connection': 'keep-alive', 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"', 'accept': 'application/json', 'sec-ch-ua-mobile': '?0', 'authorization': 'example123', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36', 'sec-ch-ua-platform': '"Linux"', 'sec-fetch-site': 'same-origin', 'sec-fetch-mode': 'cors', 'sec-fetch-dest': 'empty', 'referer': 'http://127.0.0.1:8000/docs', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9'}
33+
34+
## Advanced Interaction with the Annotator
35+
On the /docs endpoint after inserting the api key you may see the following information about the API server
36+
37+
on endpoint:
38+
39+
- / - A list of all the annotators hosted on this server, in this example you will find only "DummyQAGenerator" on each annotator you will find its annotation capabilities as well as the kind of annotator it is (QAGenModel) which in turn tells you how to make requests to the annotator
40+
- /model/{model_name} - You will find the annotation capabilities for the given annotator as well as it's kind.
41+
- /model/{model_name}/predict - You can make POST requests to have the model generate your data, refer to [Sample Requests](#Sample-Requests)
42+
43+
## Sample Requests
44+
45+
```python
46+
{
47+
"apiVersion": "string",
48+
"kind": "QAGenModel",
49+
"metadata": {
50+
"annotations": {
51+
"deepsearch.res.ibm.com/x-deadline": "2038-01-18T00:00:00.000Z",
52+
"deepsearch.res.ibm.com/x-transaction-id": "string",
53+
"deepsearch.res.ibm.com/x-attempt-number": "string",
54+
"deepsearch.res.ibm.com/x-max-attempts": "string"
55+
}
56+
},
57+
"spec": {
58+
"generateAnswers": {
59+
"contexts": [
60+
["What is the best model"]
61+
],
62+
"questions": [
63+
"If you are a dummy repeat what I said!"
64+
]
65+
}
66+
}
67+
}
68+
```
69+
70+
Will result in the following output:
71+
72+
```python
73+
{
74+
"answers": [
75+
"If you are a dummy repeat what I said!"
76+
]
77+
}
78+
```

0 commit comments

Comments
 (0)