Jump to content

탱구탱구

Members
  • 게시글

    3
  • 첫 방문

  • 최근 방문

Everything posted by 탱구탱구

  1. 위 예시 코드에 tools = TOOLS 가 누락됬네요. 이부분 수정이 안되서 댓글로 추가하겠습니다.
  2. 안녕하세요 일단 날짜 조회 하는 부분부터 이슈가 있어서 전달드립니다. Tool.fromFunction을 통해서 호출할 때는 년도가 잘못 나오는 경우를 제외하면 요청 및 응답은 오는데요. 다만 @tool 데코레이션이나 StructuredTool을 통해 tool을 정의할 경우 디버그 오류가 아래 볼드처리된 부분만 나오고 끝이라서요. httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://clovastudio.stream.ntruss.com/v1/openai/chat/completions' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 같은 코드에서 ChatOpenAi나 ChatAnthropic을 사용했을 때는 두 모델 모두 정상이라서요. 혹시 코드상에 문제가 되는 부분이 있다면 피드백 부탁드립니다. 아래는 도구 정의 및 호출하는 코드입니다. def get_current_datetime(dummy: str = "now") -> str: """오늘 날짜를 ISO 8601 형식으로 반환합니다.""" print("[tool 호출] 날짜 조회->", datetime.now().isoformat()) kst = timezone(timedelta(hours=9)) current_time = datetime.now() return {"current_time": current_time.isoformat()} TOOLS = [ StructuredTool.from_function( func=get_current_datetime, name="get_current_datetime", description="오늘 시간을 ISO 8601 형식으로 반환합니다. 입력은 무시됩니다." ) ] model = ChatClovaX(temperature=0.5, model="HCX-DASH-002", max_tokens=3000) # HCX-005, HCX-DASH-002 # create_react_agent app = create_react_agent( model=model, tools=tools, prompt=system_prompt, interrupt_before=None, interrupt_after=None, debug=True ) async def run_graph_stream(query: str, user_id: str, room_id: str): state = { "messages": [ HumanMessage( content=query, # additional_kwargs={"user_id": user_id, "meeting_id": room_id}, ) ] } print(f"=== DEBUG: 상태 생성 완료 ===") print(f"메시지 개수: {len(state['messages'])}") try: async for msg, metadata in app.astream(state, stream_mode="messages"): print(f"=== DEBUG: 스트림 응답 ===") print(f"메시지 타입: {type(msg)}") print(f"메시지 내용: {msg}") if isinstance(msg, AIMessageChunk): content_text = "" if hasattr(msg, 'content') and msg.content: if isinstance(msg.content, str): content_text = msg.content elif isinstance(msg.content, list): # content가 list인 경우 (Anthropic 형식) for item in msg.content: if isinstance(item, dict) and item.get('type') == 'text': content_text += item.get('text', '') elif hasattr(item, 'text'): content_text += item.text if content_text: data = { "type": "token", "content": content_text, "timestamp": datetime.now().isoformat() } yield f"data: {json.dumps(data)}\n\n" yield f"data: {json.dumps({'type': 'done'})}\n\n" except Exception as e: print(f"=== DEBUG: 스트림 에러 ===") print(f"에러: {str(e)}") error_data = { "type": "error", "content": f"에러 발생: {str(e)}", "timestamp": datetime.now().isoformat() } yield f"data: {json.dumps(error_data)}\n\n"
  3. 안녕하세요 langchain-naver를 통해 ChatClovaX를 사용하고 있는데요. 랭체인 도구중 StructuredTool을 지원하지 않는 것으로 확인되는데.. 혹시 지원 계획이 있을까요? docstring이나 description에 적은 형태로 매개변수를 생성하여 tool calling이 잘 안되는 것 같아서 문의드립니다. 그리고 혹시 각 tool의 결과값을 다음 tool의 매개변수로 잘 활용하기 위해서 명시해야하는 prompt나 desc, docstring이 있을까요?
×
×
  • Create New...