π Build an AI Sentiment Analyzer on GenLayer
GenLayer allows smart contracts to use LLMs through decentralized consensus. Here is how to build a Sentiment Analyzer.
π The Contract
python
# { "Depends": "py-genlayer:test" }
from genlayer import *
@gl.contract
class SentimentAnalyzer:
last_analysis: str
def __init__(self):
self.last_analysis = "Empty"
@gl.public.write
def analyze(self, text: str) -> str:
self.last_analysis = gl.call_llm(f"Sentiment of: {text}")
return self.last_analysis
Top comments (0)