from langchain_core.prompts import ChatPromptTemplate from pydantic import BaseModel, Field from typing import Literal class Route(BaseModel): target: Literal["income_tax", "llm", "real_estate_tax"] = Field( description="The target for the query to answer" ) router_system_prompt = """ You are an expert at routing a user's question to 'income_tax', 'llm', or 'real_estate_tax'. 'income_tax' contains information about income tax up to December 2024. 'real_estate_tax' contains information about real estate tax up to December 2024. if you think the question is not related to either 'income_tax' or 'real_estate_tax'; you can route it to 'llm'.""" router_prompt = ChatPromptTemplate.from_messages( [("system", router_system_prompt), ("user", "{query}")] ) structured_router_llm = small_llm.with_structured_output(Route) def router(state: AgentState) -> Literal["income_tax", "real_estate_tax", "llm"]: """ 주어진 state에서 쿼리를 기반으로 적절한 경로를 결정합니다. Args: state (AgentState): 현재 에이전트의 state를 나타내는 객체입니다. Returns: Literal['income_tax', 'real_estate_tax', 'llm']: 쿼리에 따라 선택된 경로를 반환합니다. """ query = state["query"] router_chain = router_prompt | structured_router_llm route = router_chain.invoke({"query": query}) return route.target 안녕하세요 강병진 강사님:) 혹시 위 코드에서 router_prompt없이 Route class의 Field에만 프롬프트 지침을 넣어도 문제가 없을까요? 테스트 결과는 잘 나왔습니다. 아래는 수정 코드입니다. class Route(BaseModel): target: Literal["real_estate_tax", "llm", "income_tax"] = Field(description = """ 당신은 사용자의 질문을 보고 적절한 라우터를 연결해주는 전문가입니다. 부동산에 관련된 질문은 real_estate_tax라우터를, 소득세에 관한 질문은 income_tax라우터를, 그 외의 질문은 llm라우터로 연결해주세요. """) def router(state: AgentState): query = "역삼역 떡볶이 맛집을 알려주세요 " router_llm = llm.with_structured_output(Route) response = router_llm.invoke(query) return response.target print(router({})) >> 'llm'
아래분도 저와 같은 에러가 나는 것 같은데 npx.cmd https://github.com/google-gemini/gemini-cl 해당 경로로 터미널에 등록해도 아래와 같은 오류가 계속 발생합니다.. node, Git다운도 다시 받아 보았지만 같은 현상이 계속 됩니다. npm error code ENOENT npm error syscall spawn git npm error path git npm error errno -4058 npm error enoent An unknown git error occurred npm error enoent This is related to npm not being able to find a file. npm error enoent npm error A complete log of this run can be found in: C:\Users\AppData\Local\npm-cache\_logs\2025-08-25T11_30_44_463Z-debug-0.log 수업 종강은 얼마 안 남았는데 되는 것이 없어서 마음이 답답하네요...
MCP Server 나 langgraph 나 모두 tool 입니다. 만약 tool 에서 결과 값이 너무 많이 나오는 경우 어떻게 처리 해야 할까요? 예1) MCP Server의 "우리 회사 고객 정보중 매출 얼마 이상 되는 정보를 보여줘?" 라고 고객이 입력 했는데, 그 고객 정보가 10만명이 나와서 tool 의 결과가 너무 커 버리는 예) DB의 Limit 등으로 어떻게 하더라도 다음 호출을 LLM이 잘 못해주는 경우가 있음. 예2) 슬랙의 채널을 보여줘 했을 때, 슬랙의 채널이 너무 많은 경우 ... 결국 전부다 예3) 소스코드를 분석해 줘 소스코드가 1만 - 2만 라인 되었을 경우 Tool 의 결과라도 양이 많으면 Summary를 하면서 계속 돌려야 하는게 효과 적일까요? 아니면 페이지 1, 2 등을 호출할 수 있게 어떻게 하던 LLM 에게 권한을 주는게 효과 적일까요? 더 괜찮은 방법이나 좋은 prompt 등이 있으시면 답변 부탁 드립니다. 감사합니다.
안녕하세요 좋은 수업제공해주셔서 많은 도움을 받고있습니다. langChain에 public 모델을 사용할때 개인정보 관련해서 질문이 있는데요 예를 들어 챗봇이나 자동 상담 기능에 적용을 한다고하면 입력이 매우 자유로울거같은데 개인정보에대해서는 어떻게 처리를 해야할까요? 기본적으로는 정규식으로 전처리를 하는데 100%보장된 작업은 아니라 현업에서는 어떻게 처리하는지 궁금합니다. 만약 개인정보 처리가 매우 중요하다면 public 모델(ex. chatGPT, gemini)은 사용 못하고 private 한 환경에 오픈소스로 운영할수밖에는 없을까요?
안녕하세요 교수님, Anthropic's latest models are currently only available to paid users. Please upgrade to a paid plan to use these models. 검색 내용 claude-4-sonnet으로 챗하였는데 해당 오류로 진행이 되지않습니다. 다른 모드 (gemini -2.5- flash)로 진행하면 전혀 다른 경로로 진행되네요 ㅠ
22강 진행 중 입니다. 마지막에 on a schedule을 연결하니, 한번의 채팅에 2초마다 새로운 사진이 계속 생성되었습니다. 혹시나 해서 Redis 화면을 보니, 데이터가 최신 데이터만 남아있고 이전 데이터는 사라진 것 같습니다. 그래서 ID가 schedule마다 새롭게 인식되어 사진이 계속 생성된 것 같은데, 어떻게 고칠 수 있을까요! ** Redis의 화면이 영상과 많이 바뀌어서 좀 어려웠는데, 이 과정에서 무슨 오류가 있었는지 모르겠네요
새로운 강의로 진행해도 계속 에러가 납니다. 1) 이 복사키로 진행했었고, 2)다른 분의 에러인 cmd npx.cmd https://github.com/google-gemini/gemini-cl 이걸로 진행해도 아래와 같이 계속 에러가 발생하여, node를 다시 install 해도 동일한 에러가 나옵니다....
PS C:\Users\USER\Desktop\new> npx https://github.com/google-gemini/gemini-cli npx : 이 시스템에서 스크립트를 실행할 수 없으므로 C:\Program Files\nodejs\npx.ps1 파일을 로드할 수 없습니다. 자세한 내용은 about_Execution_Policies( https://go.microsoft.com/fwlink/?LinkID=13 5170)를 참조하십시오. 위치 줄:1 문자:1 + npx https://github.com/google-gemini/gemini-cli + ~~~ + CategoryInfo : 보안 오류: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess 추가로 node 최신 버전으로 다운 받았습니다
에러로 진행 불가합니다. 프로그램문제라고 하여 모든프로그램 처음부터 삭제 재설치 하였고 , 그럼에도 같은에러납니다. PS C:\Users\혜지니\Desktop\뉴프로젝트> # Using npx (no installation required) >> npx https://github.com/google-gemini/gemini-cli npx : 'npx' 용어가 cmdlet, 함수, 스크립트 파일 또는 실행할 수 있는 프로그램 이름으로 인식되지 않 습니다. 이름이 정확한지 확인하고 경로가 포함된 경우 경로가 올바른지 검증한 다음 다시 시도하십시오 . 위치 줄:2 문자:1 + npx https://github.com/google-gemini/gemini-cli + ~~~ + CategoryInfo : ObjectNotFound: (npx:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
뭔가 제가 이해하기로는 Multi Agent의 개념이 Multiple tool로의 개념으로 이번 강의를 이해했는데요 맞을까요 ? 둘의 명시적인 기능의 차이는 없어보이는데 클린 코드 작성 측면에서는 더 Multi tools가 효과적으로 보입니다 다만, 명확히 왜 이렇게했지? 라는 생각이 계속 듭니다. 어떤 점에서 장점이 있다고 이해하면 될까요 ?