diff --git a/README.md b/README.md index fd69ecb..2574e98 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ function runZKInference() public { // Extract and use model output if (output.is_simulation_result == false) { - TensorLib.Number prediction = output.numbers[0].values[0]; + TensorLib.Number memory prediction = output.numbers[0].values[0]; // Use prediction in your business logic... } } @@ -132,19 +132,20 @@ function getPrediction(string memory _base, string memory _quote, uint32 _total_ base: _base, quote: _quote, total_candles: _total_candles, + candle_duration_in_mins: 1, order: CandleOrder.Ascending, candle_types: candles }); // Execute inference using historical data - ModelOutput memory output = OG_HISTORICAL_CONTRACT.runHistoricalInference( + ModelOutput memory output = OG_HISTORICAL_CONTRACT.runInferenceOnPriceFeed( "QmcLzTJ6yWF5wgW2CAkhNyJ5Tj2sb7YxkeXVVxo3WNW315", "open_high_low_close", input); // Handle result if (output.is_simulation_result == false) { - TensorLib.Number prediction = output.numbers[0].values[0]; + TensorLib.Number memory prediction = output.numbers[0].values[0]; // Use prediction... } } @@ -171,8 +172,8 @@ The OpenGradient Network is an EVM chain compatible with most existing EVM frame ## Learn More -- [**Model Hub**](hub.opengradient.ai): Browse available models -- [**Docs**](docs.opengradient.ai): Official docs +- [**Model Hub**](https://hub.opengradient.ai): Browse available models +- [**Docs**](https://docs.opengradient.ai): Official docs ## Contributing diff --git a/examples/run_historical.sol b/examples/run_historical.sol index 49047cf..0511d11 100644 --- a/examples/run_historical.sol +++ b/examples/run_historical.sol @@ -2,9 +2,12 @@ pragma solidity ^0.8.18; import "../src/interfaces/OGHistorical.sol"; -import "../lib/TensorLib.sol"; +import "../src/lib/TensorLib.sol"; contract HistoricalInference { + TensorLib.Number[] public results; + TensorLib.Number public resultNumber; + function queryCandlesPrice(string memory _base, string memory _quote, uint32 _total_candles) public{ CandleType[] memory candles = new CandleType[](4); candles[0]=CandleType.Open; @@ -16,6 +19,7 @@ contract HistoricalInference { base: _base, quote: _quote, total_candles: _total_candles, + candle_duration_in_mins: 1, order: CandleOrder.Ascending, // Choose Ascending or descending timestamps for candles candle_types: candles }); @@ -39,15 +43,16 @@ contract HistoricalInference { base: _base, quote: _quote, total_candles: _total_candles, + candle_duration_in_mins: 1, order: CandleOrder.Ascending, // Choose Ascending or descending timestamps for candles candle_types: candles }); // execute inference - ModelOutput memory output = OG_HISTORICAL_CONTRACT.runHistoricalInference( + ModelOutput memory output = OG_HISTORICAL_CONTRACT.runInferenceOnPriceFeed( "QmcLzTJ6yWF5wgW2CAkhNyJ5Tj2sb7YxkeXVVxo3WNW315", "open_high_low_close", - input_query); + input); // handle result if (output.is_simulation_result == false) { diff --git a/src/interfaces/OGHistorical.sol b/src/interfaces/OGHistorical.sol index fb8bf66..25b15b7 100644 --- a/src/interfaces/OGHistorical.sol +++ b/src/interfaces/OGHistorical.sol @@ -7,7 +7,7 @@ import "../lib/TensorLib.sol"; /// @dev The OGHistorical contract's address. address constant OG_HISTORICAL_ADDRESS = 0x00000000000000000000000000000000000000F5; -/// @dev The OGInference contract's instance. +/// @dev The OGHistorical contract's instance. OGHistorical constant OG_HISTORICAL_CONTRACT = OGHistorical(OG_HISTORICAL_ADDRESS); enum CandleOrder { diff --git a/src/interfaces/OGInference.sol b/src/interfaces/OGInference.sol index 3426795..57cf082 100644 --- a/src/interfaces/OGInference.sol +++ b/src/interfaces/OGInference.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.18; import "../lib/TensorLib.sol"; -/// @dev The OGInfernece contract's address. +/// @dev The OGInference contract's address. address constant OG_INFERENCE_ADDRESS = 0x00000000000000000000000000000000000000F4; /// @dev The OGInference contract's instance. diff --git a/src/lib/TensorLib.sol b/src/lib/TensorLib.sol index cd784b8..49048c0 100644 --- a/src/lib/TensorLib.sol +++ b/src/lib/TensorLib.sol @@ -118,7 +118,7 @@ library TensorLib { uint256 multiplier = 1; for (uint256 i = shape.length; i > 0; i--) { - require(indices[i-1] >= 0 && indices[i-1] < shape[i-1], "Index out of bounds"); + require(indices[i-1] < shape[i-1], "Index out of bounds"); flatIndex += uint256(indices[i-1]) * multiplier; multiplier *= uint256(shape[i-1]); }