-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
9726d5e
commit 8d4aa77
Showing
18 changed files
with
132 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
from .mindsdb_connector import MindsDBConnector | ||
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import mindsdb_sdk | ||
|
||
|
||
class Connector: | ||
@classmethod | ||
def connect(cls): | ||
return mindsdb_sdk.connect() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
|
||
from connectors.mindsdb.connector import Connector | ||
|
||
|
||
class ChatDB: | ||
DB_ENGINE = 'yugabyte' | ||
DB_NAME_IN_SOURCE = 'demo' | ||
SCHEMA_NAME_IN_SOURCE = 'public' | ||
DB_PORT = 5433 | ||
DB_CONNECTION_ARGS = { | ||
"user": os.environ.get('DB_USER'), | ||
"password": os.environ.get('DB_PASSWORD'), | ||
"host": os.environ.get('DB_HOST'), | ||
"port": DB_PORT, | ||
"database": DB_NAME_IN_SOURCE, | ||
"schema": SCHEMA_NAME_IN_SOURCE | ||
} | ||
|
||
# Get the connection lazily | ||
server = Connector.connect() | ||
|
||
def create_database(self, db_name): | ||
return self.server.create_database( | ||
engine=self.DB_ENGINE, | ||
name=db_name, | ||
connection_args=self.DB_CONNECTION_ARGS | ||
) | ||
|
||
def get_database(self, db_name): | ||
return self.server.get_database(db_name) | ||
|
||
def drop_database(self, db_name): | ||
self.server.drop_database(db_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ChatInput: | ||
def query_table(self): | ||
pass | ||
|
||
def insert_into_table(self): | ||
pass | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import os | ||
|
||
from connectors.mindsdb.project.mind_reader_project import MindReaderProject | ||
|
||
|
||
class GPTModel: | ||
|
||
MODEL_ENGINE = 'openai' | ||
MODEL_NAME = 'text-davinci-003' | ||
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY') | ||
model_name = 'gpt_model' | ||
project = MindReaderProject().get_project() | ||
|
||
def __init__(self): | ||
# self.create_model() | ||
pass | ||
|
||
def create_model(self): | ||
return self.project.create_model( | ||
name=self.model_name, | ||
predict='response', | ||
engine=self.MODEL_ENGINE, | ||
options={ | ||
'model_name': self.MODEL_NAME, | ||
'api_key': self.OPENAI_API_KEY, | ||
'prompt_template': ''' | ||
Reply like a friend who cares and wants to help. | ||
Input message: {{text}} | ||
In less than 550 characters, when there's some sign of distress in the input share healthy habits, | ||
motivational quotes, inspirational real-life stories. | ||
Provide options to seek out in-person help if you aren't able to satisfy. | ||
Keep the conversation going by asking them to share more. Be a good listener and conversationalist. | ||
In case there's no signs of distress then reply casually like how you would engage in conversation. | ||
''', | ||
'max_tokens': 300 | ||
} | ||
) | ||
|
||
def get_model(self): | ||
return self.project.get_model(self.model_name) | ||
|
||
def drop_model(self): | ||
self.project.drop_model(self.model_name) | ||
|
||
def predict(self, data): | ||
prediction_query = f''' | ||
SELECT response | ||
FROM {MindReaderProject.PROJECT_NAME}.{self.model_name} | ||
WHERE text = "{data}"; | ||
''' | ||
# Query on the model in the project to make predictions based on data | ||
query = self.project.query(prediction_query) | ||
return query.fetch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class ChatJob: | ||
def create_job(self): | ||
pass | ||
|
||
def get_job(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from connectors.mindsdb.connector import Connector | ||
|
||
|
||
class MindReaderProject: | ||
PROJECT_NAME = 'mind_reader_project' | ||
# Get the connection lazily | ||
server = Connector.connect() | ||
|
||
def __init__(self): | ||
# self.create_project() | ||
pass | ||
|
||
def create_project(self): | ||
return self.server.create_project(self.PROJECT_NAME) | ||
|
||
def get_project(self): | ||
return self.server.get_project(self.PROJECT_NAME) | ||
|
||
def drop_project(self): | ||
self.server.drop_project(self.PROJECT_NAME) |
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.