feat(ollama): use axios instead of fetch
This commit is contained in:
parent
b5acf34ef8
commit
409c811a42
1 changed files with 5 additions and 4 deletions
|
@ -2,6 +2,7 @@ import { OllamaEmbeddings } from '@langchain/community/embeddings/ollama';
|
||||||
import { getKeepAlive, getOllamaApiEndpoint } from '../../config';
|
import { getKeepAlive, getOllamaApiEndpoint } from '../../config';
|
||||||
import logger from '../../utils/logger';
|
import logger from '../../utils/logger';
|
||||||
import { ChatOllama } from '@langchain/community/chat_models/ollama';
|
import { ChatOllama } from '@langchain/community/chat_models/ollama';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
export const loadOllamaChatModels = async () => {
|
export const loadOllamaChatModels = async () => {
|
||||||
const ollamaEndpoint = getOllamaApiEndpoint();
|
const ollamaEndpoint = getOllamaApiEndpoint();
|
||||||
|
@ -10,13 +11,13 @@ export const loadOllamaChatModels = async () => {
|
||||||
if (!ollamaEndpoint) return {};
|
if (!ollamaEndpoint) return {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${ollamaEndpoint}/api/tags`, {
|
const response = await axios.get(`${ollamaEndpoint}/api/tags`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { models: ollamaModels } = (await response.json()) as any;
|
const { models: ollamaModels } = response.data;
|
||||||
|
|
||||||
const chatModels = ollamaModels.reduce((acc, model) => {
|
const chatModels = ollamaModels.reduce((acc, model) => {
|
||||||
acc[model.model] = {
|
acc[model.model] = {
|
||||||
|
@ -45,13 +46,13 @@ export const loadOllamaEmbeddingsModels = async () => {
|
||||||
if (!ollamaEndpoint) return {};
|
if (!ollamaEndpoint) return {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${ollamaEndpoint}/api/tags`, {
|
const response = await axios.get(`${ollamaEndpoint}/api/tags`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { models: ollamaModels } = (await response.json()) as any;
|
const { models: ollamaModels } = response.data;
|
||||||
|
|
||||||
const embeddingsModels = ollamaModels.reduce((acc, model) => {
|
const embeddingsModels = ollamaModels.reduce((acc, model) => {
|
||||||
acc[model.model] = {
|
acc[model.model] = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue