deedy5 / duckduckgo_search

Search for words, documents, images, videos, news, maps and text translation using the DuckDuckGo.com search engine. Downloading files and images to a local hard drive.
MIT License
927 stars 117 forks source link

Add documentaion and/or type annotations for the response objects #212

Open yifeikong opened 2 months ago

yifeikong commented 2 months ago

Recently, I've been using this package to write a RAG application, however, I need to actually run the lib to know the response fields.

The current return type of .text() etc, is Dict:

https://github.com/deedy5/duckduckgo_search/blob/fce7fab463934f9e4d844ca5ca40a185a656a468/duckduckgo_search/duckduckgo_search_async.py#L181

https://github.com/deedy5/duckduckgo_search/blob/fce7fab463934f9e4d844ca5ca40a185a656a468/duckduckgo_search/duckduckgo_search_async.py#L192

which is too generic for the users and linters.

Describe the solution you'd like

Can we change the return type to a TypedDict or a pydantic model? The fields would be more explicit this way. At least, common fields such as title and body should be documented.

deedy5 commented 1 month ago

TypedDict is a good idea :+1: But there is no time yet, I will update README or add TypedDict later.