added custom client for ollama

This commit is contained in:
Yogesh Ojha
2024-05-12 18:59:41 +05:30
parent d800081205
commit 36967f8fc3
2 changed files with 34 additions and 0 deletions
+6
View File
@@ -436,6 +436,12 @@ PERM_INITATE_SCANS_SUBSCANS = 'initiate_scans_subscans'
FOUR_OH_FOUR_URL = '/404/'
###############################################################################
# OLLAMA DEFINITIONS
###############################################################################
OLLAMA_INSTANCE = 'http://ollama:11434'
# GPT Vulnerability Report Generator
VULNERABILITY_DESCRIPTION_SYSTEM_MESSAGE = """
You are a highly skilled penetration tester who has recently completed a penetration testing.
+28
View File
@@ -0,0 +1,28 @@
from reNgine.definitions import OLLAMA_INSTANCE
from ollama import Client
class CustomOllamaClient:
def __init__(self, ):
self.instance_url = OLLAMA_INSTANCE
self.client = None
def connect(self):
try:
self.client = Client(
host=self.instance_url
)
return {
'status': True
}
except Exception as e:
return {
'status': False,
'error': str(e)
}
def list_models(self,):
return self.client.list()
def pull_model(self, model_name):
return self.client.pull(model_name)