Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@wenfengwang
Copy link
Contributor

introduce Thread to manage chat context

@wenfengwang wenfengwang merged commit 008e7b2 into main Apr 9, 2024
@wenfengwang wenfengwang deleted the feat-thread branch April 9, 2024 20:53
"content": msg.content,
})
msgs['history'] = history
return msgs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return json.dumps(msgs)

else:
msgs.append(msg)

return print(json.dumps(msgs))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print() returns None here, so you probably want to remove it and use return json.dumps(msgs)

message: str | ChatParameters,
context: List[ChatCompletionMessageParam] = None,
return_history: Literal[True] = True,
context: Thread,
Copy link
Collaborator

@idiotWu idiotWu Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two overloads are unnecessary in this case

message: str | ChatParameters,
context: List[ChatCompletionMessageParam] = None,
return_history: bool = False,
context: Thread,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chat() method is called without context when using the app as a tool. So we need to make context optional here.

BTW, why not just use the name thread in the parameters?

ChatCompletionMessageParam, ChatCompletionFunctionCallOptionParam)


class ThreadMessage:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a comment: Not sure if I like the name ThreadMessage here and the method Thread::fork() -> ThreadMessage below. The first thing that comes to my mind when seeing a fork() method is that it will create a copy of the running process or the instance itself. In this case, however, it just creates a new ThreadMessage. It might make more sense to me to use class Task and Thread::create_task here.


class ThreadManager():
"""the manager of the thread"""
threads: dict
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

threads: Dict[str, Thread]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants