Skip to content

Commit

Permalink
clean: replaced authToken by bearerToken
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinan Karakaya committed Feb 27, 2024
1 parent e87c99a commit 84e2897
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/modules/lineGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export async function* lineGenerator(url: string, data: any, authToken: string): AsyncGenerator<string> {
export async function* lineGenerator(url: string, data: any, bearerToken: string): AsyncGenerator<string> {
// Request
const controller = new AbortController();
let res = await fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: authToken ? {
headers: bearerToken ? {
'Content-Type': 'application/json',
Authorization: `Bearer ${authToken}`,
Authorization: `Bearer ${bearerToken}`,
} : {
'Content-Type': 'application/json',
},
Expand Down
6 changes: 3 additions & 3 deletions src/modules/ollamaCheckModel.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { info } from "./log";

export async function ollamaCheckModel(endpoint: string, model: string, authToken: string) {
export async function ollamaCheckModel(endpoint: string, model: string, bearerToken: string) {
// Check if exists
let res = await fetch(endpoint + '/api/tags', {
headers: authToken ? {
Authorization: `Bearer ${authToken}`,
headers: bearerToken ? {
Authorization: `Bearer ${bearerToken}`,
} : {},
});
if (!res.ok) {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/ollamaDownloadModel.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { lineGenerator } from "./lineGenerator";
import { info } from "./log";

export async function ollamaDownloadModel(endpoint: string, model: string, authToken: string) {
export async function ollamaDownloadModel(endpoint: string, model: string, bearerToken: string) {
info('Downloading model from ollama: ' + model);
for await (let line of lineGenerator(endpoint + '/api/pull', { name: model }, authToken)) {
for await (let line of lineGenerator(endpoint + '/api/pull', { name: model }, bearerToken)) {
info('[DOWNLOAD] ' + line);
}
}
4 changes: 2 additions & 2 deletions src/modules/ollamaTokenGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export type OllamaToken = {
done: boolean
};

export async function* ollamaTokenGenerator(url: string, data: any, authToken: string): AsyncGenerator<OllamaToken> {
for await (let line of lineGenerator(url, data, authToken)) {
export async function* ollamaTokenGenerator(url: string, data: any, bearerToken: string): AsyncGenerator<OllamaToken> {
for await (let line of lineGenerator(url, data, bearerToken)) {
info('Receive line: ' + line);
let parsed: OllamaToken;
try {
Expand Down

0 comments on commit 84e2897

Please sign in to comment.