Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Anything Llm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
Mintplex Labs
Anything Llm
Commits
1c11a47f
Unverified
Commit
1c11a47f
authored
11 months ago
by
Timothy Carambat
Committed by
GitHub
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Check ollama alive for embedder (#1057)
parent
6f52a2b7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/utils/EmbeddingEngines/ollama/index.js
+16
-0
16 additions, 0 deletions
server/utils/EmbeddingEngines/ollama/index.js
with
16 additions
and
0 deletions
server/utils/EmbeddingEngines/ollama/index.js
+
16
−
0
View file @
1c11a47f
...
...
@@ -18,12 +18,28 @@ class OllamaEmbedder {
console
.
log
(
`\x1b[36m[
${
this
.
constructor
.
name
}
]\x1b[0m
${
text
}
`
,
...
args
);
}
async
#isAlive
()
{
return
await
fetch
(
process
.
env
.
EMBEDDING_BASE_PATH
,
{
method
:
"
HEAD
"
,
})
.
then
((
res
)
=>
res
.
ok
)
.
catch
((
e
)
=>
{
this
.
log
(
e
.
message
);
return
false
;
});
}
async
embedTextInput
(
textInput
)
{
const
result
=
await
this
.
embedChunks
([
textInput
]);
return
result
?.[
0
]
||
[];
}
async
embedChunks
(
textChunks
=
[])
{
if
(
!
(
await
this
.
#isAlive
()))
throw
new
Error
(
`Ollama service could not be reached. Is Ollama running?`
);
const
embeddingRequests
=
[];
this
.
log
(
`Embedding
${
textChunks
.
length
}
chunks of text with
${
this
.
model
}
.`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment