DeepSearch Demo of Agentscope-Runtime with Langgraph / Qwen and Quark search
This project is modified from Gemini Fullstack LangGraph Quickstart.
It contains following key features:
- We use LangGraph to build an agent (directed state graph) with the help of Qwen and Quark search.
- The agent is wrapped as an Agentscope-Runtime agent and deployed as a service.
- The interaction with the agent is done through a simple CLI.
Click following image to watch the video demo:
🌳 Project Structure
├── src # Source code directory containing the core functionalities and modules
│ ├── init.py # Initialization script, possibly setting up environment or configurations
│ ├── configuration.py # Module for handling application configurations and settings
│ ├── custom_search_tool.py # Implements custom search functionality or tool
│ ├── graph_openai_compatible.py # Module for OpenAI-compatible graph operations or integrations
│ ├── llm_prompts.py # Contains large language model prompts used in the application
│ ├── llm_utils.py # Utility functions for handling large language model operations
│ ├── main.py # Main entry script to launch or execute the application
│ ├── state.py # Manages application state or data persistence
│ ├── tools_and_schemas.py # Defines various tools and data schemas used by the application
│ └── utils.py # General utility functions used across the application
└── README.md # Project documentation file providing information and usage instructions
Architecture
The architecture of the demo is shown in the following diagram:
graph LR;
subgraph As["AgentScope Runtime"]
F[Agent Engine]
end
subgraph Bs["LangGraph"]
B1[Web Research]
B2[Reflection]
B3[Answer Generation]
B0[Generation Queries]
B0 --> B1
B1 --> B2
B2 --> |if insufficient| B1
B2 --> |if sufficient| B3
end
subgraph Cs["CLI Service"]
C[main] --> S[WebSearchGraph]
end
As --> Bs
user --> |user input| C
S--> F
📖 Overview
This demo demonstrates how to build a sophisticated research agent using:
- Qwen as the underlying language model
- LangGraph for defining complex agent workflows
- Custom search tools for information retrieval
- State management for multi-step reasoning
The implementation showcases advanced patterns for building agentic systems that can perform deep research tasks through iterative thinking and tool usage.
⚙️ Components
Core Modules
configuration.py: Configuration management for the agentcustom_search_tool.py: Custom search functionality implementationgraph_openai_compatible.py: LangGraph implementation with OpenAI compatibilityllm_prompts.py: Prompt templates for different agent behaviorsllm_utils.py: Utility functions for LLM interactionsmain.py: Main entry point for the applicationstate.py: State management for the LangGraph workflowtools_and_schemas.py: Tool definitions and data schemasutils.py: General utility functions
🚀 Getting Started
Install
Follow these steps to get the application running locally for development and testing.
1. Prerequisites:
- Python 3.11+
- Create a file named
.envby copying the.env.examplefile. DASHSCOPE_API_KEY: addDASHSCOPE_API_KEY="YOUR_ACTUAL_API_KEY"if you use dashscope API.- Quark Search API KEY: add
QUARK_AK=''andQUARK_SK=''to.envfile if you use quark search API.
2. Install Dependencies:
pip install -r requirements.txt
Usage
Start the CLI Service.
cd src
python main.py
After that you can use the CLI to interact with the agent.
🛠️ Features
qwenintegration for advanced language understandinglanggraphfor complex workflow management- Custom search tools for information retrieval
- Multi-step reasoning capabilities
- Stateful agent interactions
- Research-focused agent workflows
ℹ️ Getting help
If you have any questions or if you found any problems with this demo, please report through GitHub issues.
📄 License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
