Skip to content

Commit

Permalink
enh: add simple boilerplate for AI challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasthomas committed Jun 17, 2024
1 parent 1041561 commit 463b43c
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 4 deletions.
24 changes: 24 additions & 0 deletions ai/boilerplate/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.8'

services:
postgres:
image: postgres:latest
environment:
POSTGRES_DB: yourdbname
POSTGRES_USER: youruser
POSTGRES_PASSWORD: yourpassword
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data

qdrant:
image: qdrant/qdrant
ports:
- "6333:6333"
volumes:
- qdrant-data:/qdrant/storage

volumes:
postgres-data:
qdrant-data:
7 changes: 7 additions & 0 deletions ai/boilerplate/goapp/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=youruser
POSTGRES_PASSWORD=yourpassword
POSTGRES_DB=yourdbname
QDRANT_HOST=localhost
QDRANT_PORT=6333
8 changes: 8 additions & 0 deletions ai/boilerplate/goapp/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module goapp

go 1.22.3

require (
github.com/joho/godotenv v1.5.1
github.com/lib/pq v1.10.9
)
4 changes: 4 additions & 0 deletions ai/boilerplate/goapp/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
43 changes: 43 additions & 0 deletions ai/boilerplate/goapp/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
"database/sql"
"fmt"
"log"
"net/http"
"os"

"github.com/joho/godotenv"
_ "github.com/lib/pq"
)

func main() {
// Load .env file
err := godotenv.Load()
if err != nil {
log.Fatalf("Error loading .env file: %v", err)
}

// Connect to PostgreSQL
pgConnStr := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable",
os.Getenv("POSTGRES_HOST"), os.Getenv("POSTGRES_PORT"), os.Getenv("POSTGRES_USER"), os.Getenv("POSTGRES_PASSWORD"), os.Getenv("POSTGRES_DB"))
db, err := sql.Open("postgres", pgConnStr)
if err != nil {
log.Fatalf("Error connecting to PostgreSQL: %v", err)
}
defer db.Close()

// Connect to Qdrant
qdrantURL := fmt.Sprintf("http://%s:%s", os.Getenv("QDRANT_HOST"), os.Getenv("QDRANT_PORT"))
resp, err := http.Get(qdrantURL + "/v1/collections")
if err != nil {
log.Fatalf("Error connecting to Qdrant: %v", err)
}
defer resp.Body.Close()

// Simple HTTP server
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Connected to PostgreSQL and Qdrant successfully!")
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
4 changes: 2 additions & 2 deletions ai/chats.json
Git LFS file not shown
11 changes: 9 additions & 2 deletions ai/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,23 @@ You are tasked with implementing a retrieval system for a messaging app. It must

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.

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.

Functional requirements:

- [ ] Users can search through their chat history using natural language.
The question we will be asking:
- [ ] 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:
- Matthias' id is: `018f2685-a936-44a9-8ff4-9ef0c98289b8`
- Aymeric's id is: `82247543-5c2d-46d9-9a0d-fe25482922b5`
- David's id is: `2d614bef-2b01-4021-b63a-9d04658536f3`
- Example of the questions we will be asking:
- "What did Aymeric and I discuss last week?"
- "Where does Aymeric live?"
- "What did David tell me about the roadmap?"
- [ ] Your solution is multitenant. Users can only search their own history using their user ID.
- [ ] Users can query their chat history through an API endpoint.



## Bonus

Some topics that we find interesting to dig into:
Expand Down

0 comments on commit 463b43c

Please sign in to comment.