Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes decoding in other languages such as chinese #6

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions minigpt4/minigpt4_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def minigpt4_end_chat_image(self, ctx: MiniGPT4Context, n_threads: int = 0, temp

token = CHAR_PTR()
self.panic_if_error(self.library.minigpt4_end_chat_image(ctx.ptr, ctypes.pointer(token), n_threads, temp, top_k, top_p, tfs_z, typical_p, repeat_last_n, repeat_penalty, alpha_presence, alpha_frequency, mirostat, mirostat_tau, mirostat_eta, penalize_nl))
return ctypes.cast(token, ctypes.c_char_p).value.decode('utf-8')
return ctypes.cast(token, ctypes.c_char_p).value.decode()

def minigpt4_system_prompt(self, ctx: MiniGPT4Context, n_threads: int = 0):
"""
Expand Down Expand Up @@ -417,7 +417,7 @@ def minigpt4_end_chat(self, ctx: MiniGPT4Context, n_threads: int = 0, temp: floa

token = CHAR_PTR()
self.panic_if_error(self.library.minigpt4_end_chat(ctx.ptr, ctypes.pointer(token), n_threads, temp, top_k, top_p, tfs_z, typical_p, repeat_last_n, repeat_penalty, alpha_presence, alpha_frequency, mirostat, mirostat_tau, mirostat_eta, penalize_nl))
return ctypes.cast(token, ctypes.c_char_p).value.decode('utf-8')
return ctypes.cast(token, ctypes.c_char_p).value.decode()

def minigpt4_reset_chat(self, ctx: MiniGPT4Context):
"""
Expand Down Expand Up @@ -498,7 +498,7 @@ def minigpt4_error_code_to_string(self, error_code: int) -> str:
str: Error string.
"""

return self.library.minigpt4_error_code_to_string(error_code).decode('utf-8')
return self.library.minigpt4_error_code_to_string(error_code).decode()

def minigpt4_quantize_model(self, in_path: str, out_path: str, data_type: DataType):
"""
Expand Down
Loading