-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add wpm config, --as-sys, --bump-sys
- Loading branch information
Showing
3 changed files
with
94 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,50 @@ | ||
import { ChatCompletionRequest, getChatResponse_withRetries } from "./ai.ts"; | ||
import { getChatResponse_withRetries } from "./ai.ts"; | ||
import { ChatCompletionRequest } from "./ai-types.ts"; | ||
|
||
export const genDescriptiveNameForChat = async (req: ChatCompletionRequest): Promise<string | null> => { | ||
export const genDescriptiveNameForChat = async ( | ||
req: ChatCompletionRequest, | ||
): Promise<string | null> => { | ||
// This function generates a descriptive name from a chat for your history | ||
// e.g. if you're talking about which car to buy, it will generate a name like "car-buying" | ||
|
||
const newReq = { | ||
...req, messages: [ | ||
...req.messages.filter(m => m.role !== 'system'), | ||
...req, | ||
messages: [ | ||
...req.messages.filter((m) => m.role !== "system"), | ||
{ | ||
role: 'system' as const, | ||
content: `[IMPORTANT INSTRUCTION] Response ONLY with a short, descriptive, hyphenated name that describes the above conversation, in the format: my-chat-name` | ||
} | ||
role: "system" as const, | ||
content: | ||
`[IMPORTANT INSTRUCTION] Response ONLY with a short, descriptive, hyphenated name that describes the above conversation, in the format: my-chat-name`, | ||
}, | ||
], | ||
model: 'gpt-3.5-turbo' // use turbo as its cheaper/faster | ||
} | ||
const chatName = await getChatResponse_withRetries(newReq) | ||
return chatName | ||
} | ||
model: "gpt-3.5-turbo", // use turbo as its cheaper/faster | ||
}; | ||
const chatName = await getChatResponse_withRetries(newReq); | ||
return chatName; | ||
}; | ||
|
||
export const setExecutableCmdParamsForChat = (req: ChatCompletionRequest): ChatCompletionRequest => { | ||
req.messages = req.messages.filter(m => m.role !== 'system') // other system messages tend to conflict | ||
export const setExecutableCmdParamsForChat = ( | ||
req: ChatCompletionRequest, | ||
): ChatCompletionRequest => { | ||
req.messages = req.messages.filter((m) => m.role !== "system"); // other system messages tend to conflict | ||
req.messages.push({ | ||
role: 'system', | ||
content: `[IMPORTANT INSTRUCTION] Reply ONLY with an executable shell command(s) for the given prompt and no other text. (OS: ${Deno.build.os}} Shell: ${Deno.env.get('SHELL') ?? 'unknown'})` | ||
}) | ||
return req | ||
} | ||
role: "system", | ||
content: | ||
`[IMPORTANT INSTRUCTION] Reply ONLY with an executable shell command(s) for the given prompt and no other text. (OS: ${Deno.build.os}} Shell: ${ | ||
Deno.env.get("SHELL") ?? "unknown" | ||
})`, | ||
}); | ||
return req; | ||
}; | ||
|
||
export const setCodeCmdParamsForChat = (req: ChatCompletionRequest): ChatCompletionRequest => { | ||
req.messages = req.messages.filter(m => m.role !== 'system') // other system messages tend to conflict | ||
export const setCodeCmdParamsForChat = ( | ||
req: ChatCompletionRequest, | ||
): ChatCompletionRequest => { | ||
req.messages = req.messages.filter((m) => m.role !== "system"); // other system messages tend to conflict | ||
req.messages.push({ | ||
role: 'system', | ||
content: `[IMPORTANT INSTRUCTION] Reply ONLY with code (and comments) for the given prompt and no other text or chat.` | ||
}) | ||
return req | ||
} | ||
role: "system", | ||
content: | ||
`[IMPORTANT INSTRUCTION] Reply ONLY with code (and comments) for the given prompt and no other text or chat.`, | ||
}); | ||
return req; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters