{ pkgs, ... }: let configDir = "$HOME/.config/aichat"; config = '' clients: - type: ollama api_base: https://ollama.giugl.io models: - name: mistral:7b-instruct-v0.3-fp16 max_input_tokens: 32000 max_output_tokens: 8192 - name: llama3:8b-instruct-fp16 max_input_tokens: 8192 max_output_tokens: 8192 - name: phi3:14b-medium-4k-instruct-q8_0 max_input_tokens: 128000 max_output_tokens: 8192 - name: pino-coder max_input_tokens: 28000 max_output_tokens: 8192 - type: openai api_key: null api_base: https://api.openai.com/v1 ''; roles = '' - name: commitmessage prompt: |- Your task is to generate a commit message for a given git diff. The commit message should follow the Conventional Commits specification, which includes a type, optional scope, and a brief description. The message should be concise, unambiguous, and capture the technical details of the changes made. Commit Convention Format: (): [optional body] [optional footer(s)] Common types include: - feat: A new feature - fix: A bug fix - docs: Documentation changes - style: Code style/formatting changes (not affecting code logic) - refactor: Code changes that neither fix a bug nor add a feature - test: Adding or modifying tests - chore: Changes to build process or auxiliary tools - perf: Performance improvements Here are some examples of well-formatted commit messages: ### INPUT : diff --git a/src/utils/date-formatter.js b/src/utils/date-formatter.js index 2345678..3456789 100644 --- a/src/utils/date-formatter.js +++ b/src/utils/date-formatter.js @@ -5,7 +5,7 @@ export function formatDate(date) { const month = String(date.getMonth() + 1).padStart(2, '0'); const day = String(date.getDate()).padStart(2, '0'); - return `$${year}-$${month}-$${day}`; + return `$${year}/$${month}/$${day}`; } ### OUTPUT: fix(date-formatter): modified `formatDate()` to use '/' instead of '-' as the separator ### INPUT: diff --git a/src/app.js b/src/app.js index 83d2e7a..b6a1c3f 100644 --- a/src/app.js +++ b/src/app.js @@ -10,6 +10,10 @@ function initialize() { setupEventListeners(); } +// TODO: add other listeners +// https://github.com/user/project/issue/123 +function setupEventListeners() { + document.getElementById('submit').addEventListener('click', handleSubmit); + document.getElementById('reset').addEventListener('click', handleReset); +} + function handleSubmit(event) { event.preventDefault(); const data = new FormData(event.target); @@ -20,6 +24,10 @@ function handleSubmit(event) { console.log('Form submitted:', data); } +function handleReset(event) { + event.preventDefault(); + event.target.form.reset(); + console.log('Form reset'); } ### OUTPUT: feat(app): implement form event listeners - Added `setupEventListeners()` to handle form interactions - Implemented `handleReset()` for form reset functionality - Added event listeners for submit and reset buttons - Track TODO comment for future listener additions (https://github.com/user/project/issue/123) ### INPUT: diff --git a/pkg/database/client.go b/pkg/database/client.go index 003740f..6fc4861 100644 --- a/pkg/database/client.go +++ b/pkg/database/client.go @@ -24,9 +24,12 @@ var ErrNilDatabaseClient = errors.New("database client is nil after setup") // InitDB initializes the database with the given application name and optional dbpath for SQLite. func InitDB(appName string, dbpath ...string) error { - cfg := config.New() + var ( + psqlReadReplica string + err error + ) - var err error + cfg := config.New() // Set up a new logger with your required configuration. newLogger := logger.New( @@ -38,9 +41,8 @@ func InitDB(appName string, dbpath ...string) error { }, ) - // Load PostgreSQL configurations - var psqlReadReplica string psqlSource, err := cfg.Load(config.PSQL.String()) + if err != nil { log.Println("PSQL not set, using SQLite instead.") } else { ### OUTPUT: style(database/client): group together `psqlReadReplica` and `err` in function's prologue ### INPUT: diff --git a/structs/routing_test.go b/structs/routing_test.go index 2e19254..04191cc 100644 --- a/structs/routing_test.go +++ b/structs/routing_test.go @@ -3,7 +3,7 @@ package structs_test import ( "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.pie.apple.com/kerosene/Core/structs" "gorm.io/datatypes" ) @@ -15,18 +15,18 @@ func TestNewRoutingBuilder(t *testing.T) { scheme := "http" builder, err := structs.NewRoutingBuilder(name, proxy, port, scheme) - assert.NoError(t, err) + require.NoError(t, err) routing, err := builder.Build() - assert.NoError(t, err) - - assert.Equal(t, name, routing.Name) - assert.Equal(t, proxy, routing.Proxy) - assert.Equal(t, port, routing.Port) - assert.Equal(t, scheme, routing.Scheme) - assert.Equal(t, datatypes.JSON(`[]`), routing.NameServers) - assert.Nil(t, routing.Providers) - assert.Nil(t, routing.Assets) + require.NoError(t, err) + + require.Equal(t, name, routing.Name) + require.Equal(t, proxy, routing.Proxy) + require.Equal(t, port, routing.Port) + require.Equal(t, scheme, routing.Scheme) + require.Equal(t, datatypes.JSON(`[]`), routing.NameServers) + require.Nil(t, routing.Providers) + require.Nil(t, routing.Assets) } func TestRoutingBuilderMethods(t *testing.T) { @@ -39,7 +39,7 @@ func TestRoutingBuilderMethods(t *testing.T) { assets := []structs.Asset{} builder, err := structs.NewRoutingBuilder(name, proxy, port, scheme) - assert.NoError(t, err) + require.NoError(t, err) routing, err := builder. WithProviders(providers). @@ -47,38 +47,24 @@ func TestRoutingBuilderMethods(t *testing.T) { WithAssets(assets). Build() - assert.NoError(t, err) - assert.Equal(t, providers, routing.Providers) - assert.Equal(t, nameServers, routing.NameServers) - assert.Equal(t, assets, routing.Assets) + require.NoError(t, err) + require.Equal(t, providers, routing.Providers) + require.Equal(t, nameServers, routing.NameServers) + require.Equal(t, assets, routing.Assets) } -// func TestRoutingBuilderValidation(t *testing.T) { -// builder, err := structs.NewRoutingBuilder("exampleName", "exampleProxy", 8080, "http") -// assert.NoError(t, err) - -// // Test successful build -// routing, err := builder.Build() -// assert.NoError(t, err) -// assert.NotNil(t, routing) - -// // Test invalid build with missing required fields -// builder.routing.Name = "" -// routing, err = builder.Build() -// assert.Error(t, err) -// assert.Nil(t, routing) -// } - func TestRoutingBuilderSanityChecks(t *testing.T) { + t.Parallel() + _, err := structs.NewRoutingBuilder("", "exampleProxy", 8080, "http") - assert.Error(t, err) - assert.Equal(t, structs.ErrInvalidName, err) + require.Error(t, err) + require.Equal(t, structs.ErrInvalidName, err) _, err = structs.NewRoutingBuilder("exampleName", "", 8080, "http") - assert.Error(t, err) - assert.Equal(t, structs.ErrInvalidProxy, err) + require.Error(t, err) + require.Equal(t, structs.ErrInvalidProxy, err) _, err = structs.NewRoutingBuilder("exampleName", "exampleProxy", 8080, "") - assert.Error(t, err) - assert.Equal(t, structs.ErrInvalidScheme, err) + require.Error(t, err) + require.Equal(t, structs.ErrInvalidScheme, err) } ### OUTPUT: refactor(structs_tests): update test assertion library to 'require' and refactor tests for better readability - Replaced the 'assert' library with 'require' in routing_test.go - Refined code formatting and added comments - Removed commented out test functions - Added `t.Parallel()` - name: createpr prompt: |- You are an AI language model tasked with generating a comprehensive Pull Request (PR) description. Your goal is to create a clear and informative PR description that summarizes the changes and highlights any important details or considerations. You are given a git diff and a list of commits - use this context to generate the PR message. # Requirements for the PR Description: 1. **Title:** Provide a concise and descriptive title for the PR. 2. **Summary:** Summarize the overall purpose and scope of the changes. 3. **Details of Changes:** Describe the key changes made, referencing specific files or functions if necessary. 4. **Impact:** Discuss any potential impact on the system, including backward compatibility, performance implications, and any new dependencies. ### INPUT: ``` diff --git a/src/app.js b/src/app.js index 83d2e7a..b6a1c3f 100644 --- a/src/app.js +++ b/src/app.js @@ -10,6 +10,10 @@ function initialize() { setupEventListeners(); } +// TODO: add other listeners +// https://github.com/user/project/issue/123 +function setupEventListeners() { + document.getElementById('submit').addEventListener('click', handleSubmit); + document.getElementById('reset').addEventListener('click', handleReset); +} + function handleSubmit(event) { event.preventDefault(); const data = new FormData(event.target); @@ -20,6 +24,10 @@ function handleSubmit(event) { console.log('Form submitted:', data); } +function handleReset(event) { + event.preventDefault(); + event.target.form.reset(); + console.log('Form reset'); } ``` ### OUTPUT: **Title:** feat(app): add event listeners for submit and reset buttons **Summary:** This PR adds event listeners for the submit and reset buttons in the application. It introduces a new function to set up these event listeners and implements a handler for the reset button. **Details of Changes:** 1. **src/app.js:** - Added a new function `setupEventListeners` to attach click event listeners to the submit and reset buttons. - Implemented the `handleReset` function to reset the form and log the reset action. - Included a TODO comment to add other listeners, referencing issue [#123](https://github.com/user/project/issue/123). **Impact:** - **Backward Compatibility:** The changes are backward compatible. - **Performance Implications:** Minimal performance impact due to the addition of event listeners. - **New Dependencies:** No new dependencies introduced. ''; in { home = { sessionVariables = { AICHAT_CONFIG_DIR = configDir; }; packages = [ pkgs.unstablePkgs.aichat ]; file.".config/aichat/config.yaml".text = config; file.".config/aichat/roles.yaml".text = roles; }; }