Skip to content

Commit

Permalink
ollamaloglog
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb-T-Owens committed Jan 17, 2025
1 parent 3f80238 commit 6d2ddba
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions apps/desktop/src/lib/ai/ollamaClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,22 @@ ${JSON.stringify(OLLAMA_CHAT_MESSAGE_FORMAT_SCHEMA, null, 2)}`
* @returns A Promise that resolves to the Response object.
*/
private async fetchChat(request: OllamaChatRequest): Promise<unknown> {
console.log(request);
const url = new URL(OllamaAPEndpoint.Chat, this.endpoint);
console.log(url);
const body = JSON.stringify(request);
console.log(body);

return await fetch(url.toString(), {
const response = await fetch(url.toString(), {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body
}).then(async (response) => await response.json());
});
console.log(response);

return await response.json();
}

/**
Expand All @@ -163,6 +169,7 @@ ${JSON.stringify(OLLAMA_CHAT_MESSAGE_FORMAT_SCHEMA, null, 2)}`
options,
format: 'json'
});
console.log(result);

if (!isOllamaChatResponse(result)) {
throw new Error('Invalid response\n' + JSON.stringify(result));
Expand Down

0 comments on commit 6d2ddba

Please sign in to comment.