Skip to content

Commit

Permalink
Merge pull request #91 from arshad-yaseen/website
Browse files Browse the repository at this point in the history
Monacopilot Website
  • Loading branch information
arshad-yaseen authored Dec 22, 2024
2 parents 9bae559 + 0c672a2 commit b701bc5
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 32 deletions.
2 changes: 2 additions & 0 deletions src/constants/completion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const DEFAULT_COMPLETION_TEMPERATURE = 0.1 as const;
export const DEFAULT_COMPLETION_MAX_TOKENS = 500 as const;
2 changes: 0 additions & 2 deletions src/constants/copilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ export const COPILOT_PROVIDER_ENDPOINT_MAP: Record<CopilotProvider, string> = {
anthropic: 'https://api.anthropic.com/v1/messages',
google: 'https://generativelanguage.googleapis.com/v1beta/models',
} as const;

export const DEFAULT_COPILOT_TEMPERATURE = 0.1 as const;
7 changes: 0 additions & 7 deletions src/constants/provider/anthropic.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/helpers/completion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import {
getCharAfterCursor,
getTextAfterCursor,
getTextAfterCursorInLine,
getTextBeforeCursor,
HTTP,
keepNLines,
Expand Down Expand Up @@ -135,7 +134,7 @@ const determineCompletionMode = (
mdl: EditorModel,
): CompletionMode => {
const charAfterCursor = getCharAfterCursor(pos, mdl);
const textAfterCursor = getTextAfterCursorInLine(pos, mdl);
const textAfterCursor = getTextAfterCursor(pos, mdl);

if (charAfterCursor) {
return 'insert';
Expand Down
23 changes: 14 additions & 9 deletions src/helpers/provider.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {COPILOT_MODEL_IDS, COPILOT_PROVIDER_ENDPOINT_MAP} from '../constants';
import {
COPILOT_MODEL_IDS,
COPILOT_PROVIDER_ENDPOINT_MAP,
DEFAULT_COPILOT_TEMPERATURE,
} from '../constants';
import {MAX_TOKENS_BY_ANTHROPIC_MODEL} from '../constants/provider/anthropic';
DEFAULT_COMPLETION_MAX_TOKENS,
DEFAULT_COMPLETION_TEMPERATURE,
} from '../constants/completion';
import {
ChatCompletion,
ChatCompletionCreateParams,
Expand All @@ -20,7 +19,8 @@ const openaiHandler: ProviderHandler<'openai'> = {

return {
model: getModelId(model),
...(!isO1Model && {temperature: DEFAULT_COPILOT_TEMPERATURE}),
...(!isO1Model && {temperature: DEFAULT_COMPLETION_TEMPERATURE}),
max_completion_tokens: DEFAULT_COMPLETION_MAX_TOKENS,
messages: [
{role: 'system' as const, content: prompt.system},
{role: 'user' as const, content: prompt.user},
Expand All @@ -47,7 +47,8 @@ const groqHandler: ProviderHandler<'groq'> = {

createRequestBody: (model, prompt) => ({
model: getModelId(model),
temperature: DEFAULT_COPILOT_TEMPERATURE,
temperature: DEFAULT_COMPLETION_TEMPERATURE,
max_tokens: DEFAULT_COMPLETION_MAX_TOKENS,
messages: [
{role: 'system' as const, content: prompt.system},
{role: 'user' as const, content: prompt.user},
Expand All @@ -72,10 +73,10 @@ const anthropicHandler: ProviderHandler<'anthropic'> = {

createRequestBody: (model, prompt) => ({
model: getModelId(model),
temperature: DEFAULT_COPILOT_TEMPERATURE,
temperature: DEFAULT_COMPLETION_TEMPERATURE,
system: prompt.system,
messages: [{role: 'user' as const, content: prompt.user}],
max_tokens: MAX_TOKENS_BY_ANTHROPIC_MODEL[model],
max_tokens: DEFAULT_COMPLETION_MAX_TOKENS,
}),

createHeaders: apiKey => ({
Expand Down Expand Up @@ -113,6 +114,10 @@ const googleHandler: ProviderHandler<'google'> = {
system_instruction: {
parts: {text: prompt.system},
},
generationConfig: {
temperature: DEFAULT_COMPLETION_TEMPERATURE,
maxOutputTokens: DEFAULT_COMPLETION_MAX_TOKENS,
},
contents: [
{
parts: {text: prompt.user},
Expand Down
4 changes: 2 additions & 2 deletions tests/completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {CompletionMetadata, Copilot} from '../src';
import {
COPILOT_MODEL_IDS,
COPILOT_PROVIDER_ENDPOINT_MAP,
DEFAULT_COPILOT_TEMPERATURE,
} from '../src/constants';
import {DEFAULT_COMPLETION_TEMPERATURE} from '../src/constants/completion';
import {HTTP} from '../src/utils';
import {
MOCK_COMPLETION_CONTENT,
Expand Down Expand Up @@ -54,7 +54,7 @@ describe('Completion', () => {
{role: 'user', content: expect.any(String)},
]),
system: expect.any(String),
temperature: DEFAULT_COPILOT_TEMPERATURE,
temperature: DEFAULT_COMPLETION_TEMPERATURE,
}),
expect.objectContaining({
headers: expect.any(Object),
Expand Down
31 changes: 22 additions & 9 deletions tests/ui/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,28 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<body
style={{
minHeight: '100vh',
width: '100%',
display: 'flex',
justifyContent: 'center',
}}>
{children}
</body>
<head>
<style>{`
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
font-size: 16px;
-webkit-text-size-adjust: 100%;
}
body {
min-height: 100vh;
width: 100%;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
`}</style>
</head>
<body>{children}</body>
</html>
);
}
2 changes: 1 addition & 1 deletion tests/ui/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ export default function Home() {
}}
/>
);
}
}

0 comments on commit b701bc5

Please sign in to comment.