feat: introduce Thread to manage chat context#5
Conversation
| "content": msg.content, | ||
| }) | ||
| msgs['history'] = history | ||
| return msgs |
There was a problem hiding this comment.
return json.dumps(msgs)
| else: | ||
| msgs.append(msg) | ||
|
|
||
| return print(json.dumps(msgs)) |
There was a problem hiding this comment.
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.
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.
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.
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.
threads: Dict[str, Thread]
introduce
Threadto manage chat context