Update ChatCraftCommand::isCommand() criteria for slash function #567
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #500.
![image](https://private-user-images.githubusercontent.com/78163326/319851041-237c73ba-7445-4d09-a469-3e8a12bf360d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NTM0NDAsIm5iZiI6MTczOTg1MzE0MCwicGF0aCI6Ii83ODE2MzMyNi8zMTk4NTEwNDEtMjM3YzczYmEtNzQ0NS00ZDA5LWE0NjktM2U4YTEyYmYzNjBkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA0MzIyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlkYTFkMGM4ODRkMWJmYzFhOGM0YjUyMzJkNzhiZDMwNjdkMWY4OWQ3YTEwYTllODg3MjE4NzUzYWZkMjc2MmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ja0M0-OZOCf1NxwhQ7Q_23l_AICXLpnn7yiAb6Dt1Hk)
The issue encountered above is due to ChatBase interpreting a non-slash command (in this case, a filepath in an error message) as a slash command:
isCommand()
currently treats every prompt starting with a forward slash as a potential slash command, then either tries to execute the slash command or parse the invalid command to notify the user (i.e [invalid command] is not a valid command!).This PR reuses the parseCommand() Regex in isCommand() so things like filepaths aren't treated as a potential slash command:
chatcraft.org/src/lib/ChatCraftCommand.ts
Lines 10 to 12 in f7b2803
How to Test
Potential Issue
I think this is a step in the right direction, but the Regex in the new isCommand() is not perfect.
![image](https://private-user-images.githubusercontent.com/78163326/319852890-e87379ee-b57d-41b7-a382-c8be1b364a9c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NTM0NDAsIm5iZiI6MTczOTg1MzE0MCwicGF0aCI6Ii83ODE2MzMyNi8zMTk4NTI4OTAtZTg3Mzc5ZWUtYjU3ZC00MWI3LWEzODItYzhiZTFiMzY0YTljLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA0MzIyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE4YjI3MjkzZGI5NzY0ZDllNmJkM2YzMjU2NzFiZWQzY2MwNjdmZTk3NDBlZGUyOGI4MTI4Mzc1NTM1NDgxZTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.NP5QXAEhHyy3GKZ-P7WnZz3-KptlhG805mMspB7iOa4)
If the user enters a slash command containing a non-word (special) character, it will be sent to the LLM: