model : gpt-3.5-turbo
https://openai.com/blog/introducing-chatgpt-and-whisper-apis
Introducing ChatGPT and Whisper APIs
Developers can now integrate ChatGPT and Whisper models into their apps and products through our API.
openai.com
파라미터
- 공식 페이지 https://platform.openai.com/docs/api-reference/chat/create
- model
- Required
- type : str
- 모델명 작성. 위의 gpt-3.5-turbo이 모델 중 하나를 선택한 것
- 모델 리스트 : https://platform.openai.com/docs/models/gpt-3
- messages
- Required
- type : array
- 세부 내용 doc : https://platform.openai.com/docs/guides/chat/introduction
- 메세지의 종류는 크게 3가지 형태가 존재
- 시스템(system) : 시스템 즉, chatGPT 모델에게 어느 목적으로 질문하는지 설정할 수 있다.
- 사용자(user) : 사용자 즉, 우리가 질문하고 싶은 질문을 작성한다.
- 도우미(assistant) : 이전에 응답했던 결과를 저장해 대화의 흐름을 유지할 수 있도록 설정한다.
- 포멧
messages = [
{"role": "system, user, assistant 중 선택", "content": "role에 알맞게 메세지 작성"},
{"role": "system, user, assistant 중 선택", "content": "role에 알맞게 메세지 작성"},
]
- temperature
- Optional
- type : float(0.0 ~ 2.0)
- default : 1
- 높을 수록 random, 낮을수록 deterministic 답변을 줌(테스트 해봐야 알 것 같음)
- top_p과 같이 변경하는 것은 권장하지 않음
- top_p
- Optional
- type : float(0.0 ~ 1.0)
- default : 1
- model이 생성한 token 결과를 sampling 함(테스트 해봐야 알 것 같음)
- temperature과 같이 변경하는 것은 권장하지 않음
- n
- Optional
- type : float
- default : 1
- 유저 메세지에 대해 생성할 대화 개수
- stream
- Optional
- type : boolean
- default : false
- 보류
- stop
- Optional
- type : string or array(최대 4개)
- default : null
- token을 생성을 종료하는 키워드 지정.
- max_tokens
- Optional
- type : integer
- default : inf
- 최대로 생성할 수 있는 token 길이로 보통 4096개이다.
- presence_penalty
- Optional
- type : float(-2.0 ~ 2.0)
- default : 0
- token을 만들 때 sampling 한 결과를 기억해 페널티를 주는 방식. 양수는 새로운 주제를, 음수로 갈수록 기존의 주제를 반환할 확률이 올라감.
- frequency_penalty
- Optional
- type : float(-2.0 ~ 2.0)
- default : 0
- token을 만들 때 sampling 한 결과를 기억해 페널티를 주는 방식. 한번의 답변에 대해 양수는 동일한 말을, 음수로 갈수록 새로운 말을 반환할 확률이 올라감.
- logit_bias
- Optional
- type : map
- default : null
- 보류
- user
- Optional
- type : string
- 최종 사용자를 나타내는 고유 식별자
참조
https://platform.openai.com/docs/api-reference/chat/create
OpenAI API
An API for accessing new AI models developed by OpenAI
platform.openai.com
https://wooiljeong.github.io/python/chatgpt-api/
ChatGPT API Python 사용법 (feat.DALL-E, Karlo)
ChatGPT API Python 사용법 (feat.DALL-E, Karlo)
wooiljeong.github.io
'ai > chatGPT' 카테고리의 다른 글
chatGPT-api 예제 코드 (0) | 2023.03.26 |
---|