Skip to content

Commit a55e868

Browse files
committed
Fix code to handle ChatGPT's wrong answer
1 parent 48f7a03 commit a55e868

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

aishell/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def make_executable_command(command: str) -> str:
1616
if command.endswith('\n'):
1717
command = command[:-1]
1818
command = command.strip()
19+
command = command.split('User: ')[0]
1920
return command
2021

2122

@@ -32,7 +33,7 @@ def get_os() -> str:
3233
def make_prompt(requirements: str) -> str:
3334
return f'''You are now a translater from human language to {get_os} shell command.
3435
No explanation required, respond with only the raw shell command.
35-
What should I type to shell for: {requirements}'''
36+
What should I type to shell for: {requirements}, in one line.'''
3637

3738

3839
app = typer.Typer()

test.txt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
diff --git a/README.md b/README.md
2+
index 8c32059..80d4810 100644
3+
--- a/README.md
4+
+++ b/README.md
5+
@@ -1,40 +1,42 @@
6+
-# AiShell
7+
+# AiShell 🤖
8+
9+
A simple Python code that connects to OpenAI's ChatGPT and executes the returned results.
10+
11+
-## Examples
12+
+## Examples 💡
13+
14+
-### Simple Utility commands
15+
+### Simple Utility commands 🛠
16+
17+
![terminal example](images/aishell_example.png)
18+
19+
-### A git helper
20+
+### A git helper 💻
21+
22+
![terminal example](images/aishell_example2.png)
23+
24+
-### A powerful git assistant: "add all files & amend last commit & push"
25+
+### A powerful git assistant 💪🏻👨‍💻💻: "add all files & amend last commit & push"
26+
27+
![terminal example3](images/aishell_example3.png)
28+
29+
+## Installation
30+
31+
-## Prerequisites
32+
+```sh
33+
+curl -sL https://raw.githubusercontent.com/code-yeongyu/AiShell/master/install.sh | sh
34+
+```
35+
+
36+
+## Prerequisites 📚
37+
38+
- Python 3.9.5
39+
- Poetry
40+
- OpenAI API Key
41+
42+
-## Getting Started
43+
+## Getting Started 🚀
44+
45+
1. Create account on OpenAI
46+
1. Go to <https://platform.openai.com/account/api-keys>, Copy API key
47+
-1. Set the API key as an environment variable OPENAI_API_KEY or inject it directly into the code by editing it.
48+
-1. Clone this repository to your local machine using git clone <repository-url>
49+
-1. Install the dependencies by running poetry install in your terminal
50+
-1. Start AiShell by running poetry run python3 aishell/main.py
51+
+1. Set the API key as an environment variable `OPENAI_API_KEY` or inject it directly into the code by editing it.
52+
+1. [Install](#installation)
53+
54+
-## Contributions
55+
+## Contributions 💬
56+
57+
Feel free to contribute to AiShell by adding more functionality or fixing bugs. Some suggestions for contributions include:
58+
59+
-- Adding the ability to execute AiShell as a system command aishell <command>
60+
- Publishing AiShell to PyPI so that others can easily download and use it

0 commit comments

Comments
 (0)