Spaces:
Sleeping
Sleeping
metadata
title: Crop Diag Module
emoji: 🐢
colorFrom: gray
colorTo: pink
sdk: docker
pinned: false
short_description: Crop diagnosis module
app_port: 8000
Crop Diagnosis Knowledge Graph Module
A powerful tool for querying crop diagnosis knowledge graphs using LangChain and Neo4j. This module provides an API interface to interact with a knowledge graph containing agricultural and crop disease information.
Features
- Natural language querying of crop diagnosis knowledge graph
- Integration with LangChain for intelligent query processing
- Neo4j database backend for efficient graph operations
- RESTful API interface
- Environment-based configuration
Prerequisites
- Python 3.8+
- Neo4j Database (version 5.x)
- OpenAI API key (for LangChain integration)
Installation
- Clone the repository:
git clone [repository-url]
cd crop-diag-module
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Configuration
- Create a
.env
file in the project root:
cp .env.example .env
- Edit the
.env
file with your configuration:
# Neo4j Configuration
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=your_password
# API Configuration
API_HOST=0.0.0.0
API_PORT=8000
DEBUG=True
# LangChain Configuration
OPENAI_API_KEY=your_openai_api_key
Replace the following values:
NEO4J_URI
: Your Neo4j database URINEO4J_USER
: Neo4j usernameNEO4J_PASSWORD
: Neo4j passwordOPENAI_API_KEY
: Your OpenAI API key
Running the Application
- Start the FastAPI server:
uvicorn app.main:app --reload
- Access the API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Usage
Query the Knowledge Graph
curl -X POST "http://localhost:8000/api/query" \
-H "Content-Type: application/json" \
-d '{"question": "What are the symptoms of rice blast disease?"}'
Project Structure
crop-diag-module/
├── app/
│ ├── api/ # API routes and endpoints
│ ├── core/ # Core functionality
│ ├── models/ # Data models
│ └── utils/ # Utility functions
├── KG/ # Knowledge Graph data
├── tests/ # Test cases
├── requirements.txt # Project dependencies
└── .env # Environment configuration
Development
Running Tests
pytest tests/
Code Style
This project follows PEP 8 style guidelines. Use the following command to check code style:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
uvicorn app.main:app --reload
License
[Add your license information here]
Contributing
[Add contribution guidelines here]