Skip to content

Commit

Permalink
💾 Saved.
Browse files Browse the repository at this point in the history
  • Loading branch information
k33g committed Feb 13, 2025
1 parent 57e44a0 commit 9e80b2a
Show file tree
Hide file tree
Showing 15 changed files with 184 additions and 26 deletions.
1 change: 1 addition & 0 deletions examples/69-web-chat-bot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 🚧 WIP
21 changes: 14 additions & 7 deletions examples/69-web-chat-bot/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
FROM golang:1.23.1-alpine AS builder

WORKDIR /app
COPY main.go .
COPY go.mod .

RUN <<EOF
go mod tidy
go build -o web-chat-bot
EOF
# Copy the entire parakeet project
COPY . .

# Move to the backend directory
WORKDIR /app/examples/69-web-chat-bot/backend

# Update go.mod to point to the root of the copied parakeet code
RUN go mod edit -replace github.com/parakeet-nest/parakeet=/app

# Build the application
RUN go mod download
RUN go build -o web-chat-bot

FROM scratch
WORKDIR /app
COPY --from=builder /app/web-chat-bot .
COPY --from=builder /app/examples/69-web-chat-bot/backend/web-chat-bot .

CMD ["./web-chat-bot"]
1 change: 1 addition & 0 deletions examples/69-web-chat-bot/backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ go 1.23.1

require github.com/parakeet-nest/parakeet v0.2.4

replace github.com/parakeet-nest/parakeet => ../../..
23 changes: 10 additions & 13 deletions examples/69-web-chat-bot/backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,22 @@ func main() {

fmt.Println("🅰:", conversationMessages)


query := llm.Query{
Model: model,
Model: model,
Messages: conversationMessages,
Options: options,
Options: options,
}
/*
query := llm.Query{
Model: model,
Messages: []llm.Message{
{Role: "system", Content: systemInstructions},
{Role: "user", Content: userMessage},
},
Options: options,
}
query := llm.Query{
Model: model,
Messages: []llm.Message{
{Role: "system", Content: systemInstructions},
{Role: "user", Content: userMessage},
},
Options: options,
}
*/



answer, err := completion.ChatStream(ollamaUrl, query,
func(answer llm.Answer) error {
log.Println("📝:", answer.Message.Content)
Expand Down
66 changes: 66 additions & 0 deletions examples/69-web-chat-bot/backend/what.todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
This is my project

parakeet/
├── examples/
│ └── 69-web-chat-bot/
│ └── backend
│ ├── Dockerfile
│ ├── main.go
│ └── go.mod
├── cli/
├── content/
├── data/
├── db/
├── embeddings/
├── enums/
├── flock/
├── gear/
├── history/
├── llm/
├── mcphelpers/
├── prompt/
├── similarity/
├── tools/
├── wasm/
├── completion/
└── parakeet.go


the main file of the library is parakeet.go

the example of code is in parakeet/examples/69-web-chat-bot/backend

the other directories are the package of the library

this is my current Dockerfile:

```
FROM golang:1.23.1-alpine AS builder
WORKDIR /app
COPY main.go .
COPY go.mod .

RUN <<EOF
go mod tidy
go build -o web-chat-bot
EOF

FROM scratch
WORKDIR /app
COPY --from=builder /app/web-chat-bot .

CMD ["./web-chat-bot"]
```
and this is the go.mod file

```
module 69-web-chat-bot

go 1.23.1

require github.com/parakeet-nest/parakeet v0.2.4

replace github.com/parakeet-nest/parakeet => ../../..
```

I need to dockerize the backend example, how can I handle `replace github.com/parakeet-nest/parakeet => ../../..`
1 change: 1 addition & 0 deletions examples/69-web-chat-bot/backup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 🚧 WIP
15 changes: 15 additions & 0 deletions examples/69-web-chat-bot/backup/production/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.23.1-alpine AS builder
WORKDIR /app
COPY main.go .
COPY go.mod .

RUN <<EOF
go mod tidy
go build -o web-chat-bot
EOF

FROM scratch
WORKDIR /app
COPY --from=builder /app/web-chat-bot .

CMD ["./web-chat-bot"]
5 changes: 5 additions & 0 deletions examples/69-web-chat-bot/backup/production/backend/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module 69-web-chat-bot

go 1.23.1

require github.com/parakeet-nest/parakeet v0.2.4
43 changes: 43 additions & 0 deletions examples/69-web-chat-bot/backup/production/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
services:
# docker compose -f compose.local.yml up --build

download-local-llm:
image: curlimages/curl:8.6.0
entrypoint: ["curl", "http://host.docker.internal:11434/api/pull", "-d", '{"name": "qwen2.5:3b"}']


backend:
build:
context: ./backend
dockerfile: Dockerfile
environment:
- OLLAMA_BASE_URL=http://host.docker.internal:11434
- LLM_CHAT=qwen2.5:3b
depends_on:
download-local-llm:
condition: service_completed_successfully
develop:
watch:
- action: rebuild
path: ./backend/main.go


frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- 9090:8501
environment:
- BACKEND_SERVICE_URL=http://backend:5050
- PAGE_TITLE=🙂🤓🥸 We are Bob!
- PAGE_HEADER=We are legion 🤖🤖🤖
- PAGE_ICON=🤖
depends_on:
- backend
develop:
watch:
- action: rebuild
path: ./frontend/app.py


4 changes: 2 additions & 2 deletions examples/69-web-chat-bot/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ services:

backend:
build:
context: ./backend
dockerfile: Dockerfile
context: ../.. # Points to parakeet root directory
dockerfile: examples/69-web-chat-bot/backend/Dockerfile
environment:
- OLLAMA_BASE_URL=http://host.docker.internal:11434
- LLM_CHAT=qwen2.5:3b
Expand Down
1 change: 1 addition & 0 deletions examples/70-web-chat-bot-with-session/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 🚧 WIP
2 changes: 1 addition & 1 deletion history/bbolt-messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ func (b *BboltMessages) SaveMessage(id string, message llm.Message) (llm.Message
Content: message.Content,
}
return b.Save(messageRecord)
}
}
22 changes: 22 additions & 0 deletions history/history.todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

----------------------------------
add SessionId to llm.MessageRecord
----------------------------------

----------------------------------
update the other methods to take
in account the id of session
----------------------------------

----------------------------------
implement:
----------------------------------
- GetFiltered(patternId string) ([]llm.MessageRecord, error)
- GetFilteredMessages(patternId string) ([]llm.Message, error)
- RemoveMessage(id string)
- RemoveFilteredMessages(patternId string)
- RemoveAllMessages()

----------------------------------
Add Daphnia support
----------------------------------
2 changes: 1 addition & 1 deletion history/in-memory-messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ func (m *MemoryMessages) SaveMessage(id string, message llm.Message) (llm.Messag
Content: message.Content,
}
return m.Save(messageRecord)
}
}
3 changes: 1 addition & 2 deletions history/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type Messages interface {
Save(messageRecord llm.MessageRecord) (llm.MessageRecord, error)
SaveMessage(id string, message llm.Message) (llm.MessageRecord, error)
}
// TODO: implement Delete
// TODO: get with prefix



0 comments on commit 9e80b2a

Please sign in to comment.