File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -139,10 +139,11 @@ def get_text_embedding(self, text: str):
139139
140140class OllamaEmbeddings :
141141
142+ # Uses OpenAI API standard
142143 # Format:
143- # curl http://localhost:11434/api /embeddings -d '{
144+ # curl http://localhost:11434/v1 /embeddings -d '{
144145 # "model": "mxbai-embed-large",
145- # "prompt ": "Llamas are members of the camelid family"
146+ # "input ": "Llamas are members of the camelid family"
146147 # }'
147148
148149 def __init__ (self , model : str , base_url : str , ollama_additional_kwargs : dict ):
@@ -154,18 +155,18 @@ def get_text_embedding(self, text: str):
154155 import httpx
155156
156157 headers = {"Content-Type" : "application/json" }
157- json_data = {"model" : self .model , "prompt " : text }
158+ json_data = {"model" : self .model , "input " : text }
158159 json_data .update (self .ollama_additional_kwargs )
159160
160161 with httpx .Client () as client :
161162 response = client .post (
162- f"{ self .base_url } /api/ embeddings" ,
163+ f"{ self .base_url } /embeddings" ,
163164 headers = headers ,
164165 json = json_data ,
165166 )
166167
167168 response_json = response .json ()
168- return response_json ["embedding" ]
169+ return response_json ["data" ][ 0 ][ " embedding" ]
169170
170171
171172class GoogleEmbeddings :
You can’t perform that action at this time.
0 commit comments