Spaces:
Paused
Paused
:gem: [Feature] ConversationStyle: Use Enum for more intuitive, and set default styles
Browse files
conversations/__init__.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
from .conversation_connector import ConversationConnector
|
2 |
from .conversation_creator import ConversationCreator
|
3 |
from .conversation_session import ConversationSession
|
|
|
1 |
+
from .conversation_style import ConversationStyle
|
2 |
from .conversation_connector import ConversationConnector
|
3 |
from .conversation_creator import ConversationCreator
|
4 |
from .conversation_session import ConversationSession
|
conversations/conversation_connector.py
CHANGED
@@ -8,6 +8,7 @@ from networks import (
|
|
8 |
MessageParser,
|
9 |
OpenaiStreamOutputer,
|
10 |
)
|
|
|
11 |
from utils.logger import logger
|
12 |
from utils.enver import enver
|
13 |
|
@@ -26,14 +27,18 @@ class ConversationConnector:
|
|
26 |
|
27 |
def __init__(
|
28 |
self,
|
29 |
-
conversation_style:
|
30 |
sec_access_token: str = "",
|
31 |
client_id: str = "",
|
32 |
conversation_id: str = "",
|
33 |
invocation_id: int = 0,
|
34 |
cookies={},
|
35 |
):
|
36 |
-
|
|
|
|
|
|
|
|
|
37 |
self.sec_access_token = sec_access_token
|
38 |
self.client_id = client_id
|
39 |
self.conversation_id = conversation_id
|
|
|
8 |
MessageParser,
|
9 |
OpenaiStreamOutputer,
|
10 |
)
|
11 |
+
from conversations import ConversationStyle
|
12 |
from utils.logger import logger
|
13 |
from utils.enver import enver
|
14 |
|
|
|
27 |
|
28 |
def __init__(
|
29 |
self,
|
30 |
+
conversation_style: ConversationStyle = "precise",
|
31 |
sec_access_token: str = "",
|
32 |
client_id: str = "",
|
33 |
conversation_id: str = "",
|
34 |
invocation_id: int = 0,
|
35 |
cookies={},
|
36 |
):
|
37 |
+
if conversation_style.lower() not in ConversationStyle.__members__:
|
38 |
+
self.conversation_style = ConversationStyle.PRECISE.value
|
39 |
+
else:
|
40 |
+
self.conversation_style = conversation_style.lower()
|
41 |
+
|
42 |
self.sec_access_token = sec_access_token
|
43 |
self.client_id = client_id
|
44 |
self.conversation_id = conversation_id
|
conversations/conversation_style.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from enum import Enum
|
2 |
+
|
3 |
+
|
4 |
+
class ConversationStyle(Enum):
|
5 |
+
PRECISE: str = "precise"
|
6 |
+
BALANCED: str = "balanced"
|
7 |
+
CREATIVE: str = "creative"
|
8 |
+
PRECISE_OFFLINE: str = "precise-offline"
|
9 |
+
BALANCED_OFFLINE: str = "balanced-offline"
|
10 |
+
CREATIVE_OFFLINE: str = "creative-offline"
|
networks/chathub_request_payload_constructor.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import random
|
2 |
import uuid
|
|
|
3 |
|
4 |
|
5 |
class ChathubRequestPayloadConstructor:
|
@@ -9,7 +10,7 @@ class ChathubRequestPayloadConstructor:
|
|
9 |
client_id: str,
|
10 |
conversation_id: str,
|
11 |
invocation_id: int = 0,
|
12 |
-
conversation_style:
|
13 |
):
|
14 |
self.prompt = prompt
|
15 |
self.client_id = client_id
|
|
|
1 |
import random
|
2 |
import uuid
|
3 |
+
from conversations import ConversationStyle
|
4 |
|
5 |
|
6 |
class ChathubRequestPayloadConstructor:
|
|
|
10 |
client_id: str,
|
11 |
conversation_id: str,
|
12 |
invocation_id: int = 0,
|
13 |
+
conversation_style: ConversationStyle = "precise",
|
14 |
):
|
15 |
self.prompt = prompt
|
16 |
self.client_id = client_id
|