This commit is contained in:
Wenjie Zhang 2024-09-25 13:48:25 +08:00
commit 9070ca31a2
4 changed files with 140 additions and 11 deletions

View File

@ -1,9 +1,14 @@
MODEL=Meta-Llama-3-8B-Instruct MODEL=Meta-Llama-3-8B-Instruct
if [ -z "$1" ]; then
echo "Error: No argument provided. Please specify a model name."
exit 1
fi
if [ "$1" = "llama" ]; then if [ "$1" = "llama" ]; then
CUDA_VISIBLE_DEVICES=0,1 python -m vllm.entrypoints.openai.api_server \ CUDA_VISIBLE_DEVICES=0 python -m vllm.entrypoints.openai.api_server \
--model="/hdd/zwj/models/meta-llama/$MODEL" \ --model="/hdd/zwj/models/meta-llama/$MODEL" \
--tensor-parallel-size 2 \ --tensor-parallel-size 1 \
--trust-remote-code \ --trust-remote-code \
--device auto \ --device auto \
--gpu-memory-utilization 0.98 \ --gpu-memory-utilization 0.98 \

18
vllm/test_vllm.py Normal file
View File

@ -0,0 +1,18 @@
from openai import OpenAI
# Set OpenAI's API key and API base to use vLLM's API server.
openai_api_key = "EMPTY"
openai_api_base = "http://localhost:8080/v1"
client = OpenAI(
api_key=openai_api_key,
base_url=openai_api_base,
)
chat_response = client.chat.completions.create(
model="llama",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Tell me a joke."},
]
)
print("Chat response:", chat_response)

View File

@ -466,7 +466,7 @@ watch(
.chat { .chat {
position: relative; position: relative;
width: 100%; width: 100%;
height: 100vh; max-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow-x: hidden; overflow-x: hidden;

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, KeepAlive, onMounted } from 'vue' import { ref, reactive, KeepAlive, onMounted } from 'vue'
import { RouterLink, RouterView, useRoute } from 'vue-router' import { RouterLink, RouterView, useRoute } from 'vue-router'
import { import {
MessageOutlined, MessageOutlined,
@ -27,7 +27,10 @@ import DebugComponent from '@/components/DebugComponent.vue'
const configStore = useConfigStore() const configStore = useConfigStore()
const databaseStore = useDatabaseStore() const databaseStore = useDatabaseStore()
const showDebug = ref(false) const layoutSettings = reactive({
showDebug: false,
useTopBar: false, // 使
})
const getRemoteConfig = () => { const getRemoteConfig = () => {
fetch('/api/config').then(res => res.json()).then(data => { fetch('/api/config').then(res => res.json()).then(data => {
@ -57,10 +60,10 @@ console.log(route)
</script> </script>
<template> <template>
<div class="app-layout"> <div class="app-layout" :class="{ 'use-top-bar': layoutSettings.useTopBar }">
<div class="debug-panel" > <div class="debug-panel" >
<a-float-button <a-float-button
@click="showDebug=!showDebug" @click="layoutSettings.showDebug = !layoutSettings.showDebug"
tooltip="调试面板" tooltip="调试面板"
:style="{ :style="{
right: '12px', right: '12px',
@ -71,7 +74,7 @@ console.log(route)
</template> </template>
</a-float-button> </a-float-button>
<a-drawer <a-drawer
v-model:open="showDebug" v-model:open="layoutSettings.showDebug"
title="调试面板" title="调试面板"
width="800" width="800"
:contentWrapperStyle="{ maxWidth: '100%'}" :contentWrapperStyle="{ maxWidth: '100%'}"
@ -80,9 +83,12 @@ console.log(route)
<DebugComponent /> <DebugComponent />
</a-drawer> </a-drawer>
</div> </div>
<div class="header"> <div class="header" :class="{ 'top-bar': layoutSettings.useTopBar }">
<div class="logo"> <div class="logo">
<router-link to="/"><img src="/jnu.png"> </router-link> <router-link to="/">
<img src="/jnu.png">
<span class="logo-text">语析</span>
</router-link>
</div> </div>
<div class="nav"> <div class="nav">
<RouterLink to="/chat" class="nav-item" active-class="active"> <RouterLink to="/chat" class="nav-item" active-class="active">
@ -185,6 +191,10 @@ div.header, #app-router-view {
border-radius: 50%; border-radius: 50%;
} }
.logo-text {
display: none;
}
& > a { & > a {
text-decoration: none; text-decoration: none;
font-size: 24px; font-size: 24px;
@ -213,6 +223,10 @@ div.header, #app-router-view {
&.github { &.github {
padding: 10px 12px; padding: 10px 12px;
&:hover {
background-color: transparent;
border: 1px solid transparent;
}
} }
&.setting { &.setting {
@ -300,4 +314,96 @@ div.header, #app-router-view {
width: 0; width: 0;
} }
} }
.app-layout.use-top-bar {
flex-direction: column;
}
.header.top-bar {
flex-direction: row;
flex: 0 0 50px;
width: 100%;
height: 50px;
border-right: none;
border-bottom: 1px solid var(--main-light-2);
background-color: var(--main-light-3);
padding: 0 20px;
gap: 24px;
.logo {
width: fit-content;
height: 28px;
margin-right: 16px;
display: flex;
align-items: center;
a {
display: flex;
align-items: center;
text-decoration: none;
color: inherit;
}
img {
width: 28px;
height: 28px;
margin-right: 8px;
}
.logo-text {
display: block;
font-size: 16px;
font-weight: 600;
letter-spacing: 0.5px;
color: var(--main-600);
white-space: nowrap;
}
}
.nav {
flex-direction: row;
height: auto;
gap: 20px;
}
.nav-item {
flex-direction: row;
width: auto;
padding: 4px 16px;
margin: 0;
.icon {
margin-right: 8px;
font-size: 15px; //
}
.text {
margin-top: 0;
font-size: 15px;
}
&.github, &.setting {
padding: 8px 12px;
.icon {
margin-right: 0;
font-size: 18px;
}
&.active {
color: var(--main-600);
}
}
&.github {
a {
display: flex;
justify-content: center;
align-items: center;
}
}
}
}
</style> </style>