forked from pinterest/querybook
-
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.
feat: use websocket for ai assistant (pinterest#1311)
* feat: use websocket for ai assistant * fix node test * comments * remove memory and add keep button * fix linter
- Loading branch information
Showing
24 changed files
with
507 additions
and
442 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from enum import Enum | ||
|
||
|
||
# KEEP IT CONSISTENT AS webapp/const/aiAssistant.ts | ||
class AICommandType(Enum): | ||
SQL_FIX = "SQL_FIX" | ||
SQL_TITLE = "SQL_TITLE" | ||
TEXT_TO_SQL = "TEXT_TO_SQL" | ||
RESET_MEMORY = "RESET_MEMORY" | ||
|
||
|
||
AI_ASSISTANT_NAMESPACE = "/ai_assistant" | ||
AI_ASSISTANT_REQUEST_EVENT = "ai_assistant_request" | ||
AI_ASSISTANT_RESPONSE_EVENT = "ai_assistant_response" |
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.
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,7 +1,9 @@ | ||
from . import query_execution | ||
from . import datadoc | ||
from . import connect | ||
from . import ai_assistant | ||
|
||
connect | ||
query_execution | ||
datadoc | ||
ai_assistant |
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,13 @@ | ||
from const.ai_assistant import ( | ||
AI_ASSISTANT_NAMESPACE, | ||
AI_ASSISTANT_REQUEST_EVENT, | ||
) | ||
|
||
from .helper import register_socket | ||
|
||
|
||
@register_socket(AI_ASSISTANT_REQUEST_EVENT, namespace=AI_ASSISTANT_NAMESPACE) | ||
def ai_assistant_request(command_type: str, payload={}): | ||
from lib.ai_assistant import ai_assistant | ||
|
||
ai_assistant.handle_ai_command(command_type, payload) |
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,11 +1,14 @@ | ||
from env import QuerybookSettings | ||
|
||
from .all_ai_assistants import get_ai_assistant_class | ||
|
||
|
||
if QuerybookSettings.AI_ASSISTANT_PROVIDER: | ||
from .ai_assistant import AIAssistant | ||
ai_assistant = get_ai_assistant_class(QuerybookSettings.AI_ASSISTANT_PROVIDER) | ||
ai_assistant.set_config(QuerybookSettings.AI_ASSISTANT_CONFIG) | ||
|
||
ai_assistant = AIAssistant( | ||
QuerybookSettings.AI_ASSISTANT_PROVIDER, QuerybookSettings.AI_ASSISTANT_CONFIG | ||
) | ||
else: | ||
ai_assistant = None | ||
|
||
|
||
__all__ = ["ai_assistant"] |
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
Oops, something went wrong.