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.
To install the DuckDuckAI package, you can use pip:
pip install DuckDuckAI
You can interact with DuckDuckAI by calling the ask
function. It supports both streaming responses or returning the entire message at once.
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)
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 (e.g., gpt-4o-mini). | gpt-4o-mini |
Here is the list of available models:
mistralai/Mixtral-8x7B-Instruct-v0.1
A model trained by Mistral for instruction-based tasks with 8x7B parameters.meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo
Meta's large-scale model with 70 billion parameters designed for fast and accurate responses.claude-3-haiku-20240307
A model optimized for generating short, poetic, and haiku-style text, using Claude 3 architecture.gpt-4o-mini
A smaller variant of GPT-4 designed for quick, concise responses with less computation.
This project is licensed under the Apache-2.0 license - see the LICENSE file for details.