-
Notifications
You must be signed in to change notification settings - Fork 18
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
Mccloskey/llama2 hf #17
Conversation
…bator/CP4M into mccloskey/llama2-hf
public T handle(ThreadState<T> messageStack) throws IOException { | ||
T fromUser = messageStack.tail(); | ||
@Override | ||
public T handle(ThreadState<T> threadState) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
HuggingFaceLlamaPromptBuilder<T> promptBuilder = new HuggingFaceLlamaPromptBuilder<>(); | ||
|
||
String prompt = promptBuilder.createPrompt(threadState, config); | ||
if (prompt.equals("I'm sorry but that request was too long for me.")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just have createPrompt
return an Optional
instead of doing string check like this
|
||
body.put("inputs", prompt); | ||
|
||
String bodyString; | ||
try { | ||
bodyString = MAPPER.writeValueAsString(body); | ||
} catch (JsonProcessingException e) { | ||
throw new RuntimeException(e); // this should be impossible | ||
throw new RuntimeException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just add a comment saying this should be impossible
try { | ||
resource = Objects.requireNonNull(HuggingFaceLlamaPromptBuilder.class.getClassLoader().getResource("llamaTokenizer.json")).toURI(); | ||
} catch (URISyntaxException e) { | ||
LOGGER.error("Failed to find local llama tokenizer.json file", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a fatal error, lets throw an exception. Continuing on after a fatal error is a great way to get unexpected input downstream
LOGGER.error("Failed to find local llama tokenizer.json file", e); | |
LOGGER.error("Failed to find local llama tokenizer.json file", e); | |
throw new RuntimeException(e); |
} | ||
|
||
try { | ||
assert resource != null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert
in java only runs in unit test (I know it's weird), that's why we have Objects.requiresNonNull()
Identifier.random(), | ||
Identifier.random(), | ||
Message.Role.SYSTEM); | ||
ArrayList<Message> output = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way we can avoid creating a intermediary list object here? If not lets at least initiate the size of the array list because we know that.
No description provided.