- Add web_search built-in tool that searches via DuckDuckGo - Add get_location tool to get user's geographic location - Create backend search proxy endpoint (/api/v1/proxy/search) - DuckDuckGo HTML scraping with title, URL, and snippet extraction - Geolocation with OpenStreetMap reverse geocoding for city/country - Fix StreamingIndicator visibility in dark mode - Improve tool descriptions to encourage proper tool usage - Better error messages with suggestions when location fails 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package api
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// SetupRoutes configures all API routes
|
|
func SetupRoutes(r *gin.Engine, db *sql.DB, ollamaURL string) {
|
|
// Health check
|
|
r.GET("/health", func(c *gin.Context) {
|
|
c.JSON(200, gin.H{"status": "ok"})
|
|
})
|
|
|
|
// API v1 routes
|
|
v1 := r.Group("/api/v1")
|
|
{
|
|
// Chat routes
|
|
chats := v1.Group("/chats")
|
|
{
|
|
chats.GET("", ListChatsHandler(db))
|
|
chats.POST("", CreateChatHandler(db))
|
|
chats.GET("/:id", GetChatHandler(db))
|
|
chats.PUT("/:id", UpdateChatHandler(db))
|
|
chats.DELETE("/:id", DeleteChatHandler(db))
|
|
|
|
// Message routes (nested under chats)
|
|
chats.POST("/:id/messages", CreateMessageHandler(db))
|
|
}
|
|
|
|
// Sync routes
|
|
sync := v1.Group("/sync")
|
|
{
|
|
sync.POST("/push", PushChangesHandler(db))
|
|
sync.GET("/pull", PullChangesHandler(db))
|
|
}
|
|
|
|
// URL fetch proxy (for tools that need to fetch external URLs)
|
|
v1.POST("/proxy/fetch", URLFetchProxyHandler())
|
|
|
|
// Web search proxy (for web_search tool)
|
|
v1.POST("/proxy/search", WebSearchProxyHandler())
|
|
|
|
// Ollama proxy (optional)
|
|
v1.Any("/ollama/*path", OllamaProxyHandler(ollamaURL))
|
|
}
|
|
}
|