Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Caojiahao-Coder committed Feb 15, 2024
2 parents ba6663a + 57ba73f commit dfd1439
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
13 changes: 3 additions & 10 deletions src/chat.completion/ChatCompletionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,13 @@ class ChatCompletionHandler {

const messages: ChatCompletionMessage[] = [{
role: 'system',
content: 'You are a conversation summary assistant, you will generate a short title (10 characters or less) based on the user\'s conversation with you.',
tool_call_id: null,
tool_calls: null,
name: null,
content: 'You are a conversation summary assistant and you will generate a short title (10 characters or less) based on the conversation the user has with you. Generate the title in the language that the user is talking to you in.',
}, {
role: 'user',
content: `The question for the dialogue is: ${messageInfo.user_content}`,
tool_call_id: null,
tool_calls: null,
name: null,
}]
}] as ChatCompletionMessage[]

const chatCompletionResponse = await openAIServices.createChatCompletionsRequest(messages, false)
const chatCompletionResponse = await openAIServices.createChatCompletionsRequest(messages, false, false)

if (chatCompletionResponse.code !== 1 || chatCompletionResponse.data === null)
return
Expand All @@ -207,7 +201,6 @@ class ChatCompletionHandler {
await ChatCompletionParser(chatCompletionResponse.data!, (text) => {
title += text
}, () => { })

this.updateConversationTitleByIdAsync(title, messageInfo.conversation_id)
}

Expand Down
1 change: 1 addition & 0 deletions src/components/ConversationBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function updateConversationInfo(newInfo: TBConverstationInfo) {
<div id="conversation-body">
<MessageRecordItem
v-for="(item, index) in myMessageList" :key="index" :message-info="item"
:message-index="index"
:scroll-body="updateScroll" @on-reload-message-list="() => loadMessageList()"
/>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/components/MessageRecordItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import getFunctionResultByFunctionName from '@/openai/handler/FunctionHandler'
import messageController from '@/chat.completion/MessageController'
const props = defineProps<{
messageIndex: number
messageInfo: TBMessageInfo
scrollBody: () => void
}>()
Expand Down Expand Up @@ -96,6 +97,8 @@ async function getAnswer(messageId: number) {
if (!needGetFunctionResult) {
checkingFunctionCalling.value = false
reloadMessageInfoFromDB()
if (props.messageIndex === 0)
chatCompletionStore.chatCompletionHandler?.getChatCompletionTitleFromMessageAsync(messageInfo.value.id)
}
}
Expand Down Expand Up @@ -132,6 +135,9 @@ async function handleFunction(tool_call_id: string, functionName: string, args:
if (result)
reloadMessageInfoFromDB()
if (props.messageIndex === 0)
chatCompletionStore.chatCompletionHandler?.getChatCompletionTitleFromMessageAsync(messageInfo.value.id)
}
/**
Expand Down
4 changes: 2 additions & 2 deletions src/openai/logic/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class OpenAIServices {
* @param useTools
* @returns
*/
public async createChatCompletionsRequest(message: ChatCompletionMessage[], useVisionAPI: boolean): Promise<OpenAIRequestResult> {
public async createChatCompletionsRequest(message: ChatCompletionMessage[], useVisionAPI: boolean, autoUseTools: boolean = true): Promise<OpenAIRequestResult> {
const openAIPayload = await this.getOpenAIPayload()

if (!openAIPayload) {
Expand All @@ -54,7 +54,7 @@ class OpenAIServices {

let fetchBody = null

if (tools && tools.length > 0) {
if (tools && tools.length > 0 && autoUseTools) {
fetchBody = JSON.stringify({
top_p: topP.value,
max_tokens: useVisionAPI ? gpt_models.find(item => item.value === usedModel)?.tokens : null,
Expand Down

0 comments on commit dfd1439

Please sign in to comment.