Skip to content

Commit a065c29

Browse files
committed
구조 전체 변경, README.md 업데이트
1 parent d13089f commit a065c29

12 files changed

+813
-136
lines changed

.gitignore

+769
Large diffs are not rendered by default.

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
# openai-tutorial
2-
openai-tutorial
1+
# openai-tutorial 예제를 모아놓은 Repo입니다.
2+
3+
## 본 repo는 아래 블로그 글에서 다룬 코드를 저장하고 있습니다.
4+
5+
- OpenAI GPT3.5 활용하기
6+
- https://lsjsj92.tistory.com/655
7+
- OpenAI GPT3.5 fine-tuning 하기
8+
- https://lsjsj92.tistory.com/656
9+
10+
## Example list
11+
1. GPT3.5 기본 활용 방법
12+
- gpt3_5(davinci-text-003).py
13+
2. GPT3.5 Fine-tuning model 활용
14+
- gpt3(davinci)_finetuning.py
15+
3. GPT3.5 with Slack
16+
- gpt3_5(davinci-text-003)_slack.py

example/chatgpt.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
import openai
3+
import argparse
4+
from dotenv import load_dotenv
5+
6+
class OpenAIGpt:
7+
def __init__(self):
8+
load_dotenv()
9+
10+
def run(self):
11+
openai.api_key = os.getenv("OPENAI_API_KEY")
12+
text = "Hello. nice to meet you"
13+
completion = openai.ChatCompletion.create(
14+
model="gpt-3.5-turbo",
15+
messages=[
16+
{"role": "system", "content": "You are a helpful assistant that translates English to Korean."},
17+
{"role": "user", "content": f'Translate the following English text to Korean: "{text}"'}
18+
]
19+
)
20+
21+
print(completion)
22+
print(completion['choices'][0]['message']['content'])
23+
24+
25+
if __name__ == '__main__':
26+
openai_gpt = OpenAIGpt()
27+
openai_gpt.run()
File renamed without changes.

example/openai/gpt3_finetuning.py renamed to example/gpt3(davinci)_finetuning.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def run(self, args):
1313
openai.api_key = os.getenv("OPENAI_API_KEY")
1414
response = openai.Completion.create(
1515
#model="text-davinci-003",
16-
model="davinci:ft-wjtb-2023-01-29-10-42-22",
16+
model="<Write your fine-tuning model>",
1717
prompt=f"{question}",
1818
temperature=args.temperature,
1919
max_tokens=100,
File renamed without changes.

example/openai/.env

-5
This file was deleted.

example/openai/web.py

-44
This file was deleted.

example/openai/web_chat.py

-51
This file was deleted.

main.py

-33
This file was deleted.

0 commit comments

Comments
 (0)