SandeepU commited on
Commit
acb208c
Β·
verified Β·
1 Parent(s): 2e223a3

Upload 3 files

Browse files
Files changed (2) hide show
  1. README.md +6 -6
  2. streamlit_app.py +2 -2
README.md CHANGED
@@ -2,7 +2,7 @@
2
  title: GPT Code Explainer πŸ’‘
3
  emoji: πŸ€–
4
  colorFrom: blue
5
- colorTo: purple
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 the OpenAI GPT-3.5 model to explain Python code in natural language.
15
 
16
- ## πŸ’‘ How to Use
17
- 1. Paste Python code into the text area.
18
- 2. Add your OpenAI API key as a secret called `OPENAI_API_KEY` in your Hugging Face Space (or as a local env variable).
19
- 3. Click "Explain" to get a clear explanation of the code.
 
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
- # βœ… Create OpenAI client (v1.0+)
12
  api_key = os.getenv("OPENAI_API_KEY")
13
- client = openai.OpenAI(api_key=api_key) if api_key else None
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: