Spaces:
Sleeping
Sleeping
Update app.py
Browse files10 unmodified lines1112131415161718192064 unmodified lines858687888990915 unmodified lines97989910010110213 unmodified lines11611711811912012112210 unmodified linesfrom langchain_google_genai import ChatGoogleGenerativeAIfrom langchain.agents import create_agentfrom langchain_core.messages import HumanMessagefrom langgraph.store.memory import InMemoryStoremy_store = InMemoryStore()# --- GLOBAL STATE ---MCP_URL = "https://Codemaster67-ResearchPaperMCP.hf.space/sse"64 unmodified linesllm,mcp_tools,system_prompt = system_prompt,store=my_store)return {"status": "Success", "message": f"Agent initialized with {model_name}"}5 unmodified lines@app.post("/chat")async def chat(message: str = Form(...),file: Optional[UploadFile] = File(None)):global agent_executor13 unmodified linestry:inputs = {"messages": [HumanMessage(content=message_content)]}response = await agent_executor.ainvoke(inputs)# --- NEW: PRINT TOOL CALLS ---for msg in response["messages"]:10 unmodified lines1112131415161718192064 unmodified lines858687888990915 unmodified lines97989910010110210313 unmodified lines11711811912012112212312412512610 unmodified linesfrom langchain_google_genai import ChatGoogleGenerativeAIfrom langchain.agents import create_agentfrom langchain_core.messages import HumanMessagefrom langgraph.checkpoint.memory import MemorySavermemory_saver = MemorySaver()# --- GLOBAL STATE ---MCP_URL = "https://Codemaster67-ResearchPaperMCP.hf.space/sse"64 unmodified linesllm,mcp_tools,system_prompt = system_prompt,checkpointer=memory_saver)return {"status": "Success", "message": f"Agent initialized with {model_name}"}5 unmodified lines@app.post("/chat")async def chat(message: str = Form(...),session_id: str = Form("default_thread"),file: Optional[UploadFile] = File(None)):global agent_executor13 unmodified linestry:inputs = {"messages": [HumanMessage(content=message_content)]}# --- NEW: PASS THREAD ID IN CONFIG ---config = {"configurable": {"thread_id": session_id}}response = await agent_executor.ainvoke(inputs, config=config)# --- NEW: PRINT TOOL CALLS ---for msg in response["messages"]:
app.py+8-4