Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/plugins/q_dev/models/chat_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ type QDevChatLog struct {
ActiveFileExtension string `gorm:"type:varchar(50)" json:"activeFileExtension"`
HasSteering bool `json:"hasSteering"`
IsSpecMode bool `json:"isSpecMode"`
CodeReferenceCount int `json:"codeReferenceCount"`
WebLinkCount int `json:"webLinkCount"`
HasFollowupPrompts bool `json:"hasFollowupPrompts"`
}

func (QDevChatLog) TableName() string {
Expand Down
22 changes: 12 additions & 10 deletions backend/plugins/q_dev/models/completion_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ import (
// QDevCompletionLog stores parsed data from GenerateCompletions logging events
type QDevCompletionLog struct {
common.NoPKModel
ConnectionId uint64 `gorm:"primaryKey"`
ScopeId string `gorm:"primaryKey;type:varchar(255)" json:"scopeId"`
RequestId string `gorm:"primaryKey;type:varchar(255)" json:"requestId"`
UserId string `gorm:"index;type:varchar(255)" json:"userId"`
DisplayName string `gorm:"type:varchar(255)" json:"displayName"`
Timestamp time.Time `gorm:"index" json:"timestamp"`
FileName string `gorm:"type:varchar(512)" json:"fileName"`
FileExtension string `gorm:"type:varchar(50)" json:"fileExtension"`
HasCustomization bool `json:"hasCustomization"`
CompletionsCount int `json:"completionsCount"`
ConnectionId uint64 `gorm:"primaryKey"`
ScopeId string `gorm:"primaryKey;type:varchar(255)" json:"scopeId"`
RequestId string `gorm:"primaryKey;type:varchar(255)" json:"requestId"`
UserId string `gorm:"index;type:varchar(255)" json:"userId"`
DisplayName string `gorm:"type:varchar(255)" json:"displayName"`
Timestamp time.Time `gorm:"index" json:"timestamp"`
FileName string `gorm:"type:varchar(512)" json:"fileName"`
FileExtension string `gorm:"type:varchar(50)" json:"fileExtension"`
HasCustomization bool `json:"hasCustomization"`
CompletionsCount int `json:"completionsCount"`
LeftContextLength int `json:"leftContextLength"`
RightContextLength int `json:"rightContextLength"`
}

func (QDevCompletionLog) TableName() string {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package migrationscripts

import (
"github.com/apache/incubator-devlake/core/context"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/helpers/migrationhelper"
"github.com/apache/incubator-devlake/plugins/q_dev/models/migrationscripts/archived"
)

var _ = (*addLoggingFields)(nil)

type addLoggingFields struct{}

func (*addLoggingFields) Up(basicRes context.BasicRes) errors.Error {
return migrationhelper.AutoMigrateTables(
basicRes,
&archived.QDevChatLog{},
&archived.QDevCompletionLog{},
)
}

func (*addLoggingFields) Version() uint64 {
return 20260319000001
}

func (*addLoggingFields) Name() string {
return "Add code_reference_count, web_link_count, has_followup_prompts to chat_log; left/right_context_length to completion_log"
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ type QDevChatLog struct {
ActiveFileExtension string `gorm:"type:varchar(50)" json:"activeFileExtension"`
HasSteering bool `json:"hasSteering"`
IsSpecMode bool `json:"isSpecMode"`
CodeReferenceCount int `json:"codeReferenceCount"`
WebLinkCount int `json:"webLinkCount"`
HasFollowupPrompts bool `json:"hasFollowupPrompts"`
}

func (QDevChatLog) TableName() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ import (

type QDevCompletionLog struct {
archived.NoPKModel
ConnectionId uint64 `gorm:"primaryKey"`
ScopeId string `gorm:"primaryKey;type:varchar(255)" json:"scopeId"`
RequestId string `gorm:"primaryKey;type:varchar(255)" json:"requestId"`
UserId string `gorm:"index;type:varchar(255)" json:"userId"`
DisplayName string `gorm:"type:varchar(255)" json:"displayName"`
Timestamp time.Time `gorm:"index" json:"timestamp"`
FileName string `gorm:"type:varchar(512)" json:"fileName"`
FileExtension string `gorm:"type:varchar(50)" json:"fileExtension"`
HasCustomization bool `json:"hasCustomization"`
CompletionsCount int `json:"completionsCount"`
ConnectionId uint64 `gorm:"primaryKey"`
ScopeId string `gorm:"primaryKey;type:varchar(255)" json:"scopeId"`
RequestId string `gorm:"primaryKey;type:varchar(255)" json:"requestId"`
UserId string `gorm:"index;type:varchar(255)" json:"userId"`
DisplayName string `gorm:"type:varchar(255)" json:"displayName"`
Timestamp time.Time `gorm:"index" json:"timestamp"`
FileName string `gorm:"type:varchar(512)" json:"fileName"`
FileExtension string `gorm:"type:varchar(50)" json:"fileExtension"`
HasCustomization bool `json:"hasCustomization"`
CompletionsCount int `json:"completionsCount"`
LeftContextLength int `json:"leftContextLength"`
RightContextLength int `json:"rightContextLength"`
}

func (QDevCompletionLog) TableName() string {
Expand Down
1 change: 1 addition & 0 deletions backend/plugins/q_dev/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ func All() []plugin.MigrationScript {
new(fixDedupUserTables),
new(resetS3FileMetaProcessed),
new(addLoggingTables),
new(addLoggingFields),
}
}
32 changes: 22 additions & 10 deletions backend/plugins/q_dev/tasks/s3_logging_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,13 @@ type chatLogRequest struct {
type chatLogResponse struct {
RequestID string `json:"requestId"`
AssistantResponse string `json:"assistantResponse"`
FollowupPrompts string `json:"followupPrompts"`
MessageMetadata struct {
ConversationID *string `json:"conversationId"`
UtteranceID *string `json:"utteranceId"`
} `json:"messageMetadata"`
CodeReferenceEvents []json.RawMessage `json:"codeReferenceEvents"`
SupplementaryWebLinksEvent []json.RawMessage `json:"supplementaryWebLinksEvent"`
}

type completionLogRecord struct {
Expand All @@ -296,6 +299,8 @@ type completionLogRequest struct {
Timestamp string `json:"timeStamp"`
FileName string `json:"fileName"`
CustomizationArn *string `json:"customizationArn"`
LeftContext string `json:"leftContext"`
RightContext string `json:"rightContext"`
}

type completionLogResponse struct {
Expand Down Expand Up @@ -347,6 +352,11 @@ func parseChatRecord(raw json.RawMessage, fileMeta *models.QDevS3FileMeta, ident
chatLog.UtteranceId = *record.Response.MessageMetadata.UtteranceID
}

// New fields from docs: codeReferenceEvents, supplementaryWebLinksEvent, followupPrompts
chatLog.CodeReferenceCount = len(record.Response.CodeReferenceEvents)
chatLog.WebLinkCount = len(record.Response.SupplementaryWebLinksEvent)
chatLog.HasFollowupPrompts = record.Response.FollowupPrompts != ""

return chatLog, nil
}

Expand Down Expand Up @@ -406,16 +416,18 @@ func parseCompletionRecord(raw json.RawMessage, fileMeta *models.QDevS3FileMeta,

userId := normalizeUserId(record.Request.UserID)
return &models.QDevCompletionLog{
ConnectionId: fileMeta.ConnectionId,
ScopeId: fileMeta.ScopeId,
RequestId: record.Response.RequestID,
UserId: userId,
DisplayName: cachedResolveDisplayName(userId, identityClient, cache),
Timestamp: ts,
FileName: record.Request.FileName,
FileExtension: filepath.Ext(record.Request.FileName),
HasCustomization: record.Request.CustomizationArn != nil && *record.Request.CustomizationArn != "",
CompletionsCount: len(record.Response.Completions),
ConnectionId: fileMeta.ConnectionId,
ScopeId: fileMeta.ScopeId,
RequestId: record.Response.RequestID,
UserId: userId,
DisplayName: cachedResolveDisplayName(userId, identityClient, cache),
Timestamp: ts,
FileName: record.Request.FileName,
FileExtension: filepath.Ext(record.Request.FileName),
HasCustomization: record.Request.CustomizationArn != nil && *record.Request.CustomizationArn != "",
CompletionsCount: len(record.Response.Completions),
LeftContextLength: len(record.Request.LeftContext),
RightContextLength: len(record.Request.RightContext),
}, nil
}

Expand Down
16 changes: 16 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "e2e",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs",
"dependencies": {
"@playwright/test": "^1.58.2"
}
}
39 changes: 39 additions & 0 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { defineConfig } from '@playwright/test';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { defineConfig } from '@playwright/test';
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { defineConfig } from '@playwright/test';


export default defineConfig({
testDir: '.',
testMatch: '*.spec.ts',
timeout: 180000,
expect: {
timeout: 10000,
},
use: {
baseURL: 'http://localhost:4000',
screenshot: 'on',
trace: 'on-first-retry',
},
reporter: [['html', { open: 'never' }], ['list']],
projects: [
{
name: 'chromium',
use: { browserName: 'chromium', viewport: { width: 1440, height: 900 } },
},
],
});
Loading
Loading