Skip to content

Commit

Permalink
💎 [Feature] ConversationStyle: Use Enum for more intuitive, and set d…
Browse files Browse the repository at this point in the history
…efault styles
  • Loading branch information
Hansimov committed Dec 9, 2023
1 parent bb9b91b commit 10efc14
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions conversations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .conversation_style import ConversationStyle
from .conversation_connector import ConversationConnector
from .conversation_creator import ConversationCreator
from .conversation_session import ConversationSession
Expand Down
9 changes: 7 additions & 2 deletions conversations/conversation_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
MessageParser,
OpenaiStreamOutputer,
)
from conversations import ConversationStyle
from utils.logger import logger
from utils.enver import enver

Expand All @@ -26,14 +27,18 @@ class ConversationConnector:

def __init__(
self,
conversation_style: str = "precise",
conversation_style: ConversationStyle = "precise",
sec_access_token: str = "",
client_id: str = "",
conversation_id: str = "",
invocation_id: int = 0,
cookies={},
):
self.conversation_style = conversation_style
if conversation_style.lower() not in ConversationStyle.__members__:
self.conversation_style = ConversationStyle.PRECISE.value
else:
self.conversation_style = conversation_style.lower()

self.sec_access_token = sec_access_token
self.client_id = client_id
self.conversation_id = conversation_id
Expand Down
10 changes: 10 additions & 0 deletions conversations/conversation_style.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from enum import Enum


class ConversationStyle(Enum):
PRECISE: str = "precise"
BALANCED: str = "balanced"
CREATIVE: str = "creative"
PRECISE_OFFLINE: str = "precise-offline"
BALANCED_OFFLINE: str = "balanced-offline"
CREATIVE_OFFLINE: str = "creative-offline"
3 changes: 2 additions & 1 deletion networks/chathub_request_payload_constructor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import random
import uuid
from conversations import ConversationStyle


class ChathubRequestPayloadConstructor:
Expand All @@ -9,7 +10,7 @@ def __init__(
client_id: str,
conversation_id: str,
invocation_id: int = 0,
conversation_style: str = "precise",
conversation_style: ConversationStyle = "precise",
):
self.prompt = prompt
self.client_id = client_id
Expand Down

0 comments on commit 10efc14

Please sign in to comment.