This commit is contained in:
2024-11-17 13:41:20 -05:00
parent b33470a412
commit 4e782de528
6 changed files with 198 additions and 10 deletions

View File

@ -169,13 +169,23 @@ class AI(FastAPI):
# }
# ai_req_data = {
# 'max_context_length': 8192,
# 'max_length': 256,
# 'temperature': 0.3,
# 'max_length': 512,
# 'temperature': 0,
# 'n': 1,
# 'top_k': 30,
# 'top_a': 0,
# 'top_p': 0,
# 'typical': 0,
# 'mirostat': 0,
# 'use_default_badwordsids': False,
# 'rep_pen': 1.0,
# 'rep_pen_range': 320,
# 'rep_pen_slope': 0.05,
# 'quiet': 1,
# 'bypass_eos': False,
# 'trim_stop': True,
# # 'trim_stop': True,
# 'sampler_order': [6,0,1,3,4,2,5],
# 'memory': "You are a helpful assistant who will provide only totally accurate tidbits of info on songs the user may listen to. You do not include information about which album a song was released on, or when it was released, and do not mention that you are not including this information in your response. If the input provided is not a song you are aware of, simply state that. Begin your output at your own response.",
# 'memory': "You are a helpful assistant who will provide ONLY TOTALLY ACCURATE tidbits of info on songs the user may listen to. You do not include information about which album a song was released on, or when it was released, and do not mention that you are not including this information in your response. If the input provided is not a song you are aware of, simply state that. Begin your output at your own response.",
# 'stop': ['### Inst', '### Resp'],
# 'prompt': ai_question
# }

View File

@ -41,7 +41,7 @@ class KarmaDB:
async def get_karma(self, keyword: str) -> int | dict:
async with sqlite3.connect(self.db_path, timeout=2) as db_conn:
async with db_conn.execute("SELECT score FROM karma WHERE keyword = ? LIMIT 1", (keyword,)) as db_cursor:
async with db_conn.execute("SELECT score FROM karma WHERE keyword LIKE ? LIMIT 1", (keyword,)) as db_cursor:
try:
(score,) = await db_cursor.fetchone()
return score
@ -65,7 +65,7 @@ class KarmaDB:
return
modifier = "score + 1" if not flag else "score - 1"
query = f"UPDATE karma SET score = {modifier}, last_change = ? WHERE keyword = ?"
query = f"UPDATE karma SET score = {modifier}, last_change = ? WHERE keyword LIKE ?"
new_keyword_query = "INSERT INTO karma(keyword, score, last_change) VALUES(?, ?, ?)"
friendly_flag = "++" if not flag else "--"
audit_message = f"{granter} adjusted karma for {keyword} @ {datetime.datetime.now().isoformat()}: {friendly_flag}"
@ -119,7 +119,7 @@ class Karma(FastAPI):
"""
/karma/top/
Get top keywords for karma
Requires key
(Requires key)
"""
if not self.util.check_key(request.url.path, request.headers.get('X-Authd-With')):
@ -140,13 +140,16 @@ class Karma(FastAPI):
'errorText': 'Exception occurred.',
}
async def get_karma_handler(self, data: ValidKarmaRetrievalRequest):
async def get_karma_handler(self, data: ValidKarmaRetrievalRequest, request: Request):
"""
/karma/get/
Get current karma value
Requires key
(Requires key)
"""
if not self.util.check_key(request.url.path, request.headers.get('X-Authd-With')):
raise HTTPException(status_code=403, detail="Unauthorized")
keyword = data.keyword
try:
count = await self.db.get_karma(keyword)
@ -165,7 +168,7 @@ class Karma(FastAPI):
"""
/karma/update/
Update karma count
Requires key
(Requires key)
"""
if not self.util.check_key(request.url.path, request.headers.get('X-Authd-With'), 2):