Skip to content

Commit

Permalink
auto format
Browse files Browse the repository at this point in the history
  • Loading branch information
karlkallas committed Jun 27, 2024
1 parent e2c5cbf commit 2061b7e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 36 deletions.
42 changes: 23 additions & 19 deletions contracts/contracts/AnthropicSimpleLLM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ contract SimpleLLM {

constructor() {
config = IOracle.LlmRequest({
model : "claude-3-5-sonnet-20240620", // "claude-3-5-sonnet-20240620", "claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-3-haiku-20240307", "claude-2.1", "claude-2.0", "claude-instant-1.2"
frequencyPenalty : 21, // > 20 for null
logitBias : "", // empty str for null
maxTokens : 1000, // 0 for null
presencePenalty : 21, // > 20 for null
responseFormat : "{\"type\":\"text\"}",
seed : 0, // null
stop : "", // null
temperature : 10, // Example temperature (scaled up, 10 means 1.0), > 20 means null
topP : 101, // Percentage 0-100, > 100 means null
tools : "",
toolChoice : "auto", // "none" or "auto"
user : "" // null
model: "claude-3-5-sonnet-20240620", // "claude-3-5-sonnet-20240620", "claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-3-haiku-20240307", "claude-2.1", "claude-2.0", "claude-instant-1.2"
frequencyPenalty: 21, // > 20 for null
logitBias: "", // empty str for null
maxTokens: 1000, // 0 for null
presencePenalty: 21, // > 20 for null
responseFormat: '{"type":"text"}',
seed: 0, // null
stop: "", // null
temperature: 10, // Example temperature (scaled up, 10 means 1.0), > 20 means null
topP: 101, // Percentage 0-100, > 100 means null
tools: "",
toolChoice: "auto", // "none" or "auto"
user: "" // null
});
}

Expand All @@ -41,23 +41,28 @@ contract SimpleLLM {
message = _message;
IOracle(oracleAddress).createLlmCall(runId, config);
}
// required for Oracle
function onOracleLlmResponse(

// required for Oracle
function onOracleLlmResponse(
uint /*_runId*/,
IOracle.LlmResponse memory _response,
string memory _errorMessage
) public {
require(msg.sender == oracleAddress, "Caller is not oracle");
if (keccak256(abi.encodePacked(_errorMessage)) != keccak256(abi.encodePacked(""))) {
if (
keccak256(abi.encodePacked(_errorMessage)) !=
keccak256(abi.encodePacked(""))
) {
response = _errorMessage;
} else {
response = _response.content;
}
}

// required for Oracle
function getMessageHistory(uint /*_runId*/) public view returns (IOracle.Message[] memory) {
function getMessageHistory(
uint /*_runId*/
) public view returns (IOracle.Message[] memory) {
IOracle.Message memory newMessage = IOracle.Message({
role: "user",
content: new IOracle.Content[](1)
Expand All @@ -71,4 +76,3 @@ contract SimpleLLM {
return newMessages;
}
}

38 changes: 21 additions & 17 deletions contracts/contracts/GroqSimpleLLM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ contract SimpleLLM {

constructor() {
config = IOracle.GroqRequest({
model : "mixtral-8x7b-32768", // "llama3-8b-8192", "llama3-70b-8192", "mixtral-8x7b-32768" or "gemma-7b-it"
frequencyPenalty : 21, // > 20 for null
logitBias : "", // empty str for null
maxTokens : 1000, // 0 for null
presencePenalty : 21, // > 20 for null
responseFormat : "{\"type\":\"text\"}",
seed : 0, // null
stop : "", // null
temperature : 10, // Example temperature (scaled up, 10 means 1.0), > 20 means null
topP : 101, // Percentage 0-100, > 100 means null
user : "" // null
model: "mixtral-8x7b-32768", // "llama3-8b-8192", "llama3-70b-8192", "mixtral-8x7b-32768" or "gemma-7b-it"
frequencyPenalty: 21, // > 20 for null
logitBias: "", // empty str for null
maxTokens: 1000, // 0 for null
presencePenalty: 21, // > 20 for null
responseFormat: '{"type":"text"}',
seed: 0, // null
stop: "", // null
temperature: 10, // Example temperature (scaled up, 10 means 1.0), > 20 means null
topP: 101, // Percentage 0-100, > 100 means null
user: "" // null
});
}

Expand All @@ -39,23 +39,28 @@ contract SimpleLLM {
message = _message;
IOracle(oracleAddress).createGroqLlmCall(runId, config);
}
// required for Oracle
function onOracleGroqLlmResponse(

// required for Oracle
function onOracleGroqLlmResponse(
uint /*_runId*/,
IOracle.GroqResponse memory _response,
string memory _errorMessage
) public {
require(msg.sender == oracleAddress, "Caller is not oracle");
if (keccak256(abi.encodePacked(_errorMessage)) != keccak256(abi.encodePacked(""))) {
if (
keccak256(abi.encodePacked(_errorMessage)) !=
keccak256(abi.encodePacked(""))
) {
response = _errorMessage;
} else {
response = _response.content;
}
}

// required for Oracle
function getMessageHistory(uint /*_runId*/) public view returns (IOracle.Message[] memory) {
function getMessageHistory(
uint /*_runId*/
) public view returns (IOracle.Message[] memory) {
IOracle.Message memory newMessage = IOracle.Message({
role: "user",
content: new IOracle.Content[](1)
Expand All @@ -69,4 +74,3 @@ contract SimpleLLM {
return newMessages;
}
}

0 comments on commit 2061b7e

Please sign in to comment.