Skip to content

Commit 463b43c

Browse files
enh: add simple boilerplate for AI challenge
1 parent 1041561 commit 463b43c

File tree

7 files changed

+97
-4
lines changed

7 files changed

+97
-4
lines changed

ai/boilerplate/docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: '3.8'
2+
3+
services:
4+
postgres:
5+
image: postgres:latest
6+
environment:
7+
POSTGRES_DB: yourdbname
8+
POSTGRES_USER: youruser
9+
POSTGRES_PASSWORD: yourpassword
10+
ports:
11+
- "5432:5432"
12+
volumes:
13+
- postgres-data:/var/lib/postgresql/data
14+
15+
qdrant:
16+
image: qdrant/qdrant
17+
ports:
18+
- "6333:6333"
19+
volumes:
20+
- qdrant-data:/qdrant/storage
21+
22+
volumes:
23+
postgres-data:
24+
qdrant-data:

ai/boilerplate/goapp/.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
POSTGRES_HOST=localhost
2+
POSTGRES_PORT=5432
3+
POSTGRES_USER=youruser
4+
POSTGRES_PASSWORD=yourpassword
5+
POSTGRES_DB=yourdbname
6+
QDRANT_HOST=localhost
7+
QDRANT_PORT=6333

ai/boilerplate/goapp/go.mod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module goapp
2+
3+
go 1.22.3
4+
5+
require (
6+
github.com/joho/godotenv v1.5.1
7+
github.com/lib/pq v1.10.9
8+
)

ai/boilerplate/goapp/go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
2+
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
3+
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
4+
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=

ai/boilerplate/goapp/main.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package main
2+
3+
import (
4+
"database/sql"
5+
"fmt"
6+
"log"
7+
"net/http"
8+
"os"
9+
10+
"github.com/joho/godotenv"
11+
_ "github.com/lib/pq"
12+
)
13+
14+
func main() {
15+
// Load .env file
16+
err := godotenv.Load()
17+
if err != nil {
18+
log.Fatalf("Error loading .env file: %v", err)
19+
}
20+
21+
// Connect to PostgreSQL
22+
pgConnStr := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable",
23+
os.Getenv("POSTGRES_HOST"), os.Getenv("POSTGRES_PORT"), os.Getenv("POSTGRES_USER"), os.Getenv("POSTGRES_PASSWORD"), os.Getenv("POSTGRES_DB"))
24+
db, err := sql.Open("postgres", pgConnStr)
25+
if err != nil {
26+
log.Fatalf("Error connecting to PostgreSQL: %v", err)
27+
}
28+
defer db.Close()
29+
30+
// Connect to Qdrant
31+
qdrantURL := fmt.Sprintf("http://%s:%s", os.Getenv("QDRANT_HOST"), os.Getenv("QDRANT_PORT"))
32+
resp, err := http.Get(qdrantURL + "/v1/collections")
33+
if err != nil {
34+
log.Fatalf("Error connecting to Qdrant: %v", err)
35+
}
36+
defer resp.Body.Close()
37+
38+
// Simple HTTP server
39+
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
40+
fmt.Fprintf(w, "Connected to PostgreSQL and Qdrant successfully!")
41+
})
42+
log.Fatal(http.ListenAndServe(":8080", nil))
43+
}

ai/chats.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:c0d45b1c1263d903491cdcaafc4aa2fb61d112dbc516c1456ccbfaf8567aff1c
3-
size 59219057
2+
oid sha256:20f82c13ec0d446b79a3035932aeb2da6d55bb484e8642204f1327864da6a879
3+
size 59219437

ai/readme.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@ You are tasked with implementing a retrieval system for a messaging app. It must
1414

1515
We enforce no technical constraints: you are free to choose the language, data layer, network protocol, and design your API as you see fit. You are purposefully being given a lot of freedom here, and you will not be judged on these decisions alone, but we will challenge the understanding of the trade-offs you make.
1616

17+
You can find a simple boilerplate for a Go/PGSQL/Qdrant app [here](https://github.com/hearthandsinc/challenges/tree/main/ai/boilterplate), but again, you are free to use any technology you want.
18+
1719
Functional requirements:
1820

19-
- [ ] Users can search through their chat history using natural language.
20-
The question we will be asking:
21+
- [ ] Users can search through their chat history using natural language. To evaluate the solution, we'll be asking questions from Matthias, Aymeric and David's point of view:
22+
- Matthias' id is: `018f2685-a936-44a9-8ff4-9ef0c98289b8`
23+
- Aymeric's id is: `82247543-5c2d-46d9-9a0d-fe25482922b5`
24+
- David's id is: `2d614bef-2b01-4021-b63a-9d04658536f3`
25+
- Example of the questions we will be asking:
2126
- "What did Aymeric and I discuss last week?"
2227
- "Where does Aymeric live?"
2328
- "What did David tell me about the roadmap?"
2429
- [ ] Your solution is multitenant. Users can only search their own history using their user ID.
2530
- [ ] Users can query their chat history through an API endpoint.
2631

32+
33+
2734
## Bonus
2835

2936
Some topics that we find interesting to dig into:

0 commit comments

Comments
 (0)