Skip to content

Commit 9644b40

Browse files
authored
Merge pull request #16 from hellcp/service-update
Update the service to Gemini 2.5 and remove the stamp on larger displays
2 parents fa3c874 + aa81d55 commit 9644b40

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

service/assistant/query/query.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ func ScreenWidthFromContext(ctx context.Context) int {
137137
return ctx.Value(queryContextKey).(queryContext).screenWidth
138138
}
139139

140+
func ScreenHeightFromContext(ctx context.Context) int {
141+
return ctx.Value(queryContextKey).(queryContext).screenHeight
142+
}
143+
140144
func ContextWithThread(ctx context.Context, threadContext *persistence.ThreadContext) context.Context {
141145
qc := ctx.Value(queryContextKey).(queryContext)
142146
qc.threadContext = threadContext

service/assistant/quota/quota.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import (
2525
)
2626

2727
// one credit is worth $0.000000025.
28-
const InputTokenCredits = 4
29-
const OutputTokenCredits = 16
30-
const LiteInputTokenCredits = 3
31-
const LiteOutputTokenCredits = 12
28+
const InputTokenCredits = 12
29+
const OutputTokenCredits = 100
30+
const LiteInputTokenCredits = 4
31+
const LiteOutputTokenCredits = 16
3232
const WeatherQueryCredits = 21_000
3333
const PoiSearchCredits = 1_400_000
3434
const RouteCalculationCredits = 400_000

service/assistant/session.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (ps *PromptSession) Run(ctx context.Context) {
149149
streamCtx, streamSpan := beeline.StartSpan(ctx, "chat_stream")
150150
temperature := float32(0.5)
151151
zero := int32(0)
152-
s := geminiClient.Models.GenerateContentStream(streamCtx, "models/gemini-2.0-flash", messages, &genai.GenerateContentConfig{
152+
s := geminiClient.Models.GenerateContentStream(streamCtx, "models/gemini-2.5-flash", messages, &genai.GenerateContentConfig{
153153
SystemInstruction: &genai.Content{Parts: []*genai.Part{{Text: systemPrompt}}},
154154
Temperature: &temperature,
155155
CandidateCount: 1,

service/assistant/verifier/verifier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func DetermineActions(ctx context.Context, qt *quota.Tracker, message string) ([
7676
// We don't want to hold up the user for too long - if the model is responding slowly, just give up.
7777
// Under normal circumstances, the P99 response time is around 600ms.
7878
timeoutCtx, cancelTimeout := context.WithTimeout(ctx, 1500*time.Millisecond)
79-
response, err := geminiClient.Models.GenerateContent(timeoutCtx, "models/gemini-2.0-flash-lite", []*genai.Content{
79+
response, err := geminiClient.Models.GenerateContent(timeoutCtx, "models/gemini-2.5-flash-lite", []*genai.Content{
8080
genai.NewContentFromText(message, genai.RoleUser),
8181
}, &genai.GenerateContentConfig{
8282
SystemInstruction: genai.NewContentFromText(SYSTEM_PROMPT, genai.RoleUser),

service/assistant/widgets/map.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,22 @@ func generateMap(ctx context.Context, markers map[string]util.Coords, userLocati
233233
}
234234

235235
screenWidth := query.ScreenWidthFromContext(ctx)
236+
screenHeight := query.ScreenHeightFromContext(ctx)
236237
if screenWidth == 0 {
237238
screenWidth = 144
238239
}
240+
241+
widgetHeight := 100
242+
if screenWidth >= 168 {
243+
widgetHeight = 140
244+
}
245+
// Assuming that screen with equal width and height is round
246+
if screenWidth == screenHeight {
247+
widgetHeight = screenHeight
248+
}
249+
239250
request := gmaps.StaticMapRequest{
240-
Size: fmt.Sprintf("%dx100", screenWidth),
251+
Size: fmt.Sprintf("%dx%d", screenWidth, widgetHeight),
241252
Format: "png8",
242253
MapType: "roadmap",
243254
MapId: config.GetConfig().GoogleMapsStaticMapId,
@@ -291,7 +302,9 @@ func monochrome(img image.Image) image.Image {
291302
}
292303
}
293304
}
294-
stampLogo(newImg, googleLogo1Bit)
305+
if img.Bounds().Max.X <= 168 {
306+
stampLogo(newImg, googleLogo1Bit)
307+
}
295308
return newImg
296309
}
297310

@@ -308,7 +321,9 @@ func lowColour(img image.Image) image.Image {
308321
}
309322
}
310323
}
311-
stampLogo(newImg, googleLogo2Bit)
324+
if img.Bounds().Max.X <= 168 {
325+
stampLogo(newImg, googleLogo2Bit)
326+
}
312327
return newImg
313328
}
314329

0 commit comments

Comments
 (0)