Skip to content

Commit

Permalink
feat(ollama): use axios instead of fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzCrazyKns committed Dec 26, 2024
1 parent b5acf34 commit 409c811
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib/providers/ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { OllamaEmbeddings } from '@langchain/community/embeddings/ollama';
import { getKeepAlive, getOllamaApiEndpoint } from '../../config';
import logger from '../../utils/logger';
import { ChatOllama } from '@langchain/community/chat_models/ollama';
import axios from 'axios';

export const loadOllamaChatModels = async () => {
const ollamaEndpoint = getOllamaApiEndpoint();
Expand All @@ -10,13 +11,13 @@ export const loadOllamaChatModels = async () => {
if (!ollamaEndpoint) return {};

try {
const response = await fetch(`${ollamaEndpoint}/api/tags`, {
const response = await axios.get(`${ollamaEndpoint}/api/tags`, {
headers: {
'Content-Type': 'application/json',
},
});

const { models: ollamaModels } = (await response.json()) as any;
const { models: ollamaModels } = response.data;

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

try {
const response = await fetch(`${ollamaEndpoint}/api/tags`, {
const response = await axios.get(`${ollamaEndpoint}/api/tags`, {
headers: {
'Content-Type': 'application/json',
},
});

const { models: ollamaModels } = (await response.json()) as any;
const { models: ollamaModels } = response.data;

const embeddingsModels = ollamaModels.reduce((acc, model) => {
acc[model.model] = {
Expand Down

0 comments on commit 409c811

Please sign in to comment.