-
Notifications
You must be signed in to change notification settings - Fork 12
feat: introduce Thread to manage chat context
#5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| "content": msg.content, | ||
| }) | ||
| msgs['history'] = history | ||
| return msgs |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
threads: Dict[str, Thread]
introduce
Threadto manage chat context