A package to interact with DuckDuckGo AI-powered search
Project description
DuckDuckAI
DuckDuckAI is a Python package for interacting with DuckDuckGo's chat API. It allows you to fetch responses from DuckDuckGo's AI models and print them in a streamed format or as a complete response.
Installation
To install the DuckDuckAI package, you can use pip:
pip install DuckDuckAI
Usage
You can interact with DuckDuckAI by calling the ask function. It supports both streaming responses or returning the entire message at once.
Example
from duckduckai import ask
# Fetch response in streamed format (printing character by character)
ask("Tell me a joke", stream=True)
# Fetch response as a complete message
response = ask("Tell me a joke", stream=False)
print(response)
Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
| query | str | The search query string. | Required |
| stream | bool | Whether to stream results or fetch them all at once. | True |
| model | str | The model to use for the response. | gpt-4o-mini |
Available Models
DuckDuckAI currently supports the following models:
| Model ID | Description |
|---|---|
gpt-4o-mini |
A smaller variant of GPT-4o designed for quick, concise responses with less computation. |
meta-llama/Llama-3.3-70B-Instruct-Turbo |
Meta's large-scale Llama 3.3 model with 70 billion parameters designed for fast and accurate responses. |
claude-3-haiku-20240307 |
Anthropic's Claude 3 Haiku model optimized for efficient, high-quality responses. |
mistralai/Mistral-Small-24B-Instruct-2501 |
Mistral AI's 24 billion parameter model trained for instruction-based tasks. |
o3-mini |
OpenAI's compact reasoning model optimized for lightweight performance. |
Additional models may be available but subject to access restrictions. Some models may require specific permissions or may not be available in all regions.
Advanced Usage
You can reuse the authentication token to make multiple requests more efficiently:
from duckduckai import ask, fetch_token
# Fetch a token once
token = fetch_token()
# Use the same token for multiple requests
response1 = ask("What is quantum computing?", model="gpt-4o-mini", token=token)
response2 = ask("Explain neural networks", model="claude-3-haiku-20240307", token=token)
License
This project is licensed under the Apache-2.0 license - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file duckduckai-1.0.3.tar.gz.
File metadata
- Download URL: duckduckai-1.0.3.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cc27f401d53210d3d3c760f557b129c541682110f0a48745f87f1d8fdbe2b65
|
|
| MD5 |
2e70d10be21597101efa82d1790cc556
|
|
| BLAKE2b-256 |
88efd186414fe6697105c7ad985fc88415cfccbd2b4b201e27af74e45c94ab9b
|
File details
Details for the file DuckDuckAI-1.0.3-py3-none-any.whl.
File metadata
- Download URL: DuckDuckAI-1.0.3-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9123ab2b3cb0ff3be638bf5e83398e1bb5ce2bc318b05e715d85350c631ae08
|
|
| MD5 |
a859fae5f4a97b1fe07b9c1d59491f4a
|
|
| BLAKE2b-256 |
4aeedb47849083b7c3f473145108a69ca0201987b76b7492fc0f8f9bf6465376
|