Skip to content

Commit

Permalink
update pass model name
Browse files Browse the repository at this point in the history
  • Loading branch information
ZHallen122 committed Nov 3, 2024
1 parent c22001d commit 2baa14b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/src/chat/chat.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class ChatResolver {
MessageRole.User,
);

const iterator = this.chatProxyService.streamChat(input.message);
const iterator = this.chatProxyService.streamChat(input);
let accumulatedContent = '';

for await (const chunk of iterator) {
Expand Down
16 changes: 12 additions & 4 deletions backend/src/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { Message, MessageRole } from 'src/chat/message.model';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { User } from 'src/user/user.model';
import { NewChatInput, UpdateChatTitleInput } from 'src/chat/dto/chat.input';
import {
ChatInput,
NewChatInput,
UpdateChatTitleInput,
} from 'src/chat/dto/chat.input';

type CustomAsyncIterableIterator<T> = AsyncIterator<T> & {
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
Expand All @@ -17,8 +21,12 @@ export class ChatProxyService {

constructor(private httpService: HttpService) {}

streamChat(input: string): CustomAsyncIterableIterator<ChatCompletionChunk> {
this.logger.debug('request chat input: ' + input);
streamChat(
input: ChatInput,
): CustomAsyncIterableIterator<ChatCompletionChunk> {
this.logger.debug(
`Request chat input: ${input.message} with model: ${input.model}`,
);
let isDone = false;
let responseSubscription: any;
const chunkQueue: ChatCompletionChunk[] = [];
Expand Down Expand Up @@ -60,7 +68,7 @@ export class ChatProxyService {
responseSubscription = this.httpService
.post(
'http://localhost:3001/chat/completion',
{ content: input },
{ content: input.message, model: input.model },
{ responseType: 'stream' },
)
.subscribe({
Expand Down

0 comments on commit 2baa14b

Please sign in to comment.