Update project files
This commit is contained in:
32
README.md
32
README.md
@@ -1,6 +1,6 @@
|
||||
# Gemini Fullstack LangGraph Quickstart
|
||||
# OpenAI-Compatible Fullstack LangGraph Quickstart
|
||||
|
||||
This project demonstrates a fullstack application using a React frontend and a LangGraph-powered backend agent. The agent is designed to perform comprehensive research on a user's query by dynamically generating search terms, querying the web using Google Search, reflecting on the results to identify knowledge gaps, and iteratively refining its search until it can provide a well-supported answer with citations. This application serves as an example of building research-augmented conversational AI using LangGraph and Google's Gemini models.
|
||||
This project demonstrates a fullstack application using a React frontend and a LangGraph-powered backend agent. The agent performs comprehensive research on a user's query by dynamically generating search terms, querying the web with Tavily, reflecting on the results to identify knowledge gaps, and iteratively refining its search until it can provide a well-supported answer with citations. This application serves as an example of building research-augmented conversational AI using LangGraph and an OpenAI-compatible chat model.
|
||||
|
||||
<img src="./app.png" title="Gemini Fullstack LangGraph" alt="Gemini Fullstack LangGraph" width="90%">
|
||||
|
||||
@@ -8,8 +8,8 @@ This project demonstrates a fullstack application using a React frontend and a L
|
||||
|
||||
- 💬 Fullstack application with a React frontend and LangGraph backend.
|
||||
- 🧠 Powered by a LangGraph agent for advanced research and conversational AI.
|
||||
- 🔍 Dynamic search query generation using Google Gemini models.
|
||||
- 🌐 Integrated web research via Google Search API.
|
||||
- 🔍 Dynamic search query generation using an OpenAI-compatible chat model.
|
||||
- 🌐 Integrated web research via Tavily Search.
|
||||
- 🤔 Reflective reasoning to identify knowledge gaps and refine searches.
|
||||
- 📄 Generates answers with citations from gathered sources.
|
||||
- 🔄 Hot-reloading for both frontend and backend during development.
|
||||
@@ -29,10 +29,15 @@ Follow these steps to get the application running locally for development and te
|
||||
|
||||
- Node.js and npm (or yarn/pnpm)
|
||||
- Python 3.11+
|
||||
- **`GEMINI_API_KEY`**: The backend agent requires a Google Gemini API key.
|
||||
- **`OPENAI_API_KEY`**: The backend agent requires an OpenAI-compatible API key.
|
||||
- **`OPENAI_BASE_URL`**: Set this to `https://open.bigmodel.cn/api/paas/v4` for BigModel.
|
||||
- **`TAVILY_API_KEY`**: Required for web search.
|
||||
1. Navigate to the `backend/` directory.
|
||||
2. Create a file named `.env` by copying the `backend/.env.example` file.
|
||||
3. Open the `.env` file and add your Gemini API key: `GEMINI_API_KEY="YOUR_ACTUAL_API_KEY"`
|
||||
3. Open the `.env` file and add:
|
||||
`OPENAI_API_KEY="YOUR_ACTUAL_API_KEY"`
|
||||
`OPENAI_BASE_URL="https://open.bigmodel.cn/api/paas/v4"`
|
||||
`TAVILY_API_KEY="YOUR_ACTUAL_TAVILY_API_KEY"`
|
||||
|
||||
**2. Install Dependencies:**
|
||||
|
||||
@@ -67,11 +72,11 @@ The core of the backend is a LangGraph agent defined in `backend/src/agent/graph
|
||||
|
||||
<img src="./agent.png" title="Agent Flow" alt="Agent Flow" width="50%">
|
||||
|
||||
1. **Generate Initial Queries:** Based on your input, it generates a set of initial search queries using a Gemini model.
|
||||
2. **Web Research:** For each query, it uses the Gemini model with the Google Search API to find relevant web pages.
|
||||
3. **Reflection & Knowledge Gap Analysis:** The agent analyzes the search results to determine if the information is sufficient or if there are knowledge gaps. It uses a Gemini model for this reflection process.
|
||||
1. **Generate Initial Queries:** Based on your input, it generates a set of initial search queries using the configured chat model.
|
||||
2. **Web Research:** For each query, it uses Tavily Search to gather relevant web pages and snippets.
|
||||
3. **Reflection & Knowledge Gap Analysis:** The agent analyzes the search results to determine if the information is sufficient or if there are knowledge gaps. It uses the configured chat model for this reflection process.
|
||||
4. **Iterative Refinement:** If gaps are found or the information is insufficient, it generates follow-up queries and repeats the web research and reflection steps (up to a configured maximum number of loops).
|
||||
5. **Finalize Answer:** Once the research is deemed sufficient, the agent synthesizes the gathered information into a coherent answer, including citations from the web sources, using a Gemini model.
|
||||
5. **Finalize Answer:** Once the research is deemed sufficient, the agent synthesizes the gathered information into a coherent answer, including citations from the web sources, using the configured chat model.
|
||||
|
||||
## CLI Example
|
||||
|
||||
@@ -97,12 +102,12 @@ _Note: If you are not running the docker-compose.yml example or exposing the bac
|
||||
|
||||
Run the following command from the **project root directory**:
|
||||
```bash
|
||||
docker build -t gemini-fullstack-langgraph -f Dockerfile .
|
||||
docker build -t openai-fullstack-langgraph -f Dockerfile .
|
||||
```
|
||||
**2. Run the Production Server:**
|
||||
|
||||
```bash
|
||||
GEMINI_API_KEY=<your_gemini_api_key> LANGSMITH_API_KEY=<your_langsmith_api_key> docker-compose up
|
||||
OPENAI_API_KEY=<your_api_key> OPENAI_BASE_URL=https://open.bigmodel.cn/api/paas/v4 TAVILY_API_KEY=<your_tavily_api_key> LANGSMITH_API_KEY=<your_langsmith_api_key> docker-compose up
|
||||
```
|
||||
|
||||
Open your browser and navigate to `http://localhost:8123/app/` to see the application. The API will be available at `http://localhost:8123`.
|
||||
@@ -113,7 +118,8 @@ Open your browser and navigate to `http://localhost:8123/app/` to see the applic
|
||||
- [Tailwind CSS](https://tailwindcss.com/) - For styling.
|
||||
- [Shadcn UI](https://ui.shadcn.com/) - For components.
|
||||
- [LangGraph](https://github.com/langchain-ai/langgraph) - For building the backend research agent.
|
||||
- [Google Gemini](https://ai.google.dev/models/gemini) - LLM for query generation, reflection, and answer synthesis.
|
||||
- OpenAI-compatible chat model - LLM for query generation, reflection, and answer synthesis.
|
||||
- [Tavily](https://tavily.com/) - Web search for research retrieval.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
Reference in New Issue
Block a user