Skip to content

Commit

Permalink
chore: Update API provider code in app component
Browse files Browse the repository at this point in the history
The code changes update the API provider code in the app component's HTML and TypeScript files. The provider code is changed from using the `Code` property to the `ApiRoute` property in the `providerList` array. This change ensures consistency with the `ApiProvider` interface defined in the `models.ts` file.

Note: The commit message follows the established convention of using a prefix (chore) to indicate a non-functional change or maintenance task.
  • Loading branch information
EdiWang committed Jun 18, 2024
1 parent 4aa4542 commit af78a25
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion web/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h1>
<section class="translator-text-container">
<div>
<fluent-select title="API" formControlName="apiProvider" ngDefaultControl>
<fluent-option *ngFor="let p of providerList" [value]="p.Code">{{ p.Name }}</fluent-option>
<fluent-option *ngFor="let p of providerList" [value]="p.ApiRoute">{{ p.Name }}</fluent-option>
</fluent-select>
</div>
<div class="translated-text-container">
Expand Down
11 changes: 6 additions & 5 deletions web/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ export class AppComponent implements OnInit {
];

providerList: ApiProvider[] = [
{ Code: 'azure-translator', Name: 'Azure Translator (Text)' },
{ Code: 'aoai', Name: 'Azure Open AI (GPT-4o)' }
{ Name: 'Azure Translator (Text)', ApiRoute: 'azure-translator' },
{ Name: 'Azure Open AI (GPT-4o)', ApiRoute: 'aoai/gpt-4o' },
{ Name: 'Azure Open AI (GPT-3.5 Turbo)', ApiRoute: 'aoai/gpt-35-turbo' }
]

maxTextLength: number = 5000;
Expand All @@ -63,7 +64,7 @@ export class AppComponent implements OnInit {
sourceText: ['', [Validators.required]],
sourceLanguage: [this.languageList[0].Code, [Validators.required]],
targetLanguage: [this.languageList[2].Code, [Validators.required]],
apiProvider: [this.providerList[0].Code, [Validators.required]]
apiProvider: [this.providerList[0].ApiRoute, [Validators.required]]
})
}

Expand Down Expand Up @@ -91,7 +92,7 @@ export class AppComponent implements OnInit {
this.languageList.find(l => l.Code === this.sourceForm.controls['targetLanguage'].value)!,
this.sourceForm.controls['sourceText'].value,
this.translatedText,
this.providerList.find(p => p.Code === this.sourceForm.controls['apiProvider'].value)!
this.providerList.find(p => p.ApiRoute === this.sourceForm.controls['apiProvider'].value)!
);

this.loadTranslations();
Expand Down Expand Up @@ -171,7 +172,7 @@ export class AppComponent implements OnInit {
this.sourceForm.controls['sourceLanguage'].setValue(translation.SourceLanguage.Code);
this.sourceForm.controls['targetLanguage'].setValue(translation.TargetLanguage.Code);
this.sourceForm.controls['sourceText'].setValue(translation.SourceText);
this.sourceForm.controls['apiProvider'].setValue(translation.Provider.Code);
this.sourceForm.controls['apiProvider'].setValue(translation.Provider.ApiRoute);

this.translatedText = translation.TranslatedText;
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export interface LanguageChoice {
}

export interface ApiProvider {
Code: string;
Name: string;
ApiRoute: string;
}
4 changes: 2 additions & 2 deletions web/src/services/azure-translator-proxy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { HttpClient } from '@angular/common/http';
export class AzureTranslatorProxyService {
constructor(private http: HttpClient) { }

translate(request: TranslationRequest, provider: string) {
let url = `/api/translation/${provider}`;
translate(request: TranslationRequest, route: string) {
let url = `/api/translation/${route}`;
return this.http.post(url, request);
}
}
Expand Down

0 comments on commit af78a25

Please sign in to comment.