File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import { FindSimilarCommand } from "./commands/FindSimilar";
2323import { HelpCommand } from "./commands/HelpCommand" ;
2424import { ImportanceCommand } from "./commands/ImportanceCommand" ;
2525import { ImproveCommand } from "./commands/ImproveCommand" ;
26+ import { TestCommand } from "./commands/TestLLM" ;
2627import { TranslateCommand } from "./commands/TranslateCommand" ;
2728import { WhyUsedCommand } from "./commands/WhyUsedCommand" ;
2829import { EstablishRelationsEndpoint } from "./endpoints/establishRelations" ;
@@ -63,6 +64,8 @@ export class RocketChatterApp extends App {
6364 configuration . slashCommands . provideSlashCommand ( new TranslateCommand ( ) ) ;
6465 configuration . slashCommands . provideSlashCommand ( new WhyUsedCommand ( ) ) ;
6566
67+ configuration . slashCommands . provideSlashCommand ( new TestCommand ( ) ) ;
68+
6669 await configuration . api . provideApi ( {
6770 visibility : ApiVisibility . PUBLIC ,
6871 security : ApiSecurity . UNSECURE ,
Original file line number Diff line number Diff line change 1+ import {
2+ IHttp ,
3+ IModify ,
4+ IRead ,
5+ } from "@rocket.chat/apps-engine/definition/accessors" ;
6+ import {
7+ ISlashCommand ,
8+ SlashCommandContext ,
9+ } from "@rocket.chat/apps-engine/definition/slashcommands" ;
10+
11+ import { Llama3_70B } from "../core/llm/llama3_70B" ;
12+ import { Prompt } from "../core/prompt/prompt" ;
13+ import { handleCommandResponse } from "../utils/handleCommandResponse" ;
14+
15+ export class TestCommand implements ISlashCommand {
16+ public command = "rcc-test" ;
17+ public i18nParamsExample = "" ;
18+ public i18nDescription = "" ;
19+ public providesPreview = false ;
20+
21+ private async process ( http : IHttp , query : string ) : Promise < string | null > {
22+ const llm = new Llama3_70B ( http ) ;
23+
24+ const prompt = new Prompt ( ) ;
25+ prompt . pushUser ( query ) ;
26+
27+ const answer = await llm . ask ( prompt ) ;
28+ if ( ! answer ) return null ;
29+
30+ return answer ;
31+ }
32+
33+ public async executor (
34+ context : SlashCommandContext ,
35+ read : IRead ,
36+ modify : IModify ,
37+ http : IHttp
38+ ) : Promise < void > {
39+ const query = context . getArguments ( ) . join ( " " ) ;
40+ if ( ! query ) return ;
41+
42+ const sendEditedMessage = await handleCommandResponse (
43+ query ,
44+ context . getSender ( ) ,
45+ context . getRoom ( ) ,
46+ modify ,
47+ this . command
48+ ) ;
49+
50+ const res = await this . process ( http , query ) ;
51+ if ( res ) {
52+ await sendEditedMessage ( res ) ;
53+ } else {
54+ await sendEditedMessage ( "❌ Unable to process your query" ) ;
55+ }
56+ }
57+ }
You can’t perform that action at this time.
0 commit comments