안녕하세요 강의 보다가 헷갈리는 부분이 있어서 질문드립니다 질문1. 3.3 LangGraph에서 도구(tool) 활용 방법 아래 agent 함수는 여러번 호출되는데 리턴하는 부분에서 새로운 배열을 만드는것 처럼 보이지만 add_messages에 의해 자동으로 누적되어 멀티턴 대화가 된다고 이해하면 맞을까요? def agent(state: MessagesState) -> MessagesState: """ 에이전트 함수는 주어진 상태에서 메시지를 가져와 LLM과 도구를 사용하여 응답 메시지를 생성합니다. Args: state (MessagesState): 메시지 상태를 포함하는 state. Returns: MessagesState: 응답 메시지를 포함하는 새로운 state. """ # 상태에서 메시지를 추출합니다. messages = state['messages'] # LLM과 도구를 사용하여 메시지를 처리하고 응답을 생성합니다. response = llm_with_tools.invoke(messages) # 응답 메시지를 새로운 상태로 반환합니다. return {'messages': [response]} 질문2. 3.5 Agent의 히스토리를 관리하는 방법 MemorySaver()의 목적은 주피터 노트북 각 블록을 사용하는데 있어 그 전에 실행해서 얻은 message를 메모리에 저장후 다음 요청 (update_query)에 반영하기 위해 사용된게 맞을까요?
from langchain_core.messages import SystemMessage def agent(state: AgentState) -> AgentState: """ 주어진 `state`에서 메시지를 가져와 LLM과 도구를 사용하여 응답 메시지를 생성합니다. Args: state (AgentState): 메시지 기록과 요약을 포함하는 state. Returns: MessagesState: 응답 메시지를 포함하는 새로운 state. """ # 메시지와 요약을 state에서 가져옵니다. messages = state['messages'] summary = state['summary'] # 요약이 비어있지 않으면, 요약을 메시지 앞에 추가합니다. if summary != '': messages = [SystemMessage(content=f'Here is the summary of the earlier conversation: {summary}')] + messages # LLM과 도구를 사용하여 메시지에 대한 응답을 생성합니다. response = llm_with_tools.invoke(messages) # 응답 메시지를 포함하는 새로운 state를 반환합니다. return {'messages': [response]} 부분에 summary = state['summary'] agent시작하자마자 summary를 넣게되는데 해당 소스부분은 몇 번을 질문해도 처음에는 빈값이 들어가는게 맞나요? summary를 연속질문에 처음 시작 부터 적용하기 위해서는 아래처럼 session정보를 받아서 처리해야하는지 궁금합니다. from langchain_core.messages import HumanMessage query = '안녕' for chunk in graph.stream({'messages': [HumanMessage(query)], 'summary': graph.get_state(config).values['summary']}, config=config, stream_mode='values'): chunk['messages'][-1].pretty_print()
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] ***문제해결**** JDBCRepository 구현시 이걸 안 붙혀넣고 이렇게 써서 생긴 오류인 것 같습니다.. 다른 질문글에서 보고 알았습니다 하하.. *************** @Transactional 어노테이션을 썻지만, h2 DB에서 롤백이 되지 않습니다. 롤백이 되지 않은 이유가 스프링 버전과 h2 버전이 바뀌어서 그런건가요? 테이블을 초기화하고 스프링통합memberServiceTest 를 진행하니 회원가입한 정보가 테스트가 끝난 후 DB에 고스란히 남아있었습니다. #스프링 환경 Java-> 17 spring->3.4.3 h2 : 2.3.232 -> 서버모드 접근함(jdbc:h2:tcp://localhost/~/test) #알아본것 h2에 서버모드로 접근하면, spring->네트워크->h2 이렇게 접근이 되어서 외부에 있는 DB는 롤백을 안한다고 들었습니다. 다른 곳에서도 접근해서 고칠 수 있기 때문에,, 그래서 대신 메모리모드를 사용하라고 답변을 들었습니다.
[질문 템플릿] 1. 강의 내용과 관련된 질문인가요? 예 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예 3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예 [질문 내용] public class ManyThreadMainV2 { public static void main(String[] args) { log("main() start"); HelloRunnable runnable = new HelloRunnable(); for(int i=0; i<100; i++){ Thread thread = new Thread(runnable); thread.start(); } log("main() end"); } } 안녕하세요, 여러 스레드 만들기에서 반복문을 사용하여 스레드를 생성하면 콘솔에 스레드의 실행 순서가 보장되며 출력이 됩니다. 사진처럼 몇 번을 다시 수행해도 Thread0, 1, 2 ... 98, 99로 강의와 다르게 순서가 항상 일정하게 출력되는데 혹시 무엇이 문제인지 알 수 있을까요 ?
다음 영상에서 문제 풀거라고 하셨는데 문제풀이 영상이 누락되어있는 것 같습니다 최소공통조상 빠르게 구하기 마지막부분이나 여러 영상들에서 다음영상에서 문제 풀어볼거라고하셨는데 문제풀이 영상이 빠져있는 것 같아요 ㅠ ! 유튜브에 들어가봐도 자바 문제풀이 영상을 찾을 수 없었습니다ㅜ 확인해주실 수 있나요?
한다 제보를 KILL-9, 바란다 응답 [제보 정보 수집중... 🤖 ] [KILL-9@user]$ cd 커리큘럼/섹션4/3장/작전1 해킹 주문 데이터베이스 정찰 작전에서 프락치를 발견했다 JdbcPagingItemReader 가 whereClause에 거짓 증거를 제출해서 혼란을 야기했다 status = 'READY_FOR_SHIPMENT' 이고 not null 이어햐 하지 않을까 생각한다 CANCELLED 가 아닌 것 같다 다시 보니 작전에 혼동이 있는 것 같다 확인요망 🔥 유해 게시물 처형 작전 시스템에도 버그가 발견됐다 전체코드에서 JpaCursorItemReader 에 queryString 조건이 잘못된 것 같다 이후의 예시 코드들은 잘돼있지만 전체코드 복사하는 녀석들이 많기 때문에 처리부탁한다 [추가 처형 요청... 💀 ] [KILL-9@user]$ cd 커리큘럼/섹션3/2장/작전1 글 쓰는 김에 한 녀석도 추가 제보하겠다 FlatFileItemReader 고정길이 예제도 처형 부탁한다 소제목인 .columns() 예제 이미지가 정확하다 하지만 예시코드라고 적혀있는 Range는 틀렸다 이것은 KILL-9 후보생의 혼란만 가중시킬뿐이다
현재 댓글 무한 depth까지 수강했는데 snowFlake를 통해 Id값을 넣고 있는데 해당 부분을 service단에서 entity.create를 통해 구현하는 점에 대해 궁금증이 생겼습니다. 이런 방식으로 계속 진행이 되면 보일러 플레이트방식이 되는것 같은 느낌이 들어서 차라리 커스텀 IdentifierGenerator를 통해 Entity안에서 값을 넣어주면 어떨까하고 생각을 해보게 되었습니다. 이렇게 진행하면 기존 service를 통해 진행하는 것보다 비효율적일까요?? 두개의 차이점이 궁금합니다
예제를 따라하고 있는데요 public ChatClient chatClient(ChatClient.Builder chatBuilder){ return chatBuilder .defaultAdvisors(new MessageChatMemoryAdvisor(new InMemoryChatMemory()).build(); } 이부분이 에러가 나서 MessageChatMemoryAdvisor를 생성을 못하는데요.. 어떻게 해야 할까요? spring ai버전이 1.0.0버전인데 버전에 따라 코드가 바뀌는것 같은데요..
문제 / 오류 / 질문에 대해 설명해 주세요 HTTP Request 강좌를 따라하는 중에 12:30 즘에서 openAI API를 입력하고 Test step을 눌렀습니다. 하지만, 다과 같은 에러가 작성하였습니다. 오류 메시지가 있다면 작성해 주세요 The service is receiving too many requests from you You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors . { "errorMessage": "The service is receiving too many requests from you", "errorDescription": "You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors .", "errorDetails": { "rawErrorMessage": [ "Try spacing your requests out using the batching settings under 'Options'" ], "httpCode": "429" }, "n8nDetails": { "nodeName": "HTTP Request", "nodeType": "n8n-nodes-base.httpRequest", "nodeVersion": 4.2, "itemIndex": 0, "time": "2025. 5. 21. 오후 9:12:44", "n8nVersion": "1.93.0 (Self Hosted)", "binaryDataMode": "default", "stackTrace": [ "NodeApiError: The service is receiving too many requests from you", " at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js:615:21)", " at processTicksAndRejections (node:internal/process/task_queues:95:5)", " at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/workflow-execute.js:696:27)", " at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/workflow-execute.js:930:51", " at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/workflow-execute.js:1266:20" ] } } 사용 중인 워크플로우를 공유해 주세요 HTTP Request 강좌 실습 중 n8n 설치 정보 안내 n8n 버전: 1.93.0 데이터베이스 종류 (기본값: SQLite): n8n 실행 프로세스 설정 (기본값: own, main): n8n 실행 방식 (예: Docker, npm, n8n cloud, 데스크탑 앱 등): Docker 운영 체제: Win 11 Pro
모두를 위한 대규모 언어 모델 LLM Part 5 - LangGraph로 나만의 AI 에이전트 만들기
안녕하세요.. 수업노트에 있는 storm colab 파일을 따라 하는데.. import json from langchain_core.runnables import RunnableConfig async def gen_answer( state: InterviewState, config: Optional[RunnableConfig] = None, name: str = "Subject_Matter_Expert", max_str_len: int = 15000, ): swapped_state = swap_roles(state, name) # Convert all other AI messages # 쿼리 생성 queries = await gen_queries_chain.ainvoke(swapped_state) query_results = await search_engine.abatch( queries["parsed"].queries, config, return_exceptions=True ) successful_results = [ res for res in query_results if not isinstance(res, Exception) ] # url와 콘텐츠 추출 all_query_results = { res["url"]: res["content"] for results in successful_results for res in results } # We could be more precise about handling max token length if we wanted to here dumped = json.dumps(all_query_results)[:max_str_len] ai_message: AIMessage = queries["raw"] tool_call = queries["raw"].tool_calls[0] tool_id = tool_call["id"] tool_message = ToolMessage(tool_call_id=tool_id, content=dumped) swapped_state["messages"].extend([ai_message, tool_message]) # Only update the shared state with the final answer to avoid # polluting the dialogue history with intermediate messages generated = await gen_answer_chain.ainvoke(swapped_state) cited_urls = set(generated["parsed"].cited_urls) # Save the retrieved information to a the shared state for future reference cited_references = {k: v for k, v in all_query_results.items() if k in cited_urls} formatted_message = AIMessage(name=name, content=generated["parsed"].as_str) return {"messages": [formatted_message], "references": cited_references} 이 부분에서 궁금한 것이 생겼습니다. 중간에 tool_call = queries["raw"].tool_calls[0] tool_id = tool_call["id"] 중간에 tool_calls 관련 정보를 호출하는데..그럴려면 gen_queries_chain 이 체인에 tool_bind된 llm이 사용되어야 하는 것 아닌가요? duckduckgo 관련 search_engine함수를 @tool을 이용해서 tool로 선언한 것 같은데.. 해당 퉁을 llm에 바인딩하는 것을 못보아서.. tool index 부분에서 Cell In[46], line 30, in gen_answer(state, config, name, max_str_len) 28 dumped = json.dumps(all_query_results)[:max_str_len] 29 ai_message: AIMessage = queries["raw"] ---> 30 tool_call = queries["raw"].tool_calls[0] 31 tool_id = tool_call["id"] 32 tool_message = ToolMessage(tool_call_id=tool_id, content=dumped) IndexError: list index out of range 가 발생하는 것 같습니다. 어떻게 수정하면 되는지 알려주세요..
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? 예 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예 3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예 [질문 내용] 안녕하세요 선생님 강의를 통해 배움을 얻고 프로젝트를 하며 성장 하고 있습니다. 프로젝트를 하던중 영속성 전이와 관련하여 궁금한점이 생겨 질문 드립니다. ( 영한님 JPA 강의에 질문 하는것이 맞으나 JPA는 책을 사서 여기에 질문 드립니다 ㅠㅠ ) 회원과 주소는 양방향 관계를 두고 있습니다. 회원과 주소를 연관관계 매핑하여 회원을 저장하면 영속성 전이를 통해 주소가 같이 저장 됩니다. 그런데 문제는 둘다 영속 상태일때 주소를 제거 하면 delete 쿼리가 나가지 않았습니다. 이런 저런 실험을 해본 결과 영속성 전이 때문에 삭제 되지 않은것으로 보았습니다. 영속 대상인 주소를 삭제 하려고 했으나 회원의 연관관계인 Address는 그대로 있기 때문에 영속성 전이로 인해 삭제가 되지 않았다로 판단 하였습니다. 영속성 컨텍스트에 주소만 있을 경우 주석 으로된 부분을 실행하면 영속성 전이를 수행할 회원이 없기 때문에 delete 쿼리가 나가게 됩니다. 제가 생각한게 맞는지 궁금하여 질문 드립니다. 밑의 예시의 경우 회원이 영속 상태인 경우 영속성 전이 때문에 연관관계를 끊지 않으면 영속 대상인 주소가 delete가 안되는게 맞을까요? @DisplayName("회원과 연관된 주소를 제거할때 자식인 주소를 제거 하면 delete 쿼리가 발생하지 않는다.") @Test void deleteAddress() { //given User user = new User("회원"); Address address = new Address("주소"); address.connectUser(user); //when em.persist(user); em.flush(); boolean isAddressManaged = em.contains(address); System.out.println("Address is managed? " + isAddressManaged); addressRepository.deleteById(address.getId()); em.flush(); em.clear(); //then //Address findAddress = addressRepository.findById(address.getId()).orElseThrow() //addressRepository.deleteById(findAddress.getId()); //em.flush(); } [ 회원 ] @Getter @Setter @Table(name = "users") @Entity public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @OneToOne(mappedBy = "user", cascade = CascadeType.PERSIST) private Address address; protected User() {} private String name; public void connectAddress(Address address){ this.address = address; } } @Getter @Entity public class Address { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id") private User user; private String addressName; protected Address() {} public Address(String addressName) { this.addressName = addressName; } public void connectUser(User user){ this.user = user; user.connectAddress(this); } }