Update llm/utils/chat.py
Browse files- llm/utils/chat.py +1 -18
llm/utils/chat.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import time
|
2 |
|
3 |
from llm.apimodels.gemini_model import Gemini
|
4 |
-
from llm.apimodels.hf_model import HF_Mistaril, HF_TinyLlama, HF_SmolLM135, HF_SmolLM360, HF_SmolLM, HF_Gemma2, HF_Qwen2
|
5 |
|
6 |
from typing import Optional, Any
|
7 |
|
@@ -91,18 +91,6 @@ class Conversation:
|
|
91 |
except Exception as e:
|
92 |
print(f"Error during conversation chain in get_conversation function: {e}")
|
93 |
|
94 |
-
def _libertarian_conversation(self, prompt) -> Optional[str]:
|
95 |
-
conversation = ConversationChain(llm=FreeThinker3B().execution(), memory=memory, return_final_only=True)
|
96 |
-
|
97 |
-
try:
|
98 |
-
response = conversation.predict(input=prompt)
|
99 |
-
print(f"response: {response}")
|
100 |
-
result = prettify(raw_text=response)
|
101 |
-
return result
|
102 |
-
except Exception as e:
|
103 |
-
print(f"Error during prediction with conversation in has_failed function: {e}")
|
104 |
-
return None
|
105 |
-
|
106 |
def chatting(self, prompt: str, is_own_model: bool) -> str:
|
107 |
"""
|
108 |
Carries out the conversation with the user, handling errors and delays.
|
@@ -117,11 +105,6 @@ class Conversation:
|
|
117 |
if prompt is None or prompt == "":
|
118 |
raise Exception(f"Prompt must be string not None or empty string: {prompt}")
|
119 |
|
120 |
-
if is_own_model:
|
121 |
-
result = self._libertarian_conversation(prompt)
|
122 |
-
|
123 |
-
return result
|
124 |
-
|
125 |
while self.current_model_index < len(self.model_classes):
|
126 |
conversation = self._get_conversation()
|
127 |
|
|
|
1 |
import time
|
2 |
|
3 |
from llm.apimodels.gemini_model import Gemini
|
4 |
+
from llm.apimodels.hf_model import HF_Mistaril, HF_TinyLlama, HF_SmolLM135, HF_SmolLM360, HF_SmolLM, HF_Gemma2, HF_Qwen2
|
5 |
|
6 |
from typing import Optional, Any
|
7 |
|
|
|
91 |
except Exception as e:
|
92 |
print(f"Error during conversation chain in get_conversation function: {e}")
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
def chatting(self, prompt: str, is_own_model: bool) -> str:
|
95 |
"""
|
96 |
Carries out the conversation with the user, handling errors and delays.
|
|
|
105 |
if prompt is None or prompt == "":
|
106 |
raise Exception(f"Prompt must be string not None or empty string: {prompt}")
|
107 |
|
|
|
|
|
|
|
|
|
|
|
108 |
while self.current_model_index < len(self.model_classes):
|
109 |
conversation = self._get_conversation()
|
110 |
|