cohere-ai / sandbox-grounded-qa

A sandbox repo for grounded question answering with Cohere and Google Search
MIT License
136 stars 17 forks source link

REST Demo #5

Closed michaelwechner closed 1 year ago

michaelwechner commented 1 year ago

I would like to suggest to develop a minimal web service / REST demo, e.g. rest_demo.py using for example Flask

from flask import Flask
from flask_swagger_ui import get_swaggerui_blueprint

which would allow other applications/services to integrate grounded-qa using REST.

WDYT?

nickfrosst commented 1 year ago

oh that would be great!

michaelwechner commented 1 year ago

I wrote a prototype

https://github.com/wyona/sandbox-grounded-qa/blob/michael_main/rest_demo.py

which can be called with

curl --request POST --url http://localhost:5007/api/v1/ask --header 'content-type: application/json' --data '{ "question":"What is the capital of Brazil?" }'

and the response will be

{"answer":"Brasilia\nSource:\nhttps://en.wikipedia.org/wiki/Capitals_of_Brazil\nhttps://www.mappr.co/capital-cities/brazil/","relevant_paragraphs":"TODO_PARA","source":"TODO_SOURCE"}

Whereas I think it would be good to extend it, such that one can provide a "site URL" optionally, e.g.

curl --request POST --url http://localhost:5007/api/v1/ask --header 'content-type: application/json' --data '{ "question":"What is the capital of Brazil?","site-url":"https://www.wikipedia.org/" }'

and also that the response returns the relevant paragraphs and source URLs separately.

nickfrosst commented 1 year ago

this is great! want to make a pr?

nickfrosst commented 1 year ago

you can get the award for first open source contribution!

michaelwechner commented 1 year ago

Thanks! Will be happy to do a PR :-)

michaelwechner commented 1 year ago

I have now also dockerized the REST demo and seems to work fine :-)

https://github.com/wyona/sandbox-grounded-qa/blob/michael_main/Dockerfile

There is something strange with the logging though, because part of it seems to get "lost", whereas will try to fix it.

Will try to prepare the PR as a next step :-)

nickfrosst commented 1 year ago

looking forward to it! :)

michaelwechner commented 1 year ago

Need some more time to cleanup things ;-) whereas feel free to cherry-pick in case you want to go ahead.

michaelwechner commented 1 year ago

I have created a PR https://github.com/cohere-ai/sandbox-grounded-qa/pull/15

michaelwechner commented 1 year ago

PR merged https://github.com/cohere-ai/sandbox-grounded-qa/pull/15