Skip to content

Commit

Permalink
handle empty file
Browse files Browse the repository at this point in the history
  • Loading branch information
mike dupont committed Feb 21, 2024
1 parent 0b793c5 commit dc4e525
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bin/simple_grammar.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
open Lang_agent


type backend =
| BNone
| BLlamaCpp of Llama_cpp.llama_cpp_lang_model
Expand Down Expand Up @@ -126,10 +125,13 @@ let lc_init lang_client aurl amodel agrammar=

let read_whole_file filename =
(print_endline ("DEBUG1 read :" ^ filename));
let ch = open_in_bin filename in
let s = really_input_string ch (in_channel_length ch) in
close_in ch;
s
if filename == "" then
""
else
let ch = open_in_bin filename in
let s = really_input_string ch (in_channel_length ch) in
close_in ch;
s

let () =
let start = ref "" in
Expand Down

0 comments on commit dc4e525

Please sign in to comment.