danswer-ai / danswer

Gen-AI Chat for Teams - Think ChatGPT if it had access to your team's unique knowledge.
https://docs.danswer.dev/
Other
10.27k stars 1.23k forks source link

How to access DAnswer through an API interface? #1030

Open huicewang opened 7 months ago

huicewang commented 7 months ago

How to access DAnswer through an API interface?

cypris75 commented 6 months ago

Would love to see this as well to integrate this into existing websites / knowledge bases.

Similar to what Mintlify offers.

https://mintlify.com/docs/api-playground/openapi/setup

https://mintlify.com/blog/chat

oldsj commented 4 months ago

I was able to make a curl request based off of observing the api calls in the browser with dev tools. Get the token from the cookie in the request headers, I don't think it's valid for long though:

curl -X POST "https://danswer.example.com/api/chat/send-message" \
     -H "Content-Type: application/json" \
     -H "Cookie: fastapiusersauth=<your_token>" \
     -d '{"chat_session_id":254,"parent_message_id":null,"message":"whats the company travel policy","prompt_id":0,"search_doc_ids":null,"retrieval_options":{"run_search":"auto","real_time":true,"filters":{"source_type":null,"document_set":null,"time_cutoff":null,"tags":[]}}}'

This is using Google SSO auth, you may be able to get a longer lived token with basic auth enabled

nigelsim commented 4 months ago

I'd also love to use DAnswer as the single source of indexed data, so I can build other LLM tools on top of it.

e.g., an API to search for and retrieve the text from documents matching a query (like happens on the RHS when it retrieves relevant documents). This way I can use the retrieved text in another LLM app.

Then, normal question/chat against any configured persona.

This would make the security around these integrated datasets a lot easier to manage, rather than having multiple disparate apps all separately indexing and storing the data.

cheunj3 commented 4 months ago

+1

Poltuu commented 1 month ago

Any opinion as to the possibility of such feature ? It would be a real game changer for us