|
|
""" |
|
|
GeoAI Coding Agent - Configuration |
|
|
=================================== |
|
|
Configuration settings for the Geospatial AI Coding Assistant. |
|
|
Supports multiple models via HuggingFace Inference Providers. |
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
AVAILABLE_MODELS = { |
|
|
"DeepSeek V3.2": { |
|
|
"model_id": "deepseek-ai/DeepSeek-V3.2", |
|
|
"provider": "novita", |
|
|
}, |
|
|
"Kimi K2 Instruct": { |
|
|
"model_id": "moonshotai/Kimi-K2-Instruct", |
|
|
"provider": "novita", |
|
|
}, |
|
|
"Llama 3.1 8B": { |
|
|
"model_id": "meta-llama/Llama-3.1-8B-Instruct", |
|
|
"provider": "novita", |
|
|
}, |
|
|
"MiniMax M2.1": { |
|
|
"model_id": "MiniMaxAI/MiniMax-M2.1", |
|
|
"provider": "novita", |
|
|
}, |
|
|
"GLM 4.7 Flash": { |
|
|
"model_id": "zai-org/GLM-4.7-Flash", |
|
|
"provider": "novita", |
|
|
}, |
|
|
"Mistral 7B v0.2": { |
|
|
"model_id": "mistralai/Mistral-7B-Instruct-v0.2", |
|
|
"provider": "featherless-ai", |
|
|
}, |
|
|
} |
|
|
|
|
|
|
|
|
DEFAULT_MODEL = "DeepSeek V3.2" |
|
|
|
|
|
|
|
|
MAX_NEW_TOKENS = 2048 |
|
|
TEMPERATURE = 0.3 |
|
|
TOP_P = 0.9 |
|
|
REPETITION_PENALTY = 1.1 |
|
|
|
|
|
|
|
|
SUPPORTED_LANGUAGES = { |
|
|
"python": {"extension": ".py", "highlight": "python", "mime": "text/x-python"}, |
|
|
"java": {"extension": ".java", "highlight": "java", "mime": "text/x-java"}, |
|
|
"cpp": {"extension": ".cpp", "highlight": "cpp", "mime": "text/x-c++src"}, |
|
|
"c": {"extension": ".c", "highlight": "c", "mime": "text/x-csrc"}, |
|
|
"javascript": {"extension": ".js", "highlight": "javascript", "mime": "text/javascript"}, |
|
|
"typescript": {"extension": ".ts", "highlight": "typescript", "mime": "text/typescript"}, |
|
|
"rust": {"extension": ".rs", "highlight": "rust", "mime": "text/x-rustsrc"}, |
|
|
"markdown": {"extension": ".md", "highlight": "markdown", "mime": "text/markdown"}, |
|
|
"json": {"extension": ".json", "highlight": "json", "mime": "application/json"}, |
|
|
"bash": {"extension": ".sh", "highlight": "bash", "mime": "text/x-sh"}, |
|
|
} |
|
|
|
|
|
|
|
|
SYSTEM_PROMPT = """You are GeoAI Coding Agent, an expert Geospatial Software Engineer and educator specialized in: |
|
|
|
|
|
## Core Expertise |
|
|
- **GDAL/OGR**: Raster/vector processing, format conversions, coordinate transformations |
|
|
- **Rasterio & Fiona**: Pythonic interfaces for raster/vector I/O with NumPy integration |
|
|
- **GeoPandas & Shapely**: Spatial dataframes, geometric operations, spatial joins |
|
|
- **PyProj & PROJ**: Coordinate reference systems, transformations, geodetic calculations |
|
|
- **xarray & rioxarray**: Large-scale raster processing, NetCDF/Zarr, lazy loading |
|
|
|
|
|
## Language Proficiency |
|
|
Python, Java, C/C++, JavaScript, TypeScript, Rust |
|
|
|
|
|
## Response Guidelines |
|
|
Your audience includes beginner and intermediate learners. Provide educational yet practical responses. |
|
|
|
|
|
1. **Start with a brief overview**: Explain what the code will accomplish in 1-2 sentences |
|
|
2. **Provide complete, working code**: Include imports, error handling, and type hints (Python) |
|
|
3. **Add inline comments**: Explain key lines, especially geospatial-specific operations |
|
|
4. **Explain the logic**: After the code, provide a "How It Works" section explaining: |
|
|
- The overall approach/algorithm |
|
|
- Why specific libraries or functions are used |
|
|
- What each major step does |
|
|
5. **Set expectations**: Describe what output to expect (files created, data returned, etc.) |
|
|
6. **Include tips**: Add beginner-friendly tips, common pitfalls, or alternatives when relevant |
|
|
7. **Format code blocks** with language specification: ```python, ```java, ```cpp, etc. |
|
|
|
|
|
## Response Structure |
|
|
### What This Code Does |
|
|
Brief overview of the solution. |
|
|
|
|
|
```[language] |
|
|
# Well-commented code here |
|
|
``` |
|
|
|
|
|
### How It Works |
|
|
1. **Step 1 name**: Explanation of what this step does and why |
|
|
2. **Step 2 name**: Continue with key steps... |
|
|
|
|
|
### What to Expect |
|
|
- Describe the output (files, data structures, visualizations) |
|
|
- Any dependencies to install |
|
|
|
|
|
### 💡 Tips for Beginners |
|
|
- Helpful tips, common mistakes to avoid, or alternative approaches |
|
|
|
|
|
Be thorough but not overwhelming. Focus on building understanding while providing production-quality code.""" |
|
|
|
|
|
|
|
|
EXAMPLE_PROMPTS = [ |
|
|
"Read a GeoTIFF with rasterio and calculate NDVI from Sentinel-2 bands", |
|
|
"Convert shapefile to GeoJSON using GDAL/OGR in Python", |
|
|
"Reproject a raster from EPSG:4326 to EPSG:32632 using rasterio", |
|
|
"Clip a large COG raster to a polygon boundary using rioxarray", |
|
|
"Create a spatial join between two GeoDataFrames in GeoPandas", |
|
|
"Read and mosaic multiple NetCDF files with xarray", |
|
|
"Implement parallel raster processing with GDAL in C++", |
|
|
"Calculate zonal statistics using rasterstats in Python", |
|
|
] |
|
|
|
|
|
|
|
|
NOTEBOOK_TEMPLATE = '''{{ |
|
|
"cells": [ |
|
|
{{ |
|
|
"cell_type": "markdown", |
|
|
"metadata": {{}}, |
|
|
"source": [ |
|
|
"# GeoAI Generated Code\\n", |
|
|
"\\n", |
|
|
"Generated by GeoAI Coding Agent\\n", |
|
|
"\\n", |
|
|
"## Query\\n", |
|
|
"{query}" |
|
|
] |
|
|
}}, |
|
|
{{ |
|
|
"cell_type": "code", |
|
|
"execution_count": null, |
|
|
"metadata": {{}}, |
|
|
"outputs": [], |
|
|
"source": {code_cells} |
|
|
}} |
|
|
], |
|
|
"metadata": {{ |
|
|
"kernelspec": {{ |
|
|
"display_name": "Python 3", |
|
|
"language": "python", |
|
|
"name": "python3" |
|
|
}}, |
|
|
"language_info": {{ |
|
|
"name": "python", |
|
|
"version": "3.10.0" |
|
|
}} |
|
|
}}, |
|
|
"nbformat": 4, |
|
|
"nbformat_minor": 4 |
|
|
}}''' |
|
|
|
|
|
MARKDOWN_TEMPLATE = """# GeoAI Generated Code |
|
|
|
|
|
## Query |
|
|
{query} |
|
|
|
|
|
## Response |
|
|
{response} |
|
|
|
|
|
--- |
|
|
*Generated by GeoAI Coding Agent* |
|
|
""" |
|
|
|