mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-03 20:13:03 +00:00
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
// Package client provides a Go client for Devour server.
|
|
package client
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
// Client is a Devour API client.
|
|
type Client struct {
|
|
baseURL string
|
|
httpClient *http.Client
|
|
}
|
|
|
|
// New creates a new Devour client.
|
|
func New(baseURL string) *Client {
|
|
return &Client{
|
|
baseURL: baseURL,
|
|
httpClient: &http.Client{},
|
|
}
|
|
}
|
|
|
|
// Query searches indexed documents.
|
|
func (c *Client) Query(ctx context.Context, query string, limit int) (*QueryResponse, error) {
|
|
// TODO: Implement HTTP request to /query
|
|
return nil, nil
|
|
}
|
|
|
|
// AddDocuments adds documents to the index.
|
|
func (c *Client) AddDocuments(ctx context.Context, docs []*Document) error {
|
|
// TODO: Implement HTTP request to /documents
|
|
return nil
|
|
}
|
|
|
|
// Status returns index status.
|
|
func (c *Client) Status(ctx context.Context) (*Status, error) {
|
|
// TODO: Implement HTTP request to /status
|
|
return nil, nil
|
|
}
|
|
|
|
// QueryResponse represents a query response.
|
|
type QueryResponse struct {
|
|
Query string `json:"query"`
|
|
Results []interface{} `json:"results"`
|
|
Total int `json:"total"`
|
|
TookMs int64 `json:"took_ms"`
|
|
}
|
|
|
|
// Document represents a document.
|
|
type Document struct {
|
|
ID string `json:"id"`
|
|
Content string `json:"content"`
|
|
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
|
}
|
|
|
|
// Status represents index status.
|
|
type Status struct {
|
|
Healthy bool `json:"healthy"`
|
|
DocumentCount int `json:"document_count"`
|
|
ChunkCount int `json:"chunk_count"`
|
|
}
|