Skip to content

Commit aa97b85

Browse files
committed
Merge remote-tracking branch 'origin/main' into kc-upgrade-26
2 parents 4594589 + 7e386d4 commit aa97b85

File tree

217 files changed

+17293
-7514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+17293
-7514
lines changed

.cursor/rules/go-api-handlers.mdc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
description: Use authorization functions for apps
3+
globs: api/pkg/server/*.go
4+
alwaysApply: false
5+
---
6+
Act as a security conscious senior software developer. When implementing handlers think about whether handlers need authentication and authorization.
7+
- Do not reimplement logic that is in the authz.go
8+
- When editing or adding new handlers, use existing functions such as `authorizeUserToApp` or `authorizeUserToResource`
9+
- When editing or adding handlers, always include doc string such as
10+
```
11+
// createApp godoc
12+
// @Summary Create new app
13+
// @Description Create new app. Helix apps are configured with tools and knowledge.
14+
// @Tags apps
15+
16+
// @Success 200 {object} types.App
17+
// @Param request body types.App true "Request body with app configuration.")
18+
// @Router /api/v1/apps [post]
19+
// @Security BearerAuth
20+
```
21+
as this then generates the Swagger/OpenAPI definitions

.cursor/rules/helix.mdc

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@ description: Everything
33
globs: *
44
alwaysApply: false
55
---
6-
Don't make unrelated changes
6+
Act as an expert senior Golang (or Python when editing Python files) engineers
7+
8+
Stack: Golang API server, Docker, Postgres, PGVector or Typesense for RAG, NATS (embedded into Golang server) for messaging pubsub
9+
10+
- Don't make unrelated changes
11+
- Don't ever declare types as map[string]interface{} for JSON marshalling. Declare a regular struct oustide of the function and use it to marshal JSON
12+
- If a function returns multiple parameters such as `*SomeStruct, error`, don't return `nil, nil` from within the function, if the struct is nil, return an error to avoid extra checking that the struct is nil if the error is nil
13+
- For logging use `"github.com/rs/zerolog/log"` library
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
description: Database interactions should be using Gorm
3+
globs: api/pkg/store/*.go
4+
alwaysApply: false
5+
---
6+
- When adding methods to interact with Postgres database, use Gorm client `s.gdb.WithContext(ctx).Where(xx).First(xx)`, etc.
7+
- If a query is more complex where joins are needed, then use the "Raw" feature of gorm client such as `s.gdb.WithContext(ctx).Raw("some query").Scan(&result)`

.drone.yml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ steps:
2727
- name: run-linter
2828
image: golangci/golangci-lint:v1.62-alpine
2929
commands:
30+
- golangci-lint cache clean
3031
- golangci-lint run
3132
when:
3233
event:

.golangci.yml

+31
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,41 @@ linters:
1313
- tparallel
1414
- errcheck
1515
- revive
16+
- forbidigo
17+
# - gocritic
1618

1719
issues:
1820
exlude-dirs:
1921
- vendor
22+
exclude-rules:
23+
- path: 'api/cmd'
24+
linters:
25+
- forbidigo
26+
- path: 'api/pkg/cli'
27+
linters:
28+
- forbidigo
29+
- path: 'demos'
30+
linters:
31+
- forbidigo
32+
- path: '.*_test.go'
33+
linters:
34+
- forbidigo
2035

2136
run:
2237
timeout: 10m
38+
39+
linters-settings:
40+
forbidigo:
41+
forbid:
42+
- ^fmt\.Print.*
43+
- ^print(ln)?$
44+
rules:
45+
- name: error-strings
46+
disabled: false
47+
- name: error-naming
48+
disabled: false
49+
50+
gocritic:
51+
enabled-tags:
52+
- diagnostic
53+
- style

Dockerfile.runner

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ FROM registry.helix.ml/helix/runner-base:${TAG}
4545

4646
# Install ollama
4747
RUN TEMP_DIR=$(mktemp -d /tmp/ollama_install_XXXXXX) && \
48-
curl --retry 5 -L https://github.com/ollama/ollama/releases/download/v0.5.1/ollama-linux-amd64.tgz -o $TEMP_DIR/ollama.tgz && \
48+
curl --retry 5 -L https://github.com/ollama/ollama/releases/download/v0.6.1-rc0/ollama-linux-amd64.tgz -o $TEMP_DIR/ollama.tgz && \
4949
tar -xzf $TEMP_DIR/ollama.tgz -C $TEMP_DIR && \
5050
mv $TEMP_DIR/bin/ollama /usr/bin/ollama && \
5151
chmod +x /usr/bin/ollama && \

api/cmd/helix/gptscript.go

-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ func newGptScriptCmd() *cobra.Command {
3737
}
3838

3939
func gptscriptServer(_ *cobra.Command) error {
40-
41-
// this is populated by a testfaster secret which is written into /root/secrets and then hoisted
42-
// as the environment file for the gptscript systemd service which runs this
4340
if os.Getenv("OPENAI_API_KEY") == "" {
4441
log.Fatal().Msg("missing API key for OpenAI")
4542
}

api/cmd/helix/serve.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,11 @@ func serve(cmd *cobra.Command, cfg *config.ServerConfig) error {
243243
return err
244244
}
245245

246-
var gse gptscript.Executor
247-
248246
if cfg.GPTScript.TestFaster.URL != "" {
249-
log.Info().Msg("using firecracker based GPTScript executor")
250-
gse = gptscript.NewTestFasterExecutor(cfg)
251-
} else {
252-
log.Info().Msg("using runner based GPTScript executor")
253-
gse = gptscript.NewExecutor(cfg, ps)
247+
return fmt.Errorf("HELIX_TESTFASTER_URL is deprecated, please use runner based GPTScript executor")
254248
}
249+
log.Info().Msg("using runner based GPTScript executor")
250+
gse := gptscript.NewExecutor(cfg, ps)
255251

256252
var extractor extract.Extractor
257253

@@ -324,6 +320,10 @@ func serve(cmd *cobra.Command, cfg *config.ServerConfig) error {
324320

325321
providerManager := manager.NewProviderManager(cfg, postgresStore, helixInference, logStores...)
326322

323+
// Connect the runner controller to the provider manager
324+
providerManager.SetRunnerController(runnerController)
325+
log.Info().Msg("Connected runner controller to provider manager to enable hiding Helix provider when no runners are available")
326+
327327
// Will run async and watch for changes in the API keys, non-blocking
328328
providerManager.StartRefresh(ctx)
329329

api/cmd/helix/test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ var htmlTemplate = `
385385
<td>{{.Model}}</td>
386386
<td>{{printf "%.2f" .InferenceTime.Seconds}}s</td>
387387
<td>{{printf "%.2f" .EvaluationTime.Seconds}}s</td>
388-
<td><a href="#" onclick="openLink('{{$.HelixURL}}/session/{{.SessionID}}'); return false;">Session</a></td>
389-
<td><a href="#" onclick="openLink('{{$.HelixURL}}/dashboard?tab=llm_calls&filter_sessions={{.SessionID}}'); return false;">Debug</a></td>
388+
<td><a href="{{$.HelixURL}}/session/{{.SessionID}}" onclick="openLink('{{$.HelixURL}}/session/{{.SessionID}}'); return false;">Session</a></td>
389+
<td><a href="{{$.HelixURL}}/dashboard?tab=llm_calls&filter_sessions={{.SessionID}}" onclick="openLink('{{$.HelixURL}}/dashboard?tab=llm_calls&filter_sessions={{.SessionID}}'); return false;">Debug</a></td>
390390
</tr>
391391
{{end}}
392392
</tbody>
@@ -1443,7 +1443,6 @@ func deployApp(namespacedAppName string, yamlFile string) (string, error) {
14431443
app := &types.App{
14441444
AppSource: types.AppSourceHelix,
14451445
Global: false,
1446-
Shared: false,
14471446
Config: types.AppConfig{
14481447
AllowedDomains: []string{},
14491448
Helix: *parsedAppConfig,

api/pkg/cli/app/apply.go

+4-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ func init() {
1818
rootCmd.AddCommand(applyCmd)
1919

2020
applyCmd.Flags().StringP("filename", "f", "", "Filename to apply")
21-
applyCmd.Flags().Bool("shared", false, "Shared application")
2221
applyCmd.Flags().Bool("global", false, "Global application")
2322
applyCmd.Flags().Bool("refresh-knowledge", false, "Refresh knowledge, re-index all knowledge for the app")
2423
applyCmd.Flags().StringVarP(&organization, "organization", "o", "", "Organization ID or name")
@@ -51,11 +50,6 @@ var applyCmd = &cobra.Command{
5150
return err
5251
}
5352

54-
shared, err := cmd.Flags().GetBool("shared")
55-
if err != nil {
56-
return err
57-
}
58-
5953
global, err := cmd.Flags().GetBool("global")
6054
if err != nil {
6155
return err
@@ -117,12 +111,12 @@ var applyCmd = &cobra.Command{
117111
}
118112

119113
if existingApp != nil {
120-
err = updateApp(cmd.Context(), apiClient, existingApp, appConfig.GetAppConfig(), shared, global)
114+
err = updateApp(cmd.Context(), apiClient, existingApp, appConfig.GetAppConfig(), global)
121115
if err != nil {
122116
return err
123117
}
124118
} else {
125-
appID, err = createApp(cmd.Context(), apiClient, organization, appConfig.GetAppConfig(), shared, global)
119+
appID, err = createApp(cmd.Context(), apiClient, organization, appConfig.GetAppConfig(), global)
126120
if err != nil {
127121
return err
128122
}
@@ -195,9 +189,8 @@ func RefreshAppKnowledge(ctx context.Context, apiClient client.Client, appID str
195189
return nil
196190
}
197191

198-
func updateApp(ctx context.Context, apiClient client.Client, app *types.App, appConfig *types.AppHelixConfig, shared, global bool) error {
192+
func updateApp(ctx context.Context, apiClient client.Client, app *types.App, appConfig *types.AppHelixConfig, global bool) error {
199193
app.Config.Helix = *appConfig
200-
app.Shared = shared
201194
app.Global = global
202195

203196
app, err := apiClient.UpdateApp(ctx, app)
@@ -210,11 +203,10 @@ func updateApp(ctx context.Context, apiClient client.Client, app *types.App, app
210203
return nil
211204
}
212205

213-
func createApp(ctx context.Context, apiClient client.Client, orgID string, appConfig *types.AppHelixConfig, shared, global bool) (string, error) {
206+
func createApp(ctx context.Context, apiClient client.Client, orgID string, appConfig *types.AppHelixConfig, global bool) (string, error) {
214207
app := &types.App{
215208
AppSource: types.AppSourceHelix,
216209
Global: global,
217-
Shared: shared,
218210
Config: types.AppConfig{
219211
AllowedDomains: []string{}, // TODO: make configurable
220212
Helix: *appConfig,

api/pkg/cli/app/inspect.go

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ var inspectCmd = &cobra.Command{
4141
// only show app.Config.Helix since that is the thing that roundtrips with helix apply -f
4242
appConfig := app.Config.Helix
4343

44+
// Remove tools section from all assistants
45+
for i := range appConfig.Assistants {
46+
appConfig.Assistants[i].Tools = nil
47+
}
48+
4449
// Convert to CRD format for both JSON and YAML output
4550
crd := types.AppHelixConfigCRD{
4651
APIVersion: "app.aispec.org/v1alpha1",
@@ -50,6 +55,7 @@ var inspectCmd = &cobra.Command{
5055
},
5156
Spec: appConfig,
5257
}
58+
5359
// Clear the name from the spec since it's now in metadata
5460
crd.Spec.Name = ""
5561

api/pkg/cli/knowledge/search.go

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ func init() {
1212
searchCmd.Flags().String("app", "", "App ID to search within")
1313
searchCmd.Flags().String("knowledge", "", "Knowledge ID to search within")
1414
searchCmd.Flags().String("prompt", "", "Search prompt")
15+
searchCmd.Flags().String("document", "", "Document ID to search within")
1516

1617
_ = searchCmd.MarkFlagRequired("app")
1718
_ = searchCmd.MarkFlagRequired("prompt")
@@ -32,11 +33,13 @@ var searchCmd = &cobra.Command{
3233
appID, _ := cmd.Flags().GetString("app")
3334
knowledgeID, _ := cmd.Flags().GetString("knowledge")
3435
prompt, _ := cmd.Flags().GetString("prompt")
36+
documentID, _ := cmd.Flags().GetString("document")
3537

3638
results, err := apiClient.SearchKnowledge(cmd.Context(), &client.KnowledgeSearchQuery{
3739
AppID: appID,
3840
KnowledgeID: knowledgeID,
3941
Prompt: prompt,
42+
DocumentID: documentID,
4043
})
4144
if err != nil {
4245
return fmt.Errorf("failed to search knowledge: %w", err)

0 commit comments

Comments
 (0)