This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
forked from PAIR-code/recommendation-rudders
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'pair-recommendation-rudders/master' int…
…o try-merge-pair-master-into-lsir-repo
- Loading branch information
Showing
31 changed files
with
894 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,5 @@ testem.log | |
.DS_Store | ||
Thumbs.db | ||
17.0.6/* | ||
|
||
llm-recs/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/app/experimenter-view/llm-api-config/llm-api-config.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<div class="main"> | ||
|
||
<p> | ||
You can this on the command line to get your parameters: | ||
</p> | ||
<pre> | ||
echo "Project: $(gcloud config get-value project)" | ||
echo "AccessToken: $(gcloud auth print-access-token)" | ||
</pre> | ||
<p> | ||
Note: the access token generally works for <b>1 hour</b>. After that, you'll need to | ||
renew it. | ||
</p> | ||
<p> | ||
And then copy/paste them here: | ||
</p> | ||
<form class="cloud-info-form"> | ||
<mat-form-field class="full-width" > | ||
<mat-label>Project</mat-label> | ||
<input type="text" matInput [formControl]="projectControl"> | ||
</mat-form-field> | ||
|
||
<mat-form-field class="full-width"> | ||
<mat-label>AccessToken</mat-label> | ||
<textarea matInput [formControl]="tokenControl"></textarea> | ||
</mat-form-field> | ||
</form> | ||
<p> | ||
These values are saved in your local browser storage, you can clear them | ||
by simply editing the above fields (local browser storage is updated as you | ||
type). | ||
</p> | ||
</div> | ||
|
||
<button color="primary" mat-button (click)="sendRequest()"> | ||
<span>Send</span> | ||
</button> |
9 changes: 9 additions & 0 deletions
9
src/app/experimenter-view/llm-api-config/llm-api-config.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.cloud-info-form { | ||
min-width: 150px; | ||
max-width: 500px; | ||
width: 100%; | ||
} | ||
|
||
.full-width { | ||
width: 100%; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/app/experimenter-view/llm-api-config/llm-api-config.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { LlmApiConfigComponent } from './llm-api-config.component'; | ||
|
||
describe('LlmApiConfigComponent', () => { | ||
let component: LlmApiConfigComponent; | ||
let fixture: ComponentFixture<LlmApiConfigComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [LlmApiConfigComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(LlmApiConfigComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
54 changes: 54 additions & 0 deletions
54
src/app/experimenter-view/llm-api-config/llm-api-config.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an Apache2 license that can be | ||
* found in the LICENSE file and http://www.apache.org/licenses/LICENSE-2.0 | ||
==============================================================================*/ | ||
|
||
import { Component, effect } from '@angular/core'; | ||
import { FormControl } from '@angular/forms'; | ||
import { VertexApiService } from '../../services/vertex-api.service'; | ||
import { MatInputModule } from '@angular/material/input'; | ||
import { MatFormFieldModule } from '@angular/material/form-field'; | ||
import { ReactiveFormsModule } from '@angular/forms'; | ||
import { preparePalm2Request, sendPalm2Request } from 'src/lib/text-templates/llm_vertexapi_palm2'; | ||
|
||
@Component({ | ||
selector: 'app-llm-api-config', | ||
templateUrl: './llm-api-config.component.html', | ||
styleUrls: ['./llm-api-config.component.scss'], | ||
standalone: true, | ||
imports: [MatFormFieldModule, MatInputModule, ReactiveFormsModule], | ||
}) | ||
export class LlmApiConfigComponent { | ||
public tokenControl: FormControl<string | null>; | ||
public projectControl: FormControl<string | null>; | ||
|
||
constructor(private llmService: VertexApiService) { | ||
this.tokenControl = new FormControl<string | null>(this.llmService.accessToken); | ||
this.projectControl = new FormControl<string | null>(this.llmService.projectId); | ||
|
||
this.tokenControl.valueChanges.forEach(update => { | ||
if (update && this.llmService.accessToken !== update) { | ||
this.llmService.accessToken = update | ||
} | ||
}); | ||
this.projectControl.valueChanges.forEach(update => { | ||
if (update && this.llmService.projectId !== update) { | ||
this.llmService.projectId = update | ||
} | ||
}); | ||
} | ||
// The Token is valid for 1 hour! Don't forget to renew it! | ||
async sendRequest() { | ||
const prompt = `Hello word`; | ||
const request = preparePalm2Request(prompt); | ||
console.log(JSON.stringify(request)); | ||
console.log(this.llmService.projectId); | ||
console.log(this.llmService.accessToken); | ||
const response = await sendPalm2Request( | ||
this.llmService.projectId, this.llmService.accessToken, request); | ||
console.log(JSON.stringify(response)); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.item-pair{ | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.error-message{ | ||
color: red; | ||
font-size: 12px; | ||
margin-top: 5px; | ||
} |
Oops, something went wrong.