added really good token checking
This commit is contained in:
parent
c3e66c64c1
commit
06d91153a2
|
@ -155,7 +155,7 @@ cython_debug/
|
|||
|
||||
#ML
|
||||
VeraMind-Mini/
|
||||
Token.py
|
||||
Token.txt
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
from langchain_community.llms import Ollama
|
||||
from Ai.Token import get_token
|
||||
|
||||
|
||||
class ArticleRater:
|
||||
def __init__(self):
|
||||
self.client = "https://ai.fabelous.app/v1/ollama/generic"
|
||||
self.headers = {"Authorization": f"Token {get_token()}"}
|
||||
self.token = self._get_token()
|
||||
self.headers = {"Authorization": f"Token {self.token}"}
|
||||
|
||||
def _get_token(self):
|
||||
with open("Token/Token.txt", "r") as t:
|
||||
return t.readline().strip()
|
||||
def get_response(self, article, result, confidence):
|
||||
ollama_params = {
|
||||
"base_url": self.client,
|
||||
|
|
|
@ -7,7 +7,6 @@ from utils.database.database import FakeNewsChecker
|
|||
from models.provider import Provider
|
||||
from collections import Counter
|
||||
from Ai.llm import ArticleRater
|
||||
from Ai.Token import get_token
|
||||
|
||||
|
||||
class MainFrameController:
|
||||
|
@ -63,7 +62,7 @@ class MainFrameController:
|
|||
confidence_color = "green" if confidence > 80 else ("orange" if confidence > 50 else "red")
|
||||
self.frame.confidence_label.configure(fg_color=confidence_color)
|
||||
|
||||
if get_token().strip():
|
||||
if self.rater.token:
|
||||
response_stream = self.rater.get_response(text_data.text, text_data.result, confidence)
|
||||
|
||||
for chunk in response_stream:
|
||||
|
|
Loading…
Reference in New Issue