Jump to content

wji6205

Members
  • 게시글

    3
  • 첫 방문

  • 최근 방문

  • Days Won

    1

Everything posted by wji6205

  1. @CLOVA Studio 운영자9 답변 감사합니다. app id 쪽에 문제가 있었네요. app id를 수정하여 해결했습니다!
  2. 안녕하세요 @CLOVA Studio 운영자9 님. 빠른 답변 감사합니다! api key, api gateway key, request_id는 반복적으로 확인해 봤으나 오타가 없습니다. (실제로는 -이 아니라 발급받은 API key값을 입력했습니다.) 입력을 넣는 자료형에도 문제가 없는 듯 한데, 원인을 찾기가 어렵네요..
  3. class SegmentationExecutor: def __init__(self, host, api_key, api_key_primary_val, request_id): self._host = host self._api_key = api_key self._api_key_primary_val = api_key_primary_val self._request_id = request_id def _send_request(self, completion_request): headers = { "Content-Type": "application/json; charset=utf-8", "X-NCP-CLOVASTUDIO-API-KEY": self._api_key, "X-NCP-APIGW-API-KEY": self._api_key_primary_val, "X-NCP-CLOVASTUDIO-REQUEST-ID": self._request_id } conn = http.client.HTTPSConnection(self._host) conn.request( "POST", "/testapp/v1/api-tools/segmentation/-", json.dumps(completion_request), headers ) response = conn.getresponse() result = json.loads(response.read().decode(encoding="utf-8")) conn.close() return result def execute(self, completion_request): res = self._send_request(completion_request) if res["status"]["code"] == "20000": return res["result"]["topicSeg"] else: return "Error" if __name__ == "__main__": segmentation_executor = SegmentationExecutor( host="clovastudio.apigw.ntruss.com", api_key='-', api_key_primary_val='-', request_id='-' ) chunked_html = [] for htmldata in tqdm(clovastudiodatas_flattened): request_data = { "postProcessMaxSize": 100, "alpha": 1.5, "segCnt": -1, "postProcessMinSize": 0, "text": htmldata.page_content, "postProcess": False } request_json_string = json.dumps(request_data) request_data = json.loads(request_json_string, strict=False) print(request_data) response_data = segmentation_executor.execute(request_data) # 반환된 각 문단에 대해 source(주소) 포함하여 chunked_documents에 추가 for paragraph in response_data: chunked_document = { "source": htmldata.metadata["source"], "text": paragraph } chunked_html.append(chunked_document) 문단 나누기 api를 게시물과 똑같이 호출했음에도 응답값이 제대로 돌아오지 않습니다. code는 40000으로 나오고, messegae는 ' '라고만 출력되네요. 혹시 문단 나누기 api에 변경이 생겼을까요?
×
×
  • Create New...