diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..6faed1f --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +GOOGLE_API_KEY=YOUR_API_KEY \ No newline at end of file diff --git a/README.md b/README.md index 0c20f0d..521ca26 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,32 @@ 이 프로젝트에 대한 설명을 여기에 작성하세요. +## 환경 설정 + +1. Python 3.13 이상이 설치되어 있는지 확인하세요. + +2. 필요한 패키지를 설치하세요: + + ```shell + pip install -r requirements.txt + ``` + +3. 환경 변수 설정: + + - `.env.example` 파일을 복사하여 `.env` 파일을 생성하세요: + + ```shell + cp .env.example .env + ``` + + - `.env` 파일을 열고 `GOOGLE_API_KEY`에 실제 Google Generative AI API 키를 입력하세요. + ## 사용법 -사용법을 여기에 작성하세요. \ No newline at end of file +`api.py`를 실행하여 Gemini AI와 채팅을 시작하세요: + +```shell +python api.py +``` + +채팅 중 'quit'라고 입력하면 종료됩니다. diff --git a/api.py b/api.py new file mode 100644 index 0000000..aa15099 --- /dev/null +++ b/api.py @@ -0,0 +1,27 @@ +# 라이브러리 설치 +# pip install google-generativeai python-dotenv + +import os +from dotenv import load_dotenv +import google.generativeai as genai + +load_dotenv() + +# API 키 설정 +genai.configure(api_key=os.getenv('GOOGLE_API_KEY')) + +# 모델 초기화 +model = genai.GenerativeModel('gemini-2.0-flash-lite') + +# 대화형 채팅 시작 +chat = model.start_chat(history=[]) + +print("Gemini AI와 채팅을 시작합니다. 'quit'라고 입력하면 종료됩니다.") + +while True: + user_input = input("You: ") + if user_input.lower() == 'quit': + print("채팅을 종료합니다.") + break + response = chat.send_message(user_input) + print("Gemini:", response.text) \ No newline at end of file diff --git a/print_zero.py b/print_zero.py deleted file mode 100644 index 7ca3cc1..0000000 --- a/print_zero.py +++ /dev/null @@ -1,34 +0,0 @@ -""" -숫자 0 출력 모듈 -간단하게 숫자 0을 출력하는 기능을 제공합니다. -""" - -def print_zero(): - """숫자 0을 출력하는 함수""" - print(0) - return 0 - -def get_zero(): - """숫자 0을 반환하는 함수""" - return 0 - -def is_zero(number): - """주어진 숫자가 0인지 확인하는 함수""" - return number == 0 - -def main(): - """메인 실행 함수""" - print("🔢 숫자 0 출력 프로그램") - print("=" * 25) - - # 숫자 0 출력 - result = print_zero() - - # 추가 정보 출력 - print(f"반환값: {result}") - print(f"타입: {type(result)}") - print(f"0인가? {is_zero(result)}") - print("✅ 숫자 0 출력 완료!") - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bd7aa8d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +google-generativeai +python-dotenv \ No newline at end of file