using System;
using System.Runtime.InteropServices;
namespace LLama.Native;
using clip_ctx = IntPtr;
public static unsafe partial class NativeApi
{
///
/// Sanity check for clip <-> llava embed size match
///
/// LLama Context
/// Llava Model
/// True if validate successfully
[DllImport(llavaLibraryName, EntryPoint = "llava_validate_embed_size", CallingConvention = CallingConvention.Cdecl)]
public static extern bool llava_validate_embed_size( SafeLLamaContextHandle ctxLlama, SafeLlavaModelHandle ctxClip);
///
/// Build an image embed from image file bytes
///
/// SafeHandle to the Clip Model
/// Number of threads
/// Binary image in jpeg format
/// Bytes lenght of the image
/// SafeHandle to the Embeddings
[DllImport(llavaLibraryName, EntryPoint = "llava_image_embed_make_with_bytes",
CallingConvention = CallingConvention.Cdecl)]
public static extern
SafeLlavaImageEmbedHandle llava_image_embed_make_with_bytes(SafeLlavaModelHandle ctx_clip, int n_threads,
byte[] image_bytes, int image_bytes_length);
///
/// Build an image embed from a path to an image filename
///
/// SafeHandle to the Clip Model
/// Number of threads
/// Image filename (jpeg) to generate embeddings
/// SafeHandel to the embeddings
[DllImport(llavaLibraryName, EntryPoint = "llava_image_embed_make_with_filename", CallingConvention = CallingConvention.Cdecl)]
public static extern
SafeLlavaImageEmbedHandle llava_image_embed_make_with_filename(SafeLlavaModelHandle ctx_clip, int n_threads,
[MarshalAs(UnmanagedType.LPStr)] string image_path);
///
/// Free an embedding made with llava_image_embed_make_*
///
/// Embeddings to release
[DllImport(llavaLibraryName, EntryPoint = "llava_image_embed_free", CallingConvention = CallingConvention.Cdecl)]
public static extern void llava_image_embed_free(IntPtr embed);
///
/// Write the image represented by embed into the llama context with batch size n_batch, starting at context
/// pos n_past. on completion, n_past points to the next position in the context after the image embed.
///
/// Llama Context
/// Embedding handle
/// True on success
[DllImport(llavaLibraryName, EntryPoint = "llava_eval_image_embed", CallingConvention = CallingConvention.Cdecl)]
public static extern bool llava_eval_image_embed(SafeLLamaContextHandle ctx_llama, SafeLlavaImageEmbedHandle embed,
int n_batch, ref int n_past);
}