AI Chat하면 대표적으로 chatgpt를 생각하고, 모델 자체도 GPT-n 모델을 제일 많이 사용한다.
이 외 클로드도, Sonar, Gemini 등 많은 모델이 존재하지만 이중 퍼플렉시티가 사용하는 Sonar 모델은
검색 후 추론에 특화되어있다.
즉, 명확하게 어떠한 페이지의 검색결과나 조사결과의 데이터를 뽑고싶다면 퍼플렉시티를 이용하는 편이다.
퍼플렉시티 또한 api를 제공하는데, 이번에 프로젝트에서 해당 모델을 사용할 이유가 생겨 사용 전 postman을 이용해 테스트해보려고 한다.
퍼플렉시티에서 기본적으로 하단에 API 메뉴가 존재한다. API 키를 누르면 아래와 같은 페이지가 등장한다.
Start Building, Develooper Docs 버튼 아무거나 눌러도 같은 페이지의 카테고리만 하위로 들어간다.
;
결제 가능한 카드를 기본적으로 등록해야한다. api 사용량마다 크레딧이 소모되니, 자동으로 충전되거나 일반 충전을 위해 등록시켜놓는 카드다.
그 후 가이드문서 대로 쭉 따라오면 된다지만 처음 진행하면 복잡하다고 느낄 수 있다.
아래는 postman으로 출력한 내용 전문과 각 json 요소가 어떤 역할을 하는지에 대해 기록했다.
{
"model": "sonar-deep-research",
"messages": [
{
"role": "system",
"content": "Be precise and concise."
},
{
"role": "user",
"content": "How many stars are there in our galaxy?"
}
],
"max_tokens": 1024,
"temperature": 0.2,
"top_p": 0.9,
"return_citations": true,
"search_domain_filter": [
"perplexity.ai"
],
"return_images": false,
"return_related_questions": false,
"search_recency_filter": "month",
"top_k": 0,
"stream": false,
"presence_penalty": 0,
"frequency_penalty": 1
}
"model": "sonar-deep-research"
사용할 모델 지정, sonar-deep-rearch 말고도 여러 sonar 모델이 존재한다. 공식문서 참조
"messages": [
{
"role": "system",
"content": "Be precise and concise."
},
{
"role": "user",
"content": "How many stars are there in our galaxy?"
}
]
"role" : "system". 부분은 모델의 행동을 대상으로 메시지를 보내는 느낌이다.
"content" 이곳의 메시지를 보낼 수 있다, "role" : "user" 부분
"temperature": 0.2
심도? 랜덤성? 을 조절할 수 있다. 1에 가까울수록 창의적은 답변을 도출해낸다.
"top_p": 0.9
확률 분포 기반의 샘플링을 조절하는 기법, 검색결과 값이 적을때 포함하지않는다.
"return_citations": true
출처 반환 여부
"search_domain_filter": [
"perplexity.ai"
]
검색할 도메인을 제한하는 옵션, 즉 google naver 등 해당 페이지에서만 활동한다.
"return_images": false
이미지 여부 설정
"return_related_questions": false
관련 추가 질문을 질행할지 질의
위의 질의문으로 검색할시 아래와 같은 결과값이 나온다.
{
"id": "51f2fdab-580a-472a-a8fb-68576a2d200f",
"model": "llama-3.1-sonar-small-128k-online",
"created": 1742262931,
"usage": {
"prompt_tokens": 14,
"completion_tokens": 39,
"total_tokens": 53
},
"citations": [
"https://www.youtube.com/watch?v=elrtvLsb-YY",
"https://www.youtube.com/watch?v=znnh49XGx2w",
"https://www.skyatnightmagazine.com/space-science/how-many-stars-born",
"https://en.wikipedia.org/wiki/Solar_System",
"https://www.mentalfloss.com/article/525230/10-astonishing-things-you-should-know-about-milky-way"
],
"object": "chat.completion",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "The number of stars in the Milky Way galaxy is estimated to be between 100 billion and 400 billion, with the most recent estimates leaning towards 300 billion stars[2][5]."
},
"delta": {
"role": "assistant",
"content": ""
}
}
]
}
'사이드 프로젝트' 카테고리의 다른 글
Nest.js + React.js (Next.js) 사이드 프로젝트 : 트러블슈팅 (0) | 2025.04.25 |
---|---|
Nest.js + React.js (Next.js) 사이드 프로젝트 : 페이징 구현하기 (2) (0) | 2025.03.19 |
Nest.js + React.js (Next.js) 사이드 프로젝트 : Repository extend (0) | 2025.03.17 |
Nest.js + React.js (Next.js) 사이드 프로젝트 : 페이징 구현하기 (1) (0) | 2025.03.12 |
nest.js 를 이용해 크롤링 해보기 (1) - puppeteer 동적 크롤링 (0) | 2025.03.07 |