chat-console 0.4.2__py3-none-any.whl → 0.4.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- app/__init__.py +1 -1
- app/api/ollama.py +1 -1
- app/main.py +21 -10
- app/utils.py +22 -3
- {chat_console-0.4.2.dist-info → chat_console-0.4.3.dist-info}/METADATA +1 -1
- {chat_console-0.4.2.dist-info → chat_console-0.4.3.dist-info}/RECORD +10 -10
- {chat_console-0.4.2.dist-info → chat_console-0.4.3.dist-info}/WHEEL +1 -1
- {chat_console-0.4.2.dist-info → chat_console-0.4.3.dist-info}/entry_points.txt +0 -0
- {chat_console-0.4.2.dist-info → chat_console-0.4.3.dist-info}/licenses/LICENSE +0 -0
- {chat_console-0.4.2.dist-info → chat_console-0.4.3.dist-info}/top_level.txt +0 -0
app/__init__.py
CHANGED
app/api/ollama.py
CHANGED
@@ -165,7 +165,7 @@ class OllamaClient(BaseModelClient):
|
|
165
165
|
user_msg = next((msg for msg in messages if msg.get("role") == "user"), None)
|
166
166
|
if user_msg and "content" in user_msg:
|
167
167
|
# Create a direct prompt
|
168
|
-
prompt = "
|
168
|
+
prompt = "You must generate a short, descriptive title (maximum 40 characters) for this conversation. ONLY output the title with no additional text, no quotes, and no explanation. Do not start with phrases like 'Here's a title' or 'Title:'. RESPOND ONLY WITH THE TITLE TEXT for the following message:\n\n" + user_msg["content"]
|
169
169
|
debug_log(f"Created title generation prompt: {prompt[:100]}...")
|
170
170
|
return prompt
|
171
171
|
else:
|
app/main.py
CHANGED
@@ -708,21 +708,32 @@ class SimpleChatApp(App): # Keep SimpleChatApp class definition
|
|
708
708
|
if client_type == OllamaClient:
|
709
709
|
debug_log(f"Title generation with Ollama model detected: {selected_model_resolved}")
|
710
710
|
|
711
|
-
#
|
711
|
+
# Always try to use smalllm2:135m first, then fall back to other small models
|
712
712
|
try:
|
713
|
-
# Check if we have
|
713
|
+
# Check if we have smalllm2:135m or other smaller models available
|
714
714
|
ollama_client = await OllamaClient.create()
|
715
715
|
available_models = await ollama_client.get_available_models()
|
716
|
-
small_model_options = ["gemma:2b", "phi3:mini", "llama3:8b", "orca-mini:3b", "phi2"]
|
717
716
|
|
717
|
+
# Use smalllm2:135m if available (extremely small and fast)
|
718
|
+
preferred_model = "smalllm2:135m"
|
719
|
+
fallback_models = ["tinyllama", "gemma:2b", "phi3:mini", "llama3:8b", "orca-mini:3b", "phi2"]
|
720
|
+
|
721
|
+
# First check for our preferred smallest model
|
718
722
|
small_model_found = False
|
719
|
-
for
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
723
|
+
if any(model["id"] == preferred_model for model in available_models):
|
724
|
+
debug_log(f"Found optimal small model for title generation: {preferred_model}")
|
725
|
+
title_model = preferred_model
|
726
|
+
small_model_found = True
|
727
|
+
|
728
|
+
# If not found, try fallbacks in order
|
729
|
+
if not small_model_found:
|
730
|
+
for model_name in fallback_models:
|
731
|
+
if any(model["id"] == model_name for model in available_models):
|
732
|
+
debug_log(f"Found alternative small model for title generation: {model_name}")
|
733
|
+
title_model = model_name
|
734
|
+
small_model_found = True
|
735
|
+
break
|
736
|
+
|
726
737
|
if not small_model_found:
|
727
738
|
# Use the current model if no smaller models found
|
728
739
|
title_model = selected_model_resolved
|
app/utils.py
CHANGED
@@ -66,7 +66,7 @@ async def generate_conversation_title(message: str, model: str, client: Any) ->
|
|
66
66
|
title_prompt = [
|
67
67
|
{
|
68
68
|
"role": "system",
|
69
|
-
"content": "Generate a brief, descriptive title (maximum 40 characters) for a conversation that starts with the following message.
|
69
|
+
"content": "Generate a brief, descriptive title (maximum 40 characters) for a conversation that starts with the following message. ONLY output the title text. DO NOT include phrases like 'Sure, here's a title' or any additional formatting, explanation, or quotes."
|
70
70
|
},
|
71
71
|
{
|
72
72
|
"role": "user",
|
@@ -96,12 +96,31 @@ async def generate_conversation_title(message: str, model: str, client: Any) ->
|
|
96
96
|
max_tokens=60
|
97
97
|
)
|
98
98
|
|
99
|
-
# Sanitize the title
|
99
|
+
# Sanitize the title - remove quotes, extra spaces and unwanted prefixes
|
100
100
|
title = title.strip().strip('"\'').strip()
|
101
|
+
|
102
|
+
# Remove common LLM prefixes like "Title:", "Sure, here's a title:", etc.
|
103
|
+
prefixes_to_remove = [
|
104
|
+
"title:", "here's a title:", "here is a title:",
|
105
|
+
"a title for this conversation:", "sure,", "certainly,",
|
106
|
+
"the title is:", "suggested title:"
|
107
|
+
]
|
108
|
+
|
109
|
+
# Case-insensitive prefix removal
|
110
|
+
title_lower = title.lower()
|
111
|
+
for prefix in prefixes_to_remove:
|
112
|
+
if title_lower.startswith(prefix):
|
113
|
+
title = title[len(prefix):].strip()
|
114
|
+
title_lower = title.lower() # Update lowercase version after removal
|
115
|
+
|
116
|
+
# Remove any remaining quotes
|
117
|
+
title = title.strip('"\'').strip()
|
118
|
+
|
119
|
+
# Enforce length limit
|
101
120
|
if len(title) > 40:
|
102
121
|
title = title[:37] + "..."
|
103
122
|
|
104
|
-
debug_log(f"Generated title: {title}")
|
123
|
+
debug_log(f"Generated title (after sanitization): {title}")
|
105
124
|
return title
|
106
125
|
|
107
126
|
except Exception as e:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: chat-console
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.3
|
4
4
|
Summary: A command-line interface for chatting with LLMs, storing chats and (future) rag interactions
|
5
5
|
Home-page: https://github.com/wazacraftrfid/chat-console
|
6
6
|
Author: Johnathan Greenaway
|
@@ -1,13 +1,13 @@
|
|
1
|
-
app/__init__.py,sha256=
|
1
|
+
app/__init__.py,sha256=T3d41tTB1sDy6ix7bg43dp4zvNqqJku0JGlwMGKFGHo,130
|
2
2
|
app/config.py,sha256=F-0hO3NT5kRJxZelGLxaeUmnwx8i0LPHzYtNftL6CwM,8468
|
3
3
|
app/database.py,sha256=nt8CVuDpy6zw8mOYqDcfUmNw611t7Ln7pz22M0b6-MI,9967
|
4
|
-
app/main.py,sha256=
|
4
|
+
app/main.py,sha256=8UU9GcPJINu_TmbKKKFBZXIgLHNDf6vabyupKjj3Img,86297
|
5
5
|
app/models.py,sha256=4-y9Lytay2exWPFi0FDlVeRL3K2-I7E-jBqNzTfokqY,2644
|
6
|
-
app/utils.py,sha256
|
6
|
+
app/utils.py,sha256=-L38KGP8TlVl5vtZl5QgTiEAdhLcDsIXm7e62nnXgP8,41765
|
7
7
|
app/api/__init__.py,sha256=A8UL84ldYlv8l7O-yKzraVFcfww86SgWfpl4p7R03-w,62
|
8
8
|
app/api/anthropic.py,sha256=uInwNvGLJ_iPUs4BjdwaqXTU6NfmK1SzX7498Pt44fI,10667
|
9
9
|
app/api/base.py,sha256=valBWV5So76r8tjrgU5-sLfY73WaViTrszdCy8Rimjo,10314
|
10
|
-
app/api/ollama.py,sha256=
|
10
|
+
app/api/ollama.py,sha256=364PcXoPLJq9jLMF-HhPyQvaBp87U6FzNHDWx4g_Cvc,76925
|
11
11
|
app/api/openai.py,sha256=XuHJHpD7tN_ZHLkRpNUcL1VxTtsXOVk1hDPXX8JnBxQ,15322
|
12
12
|
app/ui/__init__.py,sha256=RndfbQ1Tv47qdSiuQzvWP96lPS547SDaGE-BgOtiP_w,55
|
13
13
|
app/ui/chat_interface.py,sha256=oSDZi0Jgj_L8WnBh1RuJpIeIcN-RQ38CNejwsXiWTVg,18267
|
@@ -16,9 +16,9 @@ app/ui/model_browser.py,sha256=pdblLVkdyVF0_Bo02bqbErGAtieyH-y6IfhMOPEqIso,71124
|
|
16
16
|
app/ui/model_selector.py,sha256=2G0TOXfcNodrXZOhLeaJJ2iG3Nck4c_NN1AvUAmaF3M,19172
|
17
17
|
app/ui/search.py,sha256=b-m14kG3ovqW1-i0qDQ8KnAqFJbi5b1FLM9dOnbTyIs,9763
|
18
18
|
app/ui/styles.py,sha256=04AhPuLrOd2yenfRySFRestPeuTPeMLzhmMB67NdGvw,5615
|
19
|
-
chat_console-0.4.
|
20
|
-
chat_console-0.4.
|
21
|
-
chat_console-0.4.
|
22
|
-
chat_console-0.4.
|
23
|
-
chat_console-0.4.
|
24
|
-
chat_console-0.4.
|
19
|
+
chat_console-0.4.3.dist-info/licenses/LICENSE,sha256=srHZ3fvcAuZY1LHxE7P6XWju2njRCHyK6h_ftEbzxSE,1057
|
20
|
+
chat_console-0.4.3.dist-info/METADATA,sha256=y01SPyzTsYIyCbc5gEpCx6dlQ_ROG16T1gTZPOScia8,3810
|
21
|
+
chat_console-0.4.3.dist-info/WHEEL,sha256=GHB6lJx2juba1wDgXDNlMTyM13ckjBMKf-OnwgKOCtA,91
|
22
|
+
chat_console-0.4.3.dist-info/entry_points.txt,sha256=kkVdEc22U9PAi2AeruoKklfkng_a_aHAP6VRVwrAD7c,67
|
23
|
+
chat_console-0.4.3.dist-info/top_level.txt,sha256=io9g7LCbfmTG1SFKgEOGXmCFB9uMP2H5lerm0HiHWQE,4
|
24
|
+
chat_console-0.4.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|