Skip to content

Commit

Permalink
Model avatar (#119)
Browse files Browse the repository at this point in the history
* update
  • Loading branch information
swuecho authored Apr 16, 2023
1 parent c887753 commit a609c36
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 67 deletions.
21 changes: 21 additions & 0 deletions web/src/views/chat/components/Avatar/MessageAvatar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script lang="ts" setup>
import { NAvatar } from 'naive-ui'
import ModelAvatar from './ModelAvatar.vue'
import defaultAvatar from '@/assets/avatar.jpg'
interface Props {
inversion?: boolean
model?: string
}
defineProps<Props>()
</script>

<template>
<template v-if="inversion">
<NAvatar round :src="defaultAvatar" />
</template>
<span v-else class="text-[28px] dark:text-white">
<ModelAvatar :model="model" />
</span>
</template>
28 changes: 28 additions & 0 deletions web/src/views/chat/components/Avatar/ModelAvatar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script setup lang="ts">
import { SvgIcon } from '@/components/common'
// polished version of question:
// Create a Vue 3 <script setup lang="ts"> single file component with a model prop
defineProps({
model: String,
})
</script>

<template>
<div>
<template v-if="model === 'claude-v1'">
<SvgIcon icon="eos-icons:ai" color="brown" />
</template>
<template v-if="model === 'claude-instant-v1'">
<SvgIcon icon="simple-icons:fastapi" color="brown" />
</template>
<template v-if="model?.startsWith('gpt')">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" aria-hidden="true" width="1em" height="1em">
<path
d="M29.71,13.09A8.09,8.09,0,0,0,20.34,2.68a8.08,8.08,0,0,0-13.7,2.9A8.08,8.08,0,0,0,2.3,18.9,8,8,0,0,0,3,25.45a8.08,8.08,0,0,0,8.69,3.87,8,8,0,0,0,6,2.68,8.09,8.09,0,0,0,7.7-5.61,8,8,0,0,0,5.33-3.86A8.09,8.09,0,0,0,29.71,13.09Zm-12,16.82a6,6,0,0,1-3.84-1.39l.19-.11,6.37-3.68a1,1,0,0,0,.53-.91v-9l2.69,1.56a.08.08,0,0,1,.05.07v7.44A6,6,0,0,1,17.68,29.91ZM4.8,24.41a6,6,0,0,1-.71-4l.19.11,6.37,3.68a1,1,0,0,0,1,0l7.79-4.49V22.8a.09.09,0,0,1,0,.08L13,26.6A6,6,0,0,1,4.8,24.41ZM3.12,10.53A6,6,0,0,1,6.28,7.9v7.57a1,1,0,0,0,.51.9l7.75,4.47L11.85,22.4a.14.14,0,0,1-.09,0L5.32,18.68a6,6,0,0,1-2.2-8.18Zm22.13,5.14-7.78-4.52L20.16,9.6a.08.08,0,0,1,.09,0l6.44,3.72a6,6,0,0,1-.9,10.81V16.56A1.06,1.06,0,0,0,25.25,15.67Zm2.68-4-.19-.12-6.36-3.7a1,1,0,0,0-1.05,0l-7.78,4.49V9.2a.09.09,0,0,1,0-.09L19,5.4a6,6,0,0,1,8.91,6.21ZM11.08,17.15,8.38,15.6a.14.14,0,0,1-.05-.08V8.1a6,6,0,0,1,9.84-4.61L18,3.6,11.61,7.28a1,1,0,0,0-.53.91ZM12.54,14,16,12l3.47,2v4L16,20l-3.47-2Z"
fill="currentColor"
/>
</svg>
</template>
</div>
</template>
53 changes: 0 additions & 53 deletions web/src/views/chat/components/Message/Avatar.vue

This file was deleted.

2 changes: 1 addition & 1 deletion web/src/views/chat/components/Message/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang='ts'>
import { ref } from 'vue'
import { NDropdown } from 'naive-ui'
import AvatarComponent from './Avatar.vue'
import AvatarComponent from '../Avatar/MessageAvatar.vue'
import TextComponent from './Text.vue'
import { SvgIcon } from '@/components/common'
import { copyText } from '@/utils/format'
Expand Down
16 changes: 4 additions & 12 deletions web/src/views/chat/components/Session/SessionConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ const chatModelOptions = [
label: 'claude-instant(small,fast)',
value: 'claude-instant-v1',
},
{
label: 'claude-v1.2 (slightly better than v1)',
value: 'claude-v1.2',
},
{
label: 'claude-v1.3 (better than v1, code, non-english)',
value: 'claude-v1.3',
},
{
label: 'gpt-4(chatgpt)',
value: 'gpt-4',
Expand Down Expand Up @@ -120,9 +112,9 @@ const chatModelOptions = [
</NFormItem>
</NForm>
<!--
<div class="center">
<pre>{{ JSON.stringify(modelRef, null, 2) }} </pre>
</div>
-->
<div class="center">
<pre>{{ JSON.stringify(modelRef, null, 2) }} </pre>
</div>
-->
</div>
</template>
3 changes: 2 additions & 1 deletion web/src/views/chat/layout/sider/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { renameChatSession } from '@/api'
import { SvgIcon } from '@/components/common'
import { useAppStore, useChatStore } from '@/store'
import { useBasicLayout } from '@/hooks/useBasicLayout'
import ModelAvatar from '@/views/chat/components/Avatar/ModelAvatar.vue'
import { t } from '@/locales'
const { isMobile } = useBasicLayout()
Expand Down Expand Up @@ -91,7 +92,7 @@ function isActive(uuid: string) {
@click="handleSelect(item)"
>
<span>
<SvgIcon icon="ri:message-3-line" />
<ModelAvatar :model="item.model" />
</span>
<div class="relative flex-1 overflow-hidden break-all text-ellipsis whitespace-nowrap">
<NInput
Expand Down

0 comments on commit a609c36

Please sign in to comment.