Skip to content

Commit 89c9450

Browse files
authored
Merge pull request #10 from code-yeongyu/feature/hello-pypi
2 parents 1e373d6 + 4efb25a commit 89c9450

File tree

11 files changed

+147
-127
lines changed

11 files changed

+147
-127
lines changed

.github/workflows/check_code.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Check Code
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
static-analysis:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
with:
11+
fetch-depth: 0
12+
- name: Set up Python 3.9
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: 3.9
16+
17+
- uses: snok/[email protected]
18+
with:
19+
virtualenvs-create: true
20+
virtualenvs-in-project: true
21+
22+
- name: Cache Dependencies
23+
uses: actions/cache@v2
24+
id: cache-dependencies
25+
with:
26+
path: .venv
27+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
28+
29+
- name: Install Dependencies if cache doesn't hit
30+
if: steps.cache-dependencies.cache-hit != 'true'
31+
run: poetry install
32+
33+
- name: Check Code Styles
34+
run: poetry run invoke check-code-style
35+
36+
- name: Check Types
37+
run: poetry run invoke check-types

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release Package to PyPI
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
release:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
with:
11+
fetch-depth: 0
12+
- name: Set up Python 3.9
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: 3.9
16+
17+
- uses: snok/[email protected]
18+
with:
19+
virtualenvs-create: true
20+
virtualenvs-in-project: true
21+
22+
- name: Cache Dependencies
23+
uses: actions/cache@v2
24+
id: cache-dependencies
25+
with:
26+
path: .venv
27+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
28+
29+
- name: Install Dependencies if cache doesn't hit
30+
if: steps.cache-dependencies.cache-hit != 'true'
31+
run: poetry install
32+
33+
- name: Publish to PyPI
34+
run:
35+
poetry config http-basic.pypi ${{ secrets.PYPI_USERNAME }} ${{ secrets.PYPI_PASSWORD }};
36+
poetry run invoke release ${{ github.event.release.name }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ A simple Python code that connects to OpenAI's ChatGPT and executes the returned
2020
## Installation 🔧
2121

2222
```sh
23-
curl -sL https://raw.githubusercontent.com/code-yeongyu/AiShell/master/install.sh | sh
23+
pip install aishell
2424
```
2525

2626
## Prerequisites 📚

aishell/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .cli import cli_app
2+
3+
4+
def main():
5+
cli_app()

aishell/__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import aishell
2+
3+
if __name__ == '__main__':
4+
aishell.main()

aishell/cli.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import os
2+
3+
import typer
4+
from rich.console import Console
5+
6+
from aishell.query_clients import ChatGPTClient, GPT3Client, QueryClient
7+
8+
cli_app = typer.Typer()
9+
10+
11+
@cli_app.command()
12+
def ask(question: str, use_chatgpt: bool = False):
13+
query_client: QueryClient
14+
if use_chatgpt:
15+
query_client = ChatGPTClient()
16+
else:
17+
query_client = GPT3Client()
18+
19+
console = Console()
20+
with console.status(f'[green] Asking `{question}` ...'):
21+
response = query_client.query(question)
22+
console.print(f'[italic]ai$hell: {response}\n')
23+
24+
os.system(response)

aishell/main.py

Lines changed: 0 additions & 109 deletions
This file was deleted.

aishell/query_clients/chatgpt_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def query(self, prompt: str) -> str:
3636

3737
response_text = ''
3838
for data in chatbot.ask(prompt):
39-
responsed_text = data['message']
39+
response_text = data['message']
4040

41-
responsed_text = make_executable_command(responsed_text)
41+
response_text = make_executable_command(response_text)
4242

4343
return response_text

aishell/query_clients/gpt3_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
from typing import cast
33

44
import openai
5-
from models import OpenAIResponseModel
6-
from utils import make_executable_command
5+
6+
from aishell.models import OpenAIResponseModel
7+
from aishell.utils import make_executable_command
78

89
from .query_client import QueryClient
910

install.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)