Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- README.md +6 -6
- streamlit_app.py +2 -2
README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
title: GPT Code Explainer π‘
|
| 3 |
emoji: π€
|
| 4 |
colorFrom: blue
|
| 5 |
-
colorTo:
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: "1.35.0"
|
| 8 |
app_file: streamlit_app.py
|
|
@@ -11,9 +11,9 @@ pinned: false
|
|
| 11 |
|
| 12 |
# π€ GPT Code Explainer (OpenAI GPT-3.5)
|
| 13 |
|
| 14 |
-
This app uses
|
| 15 |
|
| 16 |
-
##
|
| 17 |
-
1. Paste Python code
|
| 18 |
-
2. Add your OpenAI API key as a secret
|
| 19 |
-
3. Click "Explain" to get a
|
|
|
|
| 2 |
title: GPT Code Explainer π‘
|
| 3 |
emoji: π€
|
| 4 |
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: "1.35.0"
|
| 8 |
app_file: streamlit_app.py
|
|
|
|
| 11 |
|
| 12 |
# π€ GPT Code Explainer (OpenAI GPT-3.5)
|
| 13 |
|
| 14 |
+
This Streamlit app uses OpenAI GPT-3.5 to explain Python code in natural language.
|
| 15 |
|
| 16 |
+
## How to Use
|
| 17 |
+
1. Paste Python code.
|
| 18 |
+
2. Add your OpenAI API key as a secret in your Hugging Face Space (`OPENAI_API_KEY`).
|
| 19 |
+
3. Click "Explain" to get a step-by-step breakdown.
|
streamlit_app.py
CHANGED
|
@@ -8,9 +8,9 @@ st.write("Paste your Python code below and get a detailed explanation using Open
|
|
| 8 |
|
| 9 |
code_input = st.text_area("Paste Python Code", height=200)
|
| 10 |
|
| 11 |
-
# β
|
| 12 |
api_key = os.getenv("OPENAI_API_KEY")
|
| 13 |
-
client = openai.
|
| 14 |
|
| 15 |
if st.button("Explain"):
|
| 16 |
if not client:
|
|
|
|
| 8 |
|
| 9 |
code_input = st.text_area("Paste Python Code", height=200)
|
| 10 |
|
| 11 |
+
# β
Use correct client for openai>=1.0.0
|
| 12 |
api_key = os.getenv("OPENAI_API_KEY")
|
| 13 |
+
client = openai.Client(api_key=api_key) if api_key else None
|
| 14 |
|
| 15 |
if st.button("Explain"):
|
| 16 |
if not client:
|