Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add gemma-7b #66

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions openaoe/frontend/dist/assets/index-321b9bf8.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion openaoe/frontend/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}
}
</style>
<script type="module" crossorigin src="./assets/index-da64670e.js"></script>
<script type="module" crossorigin src="./assets/index-321b9bf8.js"></script>
<link rel="modulepreload" crossorigin href="./assets/vendor-bad6aacb.js">
<link rel="stylesheet" href="./assets/index-d5c224e8.css">
</head>
Expand Down
11 changes: 11 additions & 0 deletions openaoe/frontend/src/config/api-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const claude = {
model: 'claude-1',
max_tokens: 5000
};

const baidu = {
messages: [
{
Expand Down Expand Up @@ -93,6 +94,12 @@ const mistral = {
stream: true
};

const gemma = {
model: 'gemma',
messages: [],
stream: true
};

const API_PREFIX = '';

const API = new Map();
Expand Down Expand Up @@ -125,5 +132,9 @@ API.set('mistral', {
url: `${API_PREFIX}/v1/mistral/v1/mistral/chat`,
...mistral
});
API.set('gemma', {
url: `${API_PREFIX}/v1/google/v1/gemma/chat`,
...gemma
});

export default API;
39 changes: 22 additions & 17 deletions openaoe/frontend/src/services/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const getPayload = (provider: string, model: string, prompt: string, mess
const payload = { ...API.get(provider) || API.get(DEFAULT_PROVIDER) };
delete payload.url;
payload.model = model;
if (['openai', 'internlm', 'gpt-4', 'mistral'].includes(provider)) {
if (['openai', 'internlm', 'gpt-4', 'mistral', 'gemma'].includes(provider)) {
payload.prompt = prompt;
payload.messages = messages;
}
Expand All @@ -37,23 +37,28 @@ export const getPayload = (provider: string, model: string, prompt: string, mess
});
}
if (provider === 'google') {
// TODO: Messages must alternate between authors.
const defaultMessage = {
content: 'Hi! How can I help you today?',
author: '1'
};
const formatMessage = messages.map((item) => {
return {
content: item.text,
author: item.sender_type === 'user' ? '0' : '1',
if (['gemma-7b', 'gemma-2b'].includes(model)) {
payload.prompt = prompt;
payload.messages = messages;
} else {
// TODO: Messages must alternate between authors.
const defaultMessage = {
content: 'Hi! How can I help you today?',
author: '1'
};
});
formatMessage.push({
content: prompt,
author: '0',
});
formatMessage.unshift(defaultMessage);
payload.prompt.messages = formatMessage;
const formatMessage = messages.map((item) => {
return {
content: item.text,
author: item.sender_type === 'user' ? '0' : '1',
};
});
formatMessage.push({
content: prompt,
author: '0',
});
formatMessage.unshift(defaultMessage);
payload.prompt.messages = formatMessage;
}
}
if (provider === 'baidu' || provider === 'claude') {
const formatMessage = messages.map((item) => {
Expand Down
Loading