Skip to content

Commit

Permalink
Changing the gpt-3.5 model to gpt-4o-mini (#242)
Browse files Browse the repository at this point in the history
* chat(): replace `gpt-3.5` model with `gpt-4o-mini`
  • Loading branch information
mrgick authored Aug 2, 2024
1 parent cc213e8 commit 5c5efbc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ Exceptions:
## 1. chat() - AI chat

```python
def chat(self, keywords: str, model: str = "gpt-3.5", timeout: int = 20) -> str:
def chat(self, keywords: str, model: str = "gpt-4o-mini", timeout: int = 20) -> str:
"""Initiates a chat session with DuckDuckGo AI.
Args:
keywords (str): The initial message or question to send to the AI.
model (str): The model to use: "gpt-3.5", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b".
Defaults to "gpt-3.5".
model (str): The model to use: "gpt-4o-mini", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b".
Defaults to "gpt-4o-mini".
timeout (int): Timeout value for the HTTP client. Defaults to 20.
Returns:
Expand Down
4 changes: 2 additions & 2 deletions duckduckgo_search/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def version():
"-m",
"--model",
prompt="""DuckDuckGo AI chat. Choose a model:
[1]: gpt-3.5
[1]: gpt-4o-mini
[2]: claude-3-haiku
[3]: llama-3-70b
[4]: mixtral-8x7b
Expand All @@ -153,7 +153,7 @@ def version():
def chat(load, proxy, multiline, timeout, model):
"""CLI function to perform an interactive AI chat using DuckDuckGo API."""
client = DDGS(proxy=_expand_proxy_tb_alias(proxy))
model = ["gpt-3.5", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b"][int(model) - 1]
model = ["gpt-4o-mini", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b"][int(model) - 1]

cache_file = "ddgs_chat_conversation.json"
if load and Path(cache_file).exists():
Expand Down
8 changes: 4 additions & 4 deletions duckduckgo_search/duckduckgo_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ def _get_vqd(self, keywords: str) -> str:
resp_content = self._get_url("POST", "https://duckduckgo.com", data={"q": keywords})
return _extract_vqd(resp_content, keywords)

def chat(self, keywords: str, model: str = "gpt-3.5", timeout: int = 20) -> str:
def chat(self, keywords: str, model: str = "gpt-4o-mini", timeout: int = 20) -> str:
"""Initiates a chat session with DuckDuckGo AI.
Args:
keywords (str): The initial message or question to send to the AI.
model (str): The model to use: "gpt-3.5", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b".
Defaults to "gpt-3.5".
model (str): The model to use: "gpt-4o-mini", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b".
Defaults to "gpt-4o-mini".
timeout (int): Timeout value for the HTTP client. Defaults to 20.
Returns:
str: The response from the AI.
"""
models = {
"claude-3-haiku": "claude-3-haiku-20240307",
"gpt-3.5": "gpt-3.5-turbo-0125",
"gpt-4o-mini": "gpt-4o-mini",
"llama-3-70b": "meta-llama/Llama-3-70b-chat-hf",
"mixtral-8x7b": "mistralai/Mixtral-8x7B-Instruct-v0.1",
}
Expand Down
6 changes: 3 additions & 3 deletions duckduckgo_search/duckduckgo_search_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ async def __aexit__(
) -> None:
pass

async def achat(self, keywords: str, model: str = "gpt-3.5") -> str:
async def achat(self, keywords: str, model: str = "gpt-4o-mini") -> str:
"""Initiates async chat session with DuckDuckGo AI.
Args:
keywords (str): The initial message or question to send to the AI.
model (str): The model to use: "gpt-3.5", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b".
Defaults to "gpt-3.5".
model (str): The model to use: "gpt-4o-mini", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b".
Defaults to "gpt-4o-mini".
Returns:
str: The response from the AI.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_duckduckgo_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_context_manager():
assert 20 <= len(results) <= 30


@pytest.mark.parametrize("model", ["gpt-3.5", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b"])
@pytest.mark.parametrize("model", ["gpt-4o-mini", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b"])
def test_chat(model):
results = DDGS().chat("cat", model=model)
assert len(results) >= 1
Expand Down
2 changes: 1 addition & 1 deletion tests/test_duckduckgo_search_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def test_context_manager():


@pytest.mark.asyncio
@pytest.mark.parametrize("model", ["gpt-3.5", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b"])
@pytest.mark.parametrize("model", ["gpt-4o-mini", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b"])
async def test_chat(model):
results = await AsyncDDGS().achat("cat", model=model)
assert len(results) >= 1
Expand Down

0 comments on commit 5c5efbc

Please sign in to comment.