songhune commited on
Commit
1c3da04
ยท
1 Parent(s): 0af2878

Update space

Browse files
Files changed (4) hide show
  1. README copy.md +0 -50
  2. README.md +50 -1
  3. chatbot.py +5 -1
  4. requirements.txt +1 -4
README copy.md DELETED
@@ -1,50 +0,0 @@
1
- # Gaslighting Chatbot
2
-
3
- ## Description
4
- ๊ฐ€์Šค๋ผ์ดํŒ… ์ฑ—๋ด‡ ํ”„๋กœ์ ํŠธ
5
-
6
- ## Prerequisites
7
- - Python 3.7 or higher
8
- - pip (Python package installer)
9
-
10
- ## Setup Instructions
11
-
12
- 1. Clone the repository:
13
- ```sh
14
- git clone <repository_url>
15
- cd <repository_directory>
16
- ```
17
-
18
- 2. Create a virtual environment (optional but recommended):
19
- ```sh
20
- python -m venv venv
21
- source venv/bin/activate # On Windows: venv\Scripts\activate
22
- ```
23
-
24
- 3. Install the required packages:
25
- ```sh
26
- pip install -r requirements.txt
27
- ```
28
-
29
- 4. Create a `.env` file in the project root directory and add your OpenAI API key:
30
- ```plaintext
31
- OPENAI_API_KEY=sk-YourOpenAIKeyHere
32
- ```
33
- ๋ณ„๋„์˜ openai api๋ฅผ ํ•„์š”๋กœ ํ•ฉ๋‹ˆ๋‹ค.
34
-
35
- 5. Add `.env` to `.gitignore` to ensure it is not tracked by git:
36
- ```plaintext
37
- # .gitignore
38
- .env
39
- ```
40
-
41
- 6. Run the chatbot:
42
- HICํด๋” ๋‚ด๋ถ€์˜ V1~Vx๊นŒ์ง€ ๊ฐ€๋Šฅ
43
-
44
- ## File Descriptions
45
-
46
- - `chatbot.py`: The main script to run the chatbot.
47
- - `requirements.txt`: Lists the dependencies required for the project.
48
- - `.env`: File to store environment variables (e.g., API keys). **Do not commit this file to version control.**
49
- - `.gitignore`: Ensures `.env` and other files are not tracked by git.
50
- - `README.md`: This readme file.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -10,4 +10,53 @@ pinned: false
10
  license: unknown
11
  ---
12
 
13
- An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  license: unknown
11
  ---
12
 
13
+ # Gaslighting Chatbot
14
+
15
+ ## Description
16
+ ๊ฐ€์Šค๋ผ์ดํŒ… ์ฑ—๋ด‡ ํ”„๋กœ์ ํŠธ
17
+
18
+ ## Prerequisites
19
+ - Python 3.7 or higher
20
+ - pip (Python package installer)
21
+
22
+ ## Setup Instructions
23
+
24
+ 1. Clone the repository:
25
+ ```sh
26
+ git clone <repository_url>
27
+ cd <repository_directory>
28
+ ```
29
+
30
+ 2. Create a virtual environment (optional but recommended):
31
+ ```sh
32
+ python -m venv venv
33
+ source venv/bin/activate # On Windows: venv\Scripts\activate
34
+ ```
35
+
36
+ 3. Install the required packages:
37
+ ```sh
38
+ pip install -r requirements.txt
39
+ ```
40
+
41
+ 4. Create a `.env` file in the project root directory and add your OpenAI API key:
42
+ ```plaintext
43
+ OPENAI_API_KEY=sk-YourOpenAIKeyHere
44
+ ```
45
+ ๋ณ„๋„์˜ openai api๋ฅผ ํ•„์š”๋กœ ํ•ฉ๋‹ˆ๋‹ค.
46
+
47
+ 5. Add `.env` to `.gitignore` to ensure it is not tracked by git:
48
+ ```plaintext
49
+ # .gitignore
50
+ .env
51
+ ```
52
+
53
+ 6. Run the chatbot:
54
+ HICํด๋” ๋‚ด๋ถ€์˜ V1~Vx๊นŒ์ง€ ๊ฐ€๋Šฅ
55
+
56
+ ## File Descriptions
57
+
58
+ - `chatbot.py`: The main script to run the chatbot.
59
+ - `requirements.txt`: Lists the dependencies required for the project.
60
+ - `.env`: File to store environment variables (e.g., API keys). **Do not commit this file to version control.**
61
+ - `.gitignore`: Ensures `.env` and other files are not tracked by git.
62
+ - `README.md`: This readme file.
chatbot.py CHANGED
@@ -2,14 +2,18 @@ import os
2
  import json
3
  from datetime import datetime
4
  from openai import OpenAI
 
5
  from dotenv import load_dotenv
6
  from scenario_handler import ScenarioHandler
7
 
8
  # Initialize the OpenAI client
9
  load_dotenv()
10
  api_key = os.getenv('OPENAI_API_KEY')
11
- client = OpenAI(api_key=api_key)
12
 
 
 
 
 
13
  # ์ „์—ญ ๋Œ€ํ™” ๊ธฐ๋ก ๋ฐ ScenarioHandler ์ธ์Šคํ„ด์Šค
14
  global_history = []
15
  scenario_handler = ScenarioHandler() # ์ „์—ญ์œผ๋กœ ScenarioHandler ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ
 
2
  import json
3
  from datetime import datetime
4
  from openai import OpenAI
5
+ from huggingface_hub import InferenceClient
6
  from dotenv import load_dotenv
7
  from scenario_handler import ScenarioHandler
8
 
9
  # Initialize the OpenAI client
10
  load_dotenv()
11
  api_key = os.getenv('OPENAI_API_KEY')
 
12
 
13
+ + client = InferenceClient(
14
+ base_url=...,
15
+ api_key=...,
16
+ )
17
  # ์ „์—ญ ๋Œ€ํ™” ๊ธฐ๋ก ๋ฐ ScenarioHandler ์ธ์Šคํ„ด์Šค
18
  global_history = []
19
  scenario_handler = ScenarioHandler() # ์ „์—ญ์œผ๋กœ ScenarioHandler ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ
requirements.txt CHANGED
@@ -1,4 +1 @@
1
- python-dotenv
2
- openai
3
- gradio=4.27.0
4
- json
 
1
+ json