Skip to content

Commit

Permalink
chore: resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
railsstudent committed Mar 17, 2024
2 parents edd093f + 2a2b756 commit a128145
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { provideHttpClient } from '@angular/common/http';
import { provideRouter, withComponentInputBinding } from '@angular/router';
import { provideRouter } from '@angular/router';
import { provideMarkdown } from 'ngx-markdown';
import { routes } from './app.routes';
import { provideGeminiApi } from './gemini/gemini.provider';

export const appConfig = {
providers: [
provideHttpClient(),
provideRouter(routes, withComponentInputBinding()),
provideRouter(routes),
provideGeminiApi(),
provideMarkdown()
]
Expand Down
2 changes: 1 addition & 1 deletion src/app/gemini/chat-history/chat-history.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Output, input } from '@angular/core';
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { MarkdownComponent } from 'ngx-markdown';
import { HistoryItem } from '../interfaces/history-item.interface';
import { LineBreakPipe } from '../pipes/line-break.pipe';
Expand Down
15 changes: 15 additions & 0 deletions src/app/gemini/custom-operators/generate-text.operator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Observable, catchError, map, of, retry, tap } from 'rxjs';

export function generateText(numRetries: number) {
return function(source: Observable<any>) {
return source.pipe(
retry(numRetries),
tap((response) => console.log(response)),
map((response) => response.candidates?.[0].content?.parts?.[0].text || 'No response' ),
catchError((err) => {
console.error(err);
return of('Error occurs');
})
);
}
}
23 changes: 4 additions & 19 deletions src/app/gemini/services/gemini.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';
import { Observable, catchError, map, of, retry, tap } from 'rxjs';
import { Observable } from 'rxjs';
import { generateText } from '../custom-operators/generate-text.operator';
import { GEMINI_GENERATION_CONFIG, GEMINI_PRO_URL, GEMINI_PRO_VISION_URL, GEMINI_SAFETY_SETTINGS } from '../gemini.constant';
import { GeminiResponse } from '../interfaces/generate-response.interface';
import { MultimodalInquiry } from '../interfaces/genmini.interface';
Expand Down Expand Up @@ -34,15 +35,7 @@ export class GeminiService {
"Content-Type": "application/json"
}
})
.pipe(
retry(3),
tap((response) => console.log(response)),
map((response) => response.candidates?.[0].content?.parts?.[0].text || 'No response' ),
catchError((err) => {
console.error(err);
return of('Error occurs');
})
);
.pipe(generateText(3));
}

generateTextFromMultimodal({ prompt, mimeType, base64Data }: MultimodalInquiry): Observable<string> {
Expand Down Expand Up @@ -70,14 +63,6 @@ export class GeminiService {
"Content-Type": "application/json"
}
})
.pipe(
retry(3),
tap((response) => console.log(response)),
map((response) => response.candidates?.[0].content?.parts?.[0].text || 'No response' ),
catchError((err) => {
console.error(err);
return of('Error occurs');
})
);
.pipe(generateText(3));
}
}

0 comments on commit a128145

Please sign in to comment.