Re:ChatGPT4 writes Stan code so I don’t have to
by jpollock on Monday April 24, 2023 @12:25AM
(#35683636)
phind needed two additional prompts to get to correct code.
It needed:
1) write a function in java to decode a rfc 3588 diameter header
2) 32 bit values will not fit into a java int, please fix the code.
3) 24 bit values will not fit into a java int, please fix the code.
I think I'm going to have to come up with a more complicated problem!
Pretty impressively, this is what it produced:
public class DiameterHeader {
private int version;
private long messageLength;
private int commandFlags;
private long commandCode;
private long applicationId;
private long hopByHopId;
private long endToEndId;
public DiameterHeader(byte[] data) {
if (data == null || data.length != 20) {
throw new IllegalArgumentException("Invalid Diameter header data");
}
version = data[0] & 0xFF;
messageLength = ((long) data[1] & 0xFF) << 16 | ((long) data[2] & 0xFF) << 8 | ((long) data[3] & 0xFF);
commandFlags = data[4] & 0xFF;
commandCode = ((long) data[5] & 0xFF) << 16 | ((long) data[6] & 0xFF) << 8 | ((long) data[7] & 0xFF);
applicationId = (((long) data[8] & 0xFF) << 24) | (((long) data[9] & 0xFF) << 16) | (((long) data[10] & 0xFF) << 8) | ((long) data[11] & 0xFF);
hopByHopId = (((long) data[12] & 0xFF) << 24) | (((long) data[13] & 0xFF) << 16) | (((long) data[14] & 0xFF) << 8) | ((long) data[15] & 0xFF);
endToEndId = (((long) data[16] & 0xFF) << 24) | (((long) data[17] & 0xFF) << 16) | (((long) data[18] & 0xFF) << 8) | ((long) data[19] & 0xFF);
}
// Getters for the fields
}
Re:ChatGPT4 writes Stan code so I don’t have to
by agileAlligator on Monday April 24, 2023 @04:07AM
(#35684881)
If you have expert mode on it should reference sources most of the time.
Re:ChatGPT4 writes Stan code so I don’t have to
by jpollock on Monday April 24, 2023 @02:10PM
(#35691081)
phind seems to be showing the Google search results as "Sources", rather than the actual code used as training data.
Bard links to a github repo with license information.
Re:ChatGPT4 writes Stan code so I don’t have to
by agileAlligator on Thursday April 27, 2023 @02:24AM
(#35724017)
I was under the impression that the search results were the training data?
What phind does is pulls code from search results and modifies it to suit your needs.
Still has the "won't fit in an int" problem, but it did use byte & 0x77 to get them into ints.
Amazingly, it got the field correct and in the right order!
It did not reference a source, but that seems to be a Bard feature right now.