Skip to content

Commit

Permalink
Minor bug fixes, documentation, release 1.4.4 (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheR1D authored Aug 10, 2024
1 parent f0d000a commit b087d73
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,21 +453,16 @@ Possible options for `CODE_THEME`: https://pygments.org/styles/
```

## Docker
Run the container using the `OPENAI_API_KEY` environment variable, and a docker volume to store cache:
Run the container using the `OPENAI_API_KEY` environment variable, and a docker volume to store cache. Consider to set the environment variables `OS_NAME` and `SHELL_NAME` according to your preferences.
```shell
docker run --rm \
--env OPENAI_API_KEY="your OPENAI API key" \
--env OPENAI_API_KEY=api_key \
--env OS_NAME=$(uname -s) \
--env SHELL_NAME=$(echo $SHELL) \
--volume gpt-cache:/tmp/shell_gpt \
ghcr.io/ther1d/shell_gpt --chat rainbow "what are the colors of a rainbow"
ghcr.io/ther1d/shell_gpt -s "update my system"
```

When using a container, please note:
* The \[E\]xecute option for --shell with interaction will not work, since it would try this Execute in the docker container.
=> setting the `SHELL_INTERACTION` environment variable to false , makes sense.
* Since, most likely the os and shell of your container are not identical to the environment you want help with:
set the environment variables `OS_NAME` and `SHELL_NAME` according to your setup.


Example of a conversation, using an alias and the `OPENAI_API_KEY` environment variable:
```shell
alias sgpt="docker run --rm --volume gpt-cache:/tmp/shell_gpt --env OPENAI_API_KEY --env OS_NAME=$(uname -s) --env SHELL_NAME=$(echo $SHELL) ghcr.io/ther1d/shell_gpt"
Expand All @@ -476,8 +471,6 @@ sgpt --chat rainbow "what are the colors of a rainbow"
sgpt --chat rainbow "inverse the list of your last answer"
sgpt --chat rainbow "translate your last answer in french"
```
Note:
Consider filling in a more specific OS_NAME instead of using $(uname -s)

You also can use the provided `Dockerfile` to build your own image:
```shell
Expand All @@ -498,7 +491,7 @@ ENV USE_LITELLM=true
ENV OPENAI_API_KEY=bad_key
ENV SHELL_INTERACTION=false
ENV PRETTIFY_MARKDOWN=false
ENV OS_NAME="Red Hat Enterprise Linux 8.6 (Ootpa)"
ENV OS_NAME="Arch Linux"
ENV SHELL_NAME=auto
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion sgpt/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.4.3"
__version__ = "1.4.4"
4 changes: 2 additions & 2 deletions sgpt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"API_BASE_URL": os.getenv("API_BASE_URL", "default"),
"PRETTIFY_MARKDOWN": os.getenv("PRETTIFY_MARKDOWN", "true"),
"USE_LITELLM": os.getenv("USE_LITELLM", "false"),
"SHELL_INTERACTION ": os.getenv("SHELL_INTERACTION ", "true"),
"SHELL_INTERACTION": os.getenv("SHELL_INTERACTION ", "true"),
"OS_NAME": os.getenv("OS_NAME", "auto"),
"SHELL_NAME ": os.getenv("SHELL_NAME", "auto"),
"SHELL_NAME": os.getenv("SHELL_NAME", "auto"),
# New features might add their own config variables here.
}

Expand Down
2 changes: 1 addition & 1 deletion sgpt/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from abc import ABCMeta
from pathlib import Path
from typing import Any, Callable, Dict, List, Union
from typing import Any, Callable, Dict, List

from .config import cfg

Expand Down
1 change: 0 additions & 1 deletion sgpt/handlers/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def get_completion(
messages: List[Dict[str, Any]],
functions: Optional[List[Dict[str, str]]],
) -> Generator[str, None, None]:

name = arguments = ""
is_shell_role = self.role.name == DefaultRoles.SHELL.value
is_code_role = self.role.name == DefaultRoles.CODE.value
Expand Down

0 comments on commit b087d73

Please sign in to comment.