Skip to content
This repository was archived by the owner on Oct 24, 2021. It is now read-only.

Commit b89cf0e

Browse files
committed
A few minor fixes in the CopilotCompletionContributor + added CI
1 parent 1ea2fee commit b89cf0e

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build
2+
on:
3+
push:
4+
branches:
5+
- masrer
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up JDK 11
14+
uses: actions/setup-java@v2
15+
with:
16+
java-version: '16'
17+
distribution: 'adopt'
18+
- name: Cache Gradle packages
19+
uses: actions/cache@v2
20+
with:
21+
path: |
22+
~/.gradle/caches
23+
~/.gradle/wrapper
24+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
25+
restore-keys: |
26+
${{ runner.os }}-gradle-
27+
- name: Build with Gradle
28+
run: ./gradlew buildPlugin
29+
- name: Cleanup Gradle Cache
30+
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
31+
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
32+
run: |
33+
rm -f ~/.gradle/caches/modules-2/modules-2.lock
34+
rm -f ~/.gradle/caches/modules-2/gc.properties
35+
- name: Upload Artifacts
36+
uses: actions/upload-artifact@v2
37+
with:
38+
name: Package
39+
path: build/distributions

src/main/kotlin/dev/koding/copilot/completion/CopilotCompletionContributor.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CopilotCompletionContributor : CompletionContributor() {
2626
override fun fillCompletionVariants(parameters: CompletionParameters, result: CompletionResultSet) {
2727
if (parameters.isAutoPopup) return
2828

29-
if (settings.token?.isBlank() == true) return Notifications.send(
29+
if (settings.token == null || settings.token?.isBlank() == true) return Notifications.send(
3030
"You have not set a token for GitHub Copilot.",
3131
type = NotificationType.ERROR,
3232
once = true,
@@ -52,12 +52,15 @@ class CopilotCompletionContributor : CompletionContributor() {
5252
try {
5353
response = CompletionRequest(prompt).send(settings.token!!)
5454
} catch (e: ClientRequestException) {
55+
e.printStackTrace()
5556
errored = true
5657
return@launch Notifications.send(
5758
"Failed to fetch response. Is your copilot token valid?",
5859
type = NotificationType.ERROR,
5960
once = true,
6061
Notifications.NotificationAction("Login") { handleLogin() })
62+
} catch (e: Exception) {
63+
e.printStackTrace()
6164
}
6265
}
6366

src/main/kotlin/dev/koding/copilot/completion/api/CompletionData.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ data class CompletionChoice(
1515
data class CompletionRequest(
1616
val prompt: String,
1717
@SerializedName("max_tokens")
18-
val maxTokens: Int = 50,
18+
val maxTokens: Int = 70,
1919
val temperature: Double = 0.2,
2020
@SerializedName("top_p")
2121
val topP: Double = 1.0,

0 commit comments

Comments
 (0)