Skip to content

Conversation

@coxine
Copy link
Collaborator

@coxine coxine commented Jul 23, 2025

  • Optimize chateval.py to enhance the performance.
  • Modify extending.md correspondingly.

#44

@SHAO-Jiaqi757 SHAO-Jiaqi757 requested review from RuishanFang and SHAO-Jiaqi757 and removed request for SHAO-Jiaqi757 July 23, 2025 06:23
# Handle case where response_content might be a list or other type
content = response_content if isinstance(response_content, str) else str(response_content)
if self.chat_history is None:
self.chat_history = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check is unnecessary since chat_history is already initialized in the post_init method.

"solution": response.content
}

async def generate_response(self, context: str) -> Any:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add specific type annotations to improve code clarity

Replace generic Any return type with more specific type annotations like
Dict[str, Union[Any, str]]

self.chat_history.append({"role": "human", "human": context})
self.chat_history.append({"role": "ai", "ai": content})

def _build_messages(self, context: str) -> List:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add specific type annotations to improve code clarity

Replace the generic List return type with the more specific
List[Union[SystemMessage, HumanMessage, AIMessage]] to clearly indicate
the expected message types.

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.

2 participants