geoai-coding-agent / config.py
rifatSDAS's picture
Initial commit: GeoAI Coding Agent app
2206408
"""
GeoAI Coding Agent - Configuration
===================================
Configuration settings for the Geospatial AI Coding Assistant.
Uses Qwen/Qwen2.5-Coder-7B-Instruct via HuggingFace Inference API.
"""
# Model Configuration
MODEL_ID = "Qwen/Qwen2.5-Coder-7B-Instruct"
MAX_NEW_TOKENS = 2048
TEMPERATURE = 0.3
TOP_P = 0.9
REPETITION_PENALTY = 1.1
# Supported Languages
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"},
}
# Geospatial System Prompt
SYSTEM_PROMPT = """You are GeoAI Coding Agent, an expert Geospatial Software Engineer 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
1. **Be concise**: Provide working code with minimal but meaningful explanations
2. **Code first**: Lead with the solution, explain key points after
3. **Best practices**: Include error handling, type hints (Python), and memory efficiency
4. **Geospatial focus**: Optimize for large Earth Observation datasets
5. **Format code blocks** with language specification: ```python, ```java, ```cpp, etc.
## Response Structure
```[language]
# Your code here
```
**Key Points:**
- Brief explanation of the approach (2-3 sentences max)
- Any important caveats or dependencies
Do NOT include lengthy introductions or excessive explanations. Users are professionals who need working code quickly."""
# Example prompts for UI
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",
]
# File download templates
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*
"""