fix: build

This commit is contained in:
pablo 2026-03-27 10:51:45 +01:00
parent 14a403399e
commit cdd58ec7f4
No known key found for this signature in database
GPG Key ID: 78F35FCC60FDC63A
2 changed files with 4 additions and 4 deletions

View File

@ -52,8 +52,8 @@ pub struct ContextHandle(pub(crate) Context);
/// so the caller always gets a deterministic name reflecting their input. /// so the caller always gets a deterministic name reflecting their input.
#[ffi_export] #[ffi_export]
pub fn create_context(name: c_slice::Ref<'_, u8>) -> repr_c::Box<ContextHandle> { pub fn create_context(name: c_slice::Ref<'_, u8>) -> repr_c::Box<ContextHandle> {
let name_str = std::string::String::from_utf8_lossy(name.as_slice()); let name_str = std::string::String::from_utf8_lossy(name.as_slice()).into_owned();
Box::new(ContextHandle(Context::new_with_name(&name_str))).into() Box::new(ContextHandle(Context::new_with_name(name_str))).into()
} }
/// Returns the friendly name of the contexts installation. /// Returns the friendly name of the contexts installation.

View File

@ -15,7 +15,7 @@ type
## Create a new conversations context ## Create a new conversations context
proc newConversationsContext*(name: string): LibChat = proc newConversationsContext*(name: string): LibChat =
result.handle = create_context(name.toReprCString) result.handle = create_context(name.toSlice)
result.buffer_size = 256 result.buffer_size = 256
if result.handle.isNil: if result.handle.isNil:
raise newException(IOError, "Failed to create context") raise newException(IOError, "Failed to create context")
@ -95,7 +95,7 @@ proc sendContent*(ctx: LibChat, convoId: string, content: seq[byte]): Result[seq
if content.len == 0: if content.len == 0:
return err("content is zero length") return err("content is zero length")
let res = bindings.send_content(ctx.handle, convoId.toReprCString, content.toSlice()) let res = bindings.send_content(ctx.handle, convoId.toSlice, content.toSlice())
defer: destroy_send_content_result(res) defer: destroy_send_content_result(res)
if res.error_code != 0: if res.error_code != 0: