Skip to content

Commit

Permalink
added: Provider - Groq
Browse files Browse the repository at this point in the history
  • Loading branch information
Simatwa committed Mar 19, 2024
1 parent 101ed7f commit 0217291
Show file tree
Hide file tree
Showing 10 changed files with 392 additions and 11 deletions.
8 changes: 7 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,10 @@ For instance:
- patch: `FreeGpt` default g4f-based provider.
- added: `g4f` made required dependency.
- fix: `openai` response repetition. [#39](https://github.com/Simatwa/python-tgpt/issues/39)
- Other minor fixes.
- Other minor fixes.

## v0.5.6

**What's New?**

- added: Provider [Groq](https://console.groq.com/)
5 changes: 3 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ These are simply the hosts of the LLMs, which include:
11. [Blackboxai](https://www.blackbox.ai)
12. [gpt4all](https://gpt4all.io) *(Offline)*
13. [Poe](https://poe.com) - Poe|Quora *(Session ID required)*
14. [Groq](https://console.groq.com/) *(API Key required)


<details>
Expand Down Expand Up @@ -467,8 +468,8 @@ For example, for the option `--provider`, you would set an environment variable
The environment variables can be overridden by explicitly declaring new value.

> [!TIP]
> Save the variables in a `.env` file in your current directory or export the them in your `.zshrc` file.
> To load previous conversations from a `.txt` file, use the `-fp` or `--filepath` flag. If no flag is passed, the default file will be used. To load context from a file without altering its content, use the `--retain-file` flag.
> Save the variables in a `.env` file in your current directory or export them in your `.zshrc` file.
> To load previous conversations from a `.txt` file, use the `-fp` or `--filepath` flag. If no flag is passed, the default one will be used. To load context from a file without altering its content, use the `--retain-file` flag.
## Dynamic Provider

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ appdirs==1.4.4
webchatgpt==0.2.9
GoogleBard1>=2.1.4
colorama==0.4.6
g4f>=0.2.2.6
g4f>=0.2.5.7
pyyaml==6.0.1
matplotlib
gpt4all==2.2.0
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"GoogleBard1>=2.1.4",
"poe-api-wrapper==1.3.6",
"brotli==1.1.0",
"g4f>=0.2.4.1",
"g4f>=0.2.5.7",
]

cli_reqs = [
Expand All @@ -22,13 +22,13 @@
"clipman==3.1.0",
"pyperclip==1.8.2",
"colorama==0.4.6",
"g4f>=0.2.4.1",
"g4f>=0.2.5.7",
"python-dotenv==1.0.0",
]

EXTRA_REQUIRE = {
"cli": cli_reqs,
"all": ["g4f[all]>=0.2.4.1", "matplotlib", "gpt4all==2.2.0"] + cli_reqs,
"all": ["g4f[all]>=0.2.5.7", "matplotlib", "gpt4all==2.2.0"] + cli_reqs,
}

DOCS_PATH = Path(__file__).parents[0] / "docs/README.md"
Expand All @@ -40,7 +40,7 @@

setup(
name="python-tgpt",
version="0.5.5",
version="0.5.6",
license="MIT",
author="Smartwa",
maintainer="Smartwa",
Expand Down
1 change: 1 addition & 0 deletions src/pytgpt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"webchatgpt",
"g4fauto",
"poe",
"groq",
]

gpt4free_providers = [
Expand Down
24 changes: 24 additions & 0 deletions src/pytgpt/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,30 @@ def __init__(
act=awesome_prompt,
)

elif provider == "groq":
assert auth, (
"GROQ's API-key is required. " "Use the flag `--key` or `-k`"
)
from pytgpt.groq import main

self.bot = main.GROQ(
api_key=auth,
is_conversation=disable_conversation,
max_tokens=max_tokens,
temperature=temperature,
presence_penalty=top_p,
frequency_penalty=top_k,
top_p=top_p,
model=getOr(model, main.model),
timeout=timeout,
intro=intro,
filepath=filepath,
update_file=update_file,
proxies=proxies,
history_offset=history_offset,
act=awesome_prompt,
)

else:
raise NotImplementedError(
f"The provider `{provider}` is not yet implemented."
Expand Down
4 changes: 1 addition & 3 deletions src/pytgpt/gpt4free/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

from .main import completion_allowed_models

__info__ = (
"Interact with various free ai providers bundled by https://github.com/xtekky/gpt4free"
)
__info__ = "Interact with various free ai providers bundled by https://github.com/xtekky/gpt4free"

all = [
"GPT4FREE",
Expand Down
7 changes: 7 additions & 0 deletions src/pytgpt/groq/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .main import GROQ
from .main import session


__info__ = "Interact with GROQ's model. " "API key is required"

__all__ = ["OPENAI", "session"]
Loading

0 comments on commit 0217291

Please sign in to comment.