mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-31 08:51:55 +00:00 
			
		
		
		
	server : embeddings compatibility for OpenAI (#5190)
This commit is contained in:
		| @@ -206,3 +206,18 @@ inline static std::vector<json> format_partial_response_oaicompat(const task_res | ||||
|  | ||||
|     return std::vector<json>({ret}); | ||||
| } | ||||
|  | ||||
| inline static json format_embeddings_response_oaicompat(const json &request, const json &embeddings) | ||||
| { | ||||
|     json res = | ||||
|         json{ | ||||
|             {"model", json_value(request, "model", std::string(DEFAULT_OAICOMPAT_MODEL))}, | ||||
|             {"object", "list"}, | ||||
|             {"usage", | ||||
|                 json{{"prompt_tokens", 0}, | ||||
|                      {"total_tokens", 0}}}, | ||||
|             {"data", embeddings} | ||||
|         }; | ||||
|     return res; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Wu Jian Ping
					Wu Jian Ping