Skip to content

Commit ec4308b

Browse files
committed
load .env config
1 parent 635e958 commit ec4308b

4 files changed

Lines changed: 17 additions & 20 deletions

File tree

server/.env.example

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,23 @@
11
# RAG Service Configuration
2-
# Copy this file to .env and adjust values as needed
2+
# Copy to .env and adjust as needed. All values have sensible defaults.
33

4-
# Server Configuration
4+
# Server
55
GRPC_PORT=9090
66
HTTP_PORT=8080
7-
ENVIRONMENT=development
8-
LOG_LEVEL=debug
7+
LOG_LEVEL=info
98

10-
# PostgreSQL Configuration
9+
# PostgreSQL
1110
DATABASE_URL=postgres://rag:rag@localhost:5432/rag?sslmode=disable
1211

13-
# Qdrant Configuration
12+
# Qdrant
1413
QDRANT_URL=http://localhost:6333
15-
QDRANT_GRPC_URL=localhost:6334
1614

17-
# Ollama Configuration
15+
# Ollama
1816
OLLAMA_URL=http://localhost:11434
1917
OLLAMA_EMBEDDING_MODEL=nomic-embed-text
2018
OLLAMA_LLM_MODEL=llama3.2
2119

22-
# Auth Configuration
23-
JWT_SECRET=change-this-in-production-use-a-random-32-byte-key
24-
JWT_EXPIRY=24h
25-
SESSION_SECRET=change-this-in-production-use-a-random-32-byte-key
26-
27-
# Default Tenant Configuration
20+
# RAG defaults (optional)
2821
DEFAULT_CHUNK_METHOD=semantic
29-
DEFAULT_CHUNK_TARGET_SIZE=512
30-
DEFAULT_CHUNK_MAX_SIZE=1024
31-
DEFAULT_CHUNK_OVERLAP=50
32-
DEFAULT_TOP_K=5
33-
DEFAULT_MIN_SCORE=0.7
22+
DEFAULT_TOP_K=4
23+
DEFAULT_MIN_SCORE=0.35

server/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ require (
2727
github.com/jackc/pgpassfile v1.0.0 // indirect
2828
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
2929
github.com/jackc/puddle/v2 v2.2.2 // indirect
30+
github.com/joho/godotenv v1.5.1 // indirect
3031
golang.org/x/sync v0.19.0 // indirect
3132
golang.org/x/sys v0.40.0 // indirect
3233
golang.org/x/text v0.33.0 // indirect

server/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ github.com/jackc/pgx/v5 v5.8.0 h1:TYPDoleBBme0xGSAX3/+NujXXtpZn9HBONkQC7IEZSo=
4141
github.com/jackc/pgx/v5 v5.8.0/go.mod h1:QVeDInX2m9VyzvNeiCJVjCkNFqzsNb43204HshNSZKw=
4242
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
4343
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
44+
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
45+
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
4446
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo=
4547
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs=
4648
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde h1:x0TT0RDC7UhAVbbWWBzr41ElhJx5tXPWkIHA2HWPRuw=

server/internal/config/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"time"
55

66
"github.com/caarlos0/env/v10"
7+
"github.com/joho/godotenv"
78
)
89

910
// Config holds all configuration for the RAG service
@@ -40,8 +41,11 @@ type Config struct {
4041
DefaultMinScore float32 `env:"DEFAULT_MIN_SCORE" envDefault:"0.35"`
4142
}
4243

43-
// Load loads configuration from environment variables
44+
// Load loads configuration from .env file (if present) and environment variables
4445
func Load() (*Config, error) {
46+
// Load .env file if it exists (ignore error if not found)
47+
_ = godotenv.Load()
48+
4549
cfg := &Config{}
4650
if err := env.Parse(cfg); err != nil {
4751
return nil, err

0 commit comments

Comments
 (0)