Skip to content

Commit 409c811

Browse files
committed
feat(ollama): use axios instead of fetch
1 parent b5acf34 commit 409c811

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib/providers/ollama.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { OllamaEmbeddings } from '@langchain/community/embeddings/ollama';
22
import { getKeepAlive, getOllamaApiEndpoint } from '../../config';
33
import logger from '../../utils/logger';
44
import { ChatOllama } from '@langchain/community/chat_models/ollama';
5+
import axios from 'axios';
56

67
export const loadOllamaChatModels = async () => {
78
const ollamaEndpoint = getOllamaApiEndpoint();
@@ -10,13 +11,13 @@ export const loadOllamaChatModels = async () => {
1011
if (!ollamaEndpoint) return {};
1112

1213
try {
13-
const response = await fetch(`${ollamaEndpoint}/api/tags`, {
14+
const response = await axios.get(`${ollamaEndpoint}/api/tags`, {
1415
headers: {
1516
'Content-Type': 'application/json',
1617
},
1718
});
1819

19-
const { models: ollamaModels } = (await response.json()) as any;
20+
const { models: ollamaModels } = response.data;
2021

2122
const chatModels = ollamaModels.reduce((acc, model) => {
2223
acc[model.model] = {
@@ -45,13 +46,13 @@ export const loadOllamaEmbeddingsModels = async () => {
4546
if (!ollamaEndpoint) return {};
4647

4748
try {
48-
const response = await fetch(`${ollamaEndpoint}/api/tags`, {
49+
const response = await axios.get(`${ollamaEndpoint}/api/tags`, {
4950
headers: {
5051
'Content-Type': 'application/json',
5152
},
5253
});
5354

54-
const { models: ollamaModels } = (await response.json()) as any;
55+
const { models: ollamaModels } = response.data;
5556

5657
const embeddingsModels = ollamaModels.reduce((acc, model) => {
5758
acc[model.model] = {

0 commit comments

Comments
 (0)