Skip to content

Dev test#412

Closed
whipser030 wants to merge 3 commits intoMemTensor:devfrom
whipser030:dev_test
Closed

Dev test#412
whipser030 wants to merge 3 commits intoMemTensor:devfrom
whipser030:dev_test

Conversation

@whipser030
Copy link
Copy Markdown
Collaborator

Description

Summary: (summary)

Fix: #(issue)

Docs Issue/PR: (docs-issue-or-pr-link)

Reviewer: @(reviewer)

Checklist:

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

return remove_thinking_tags(response_content)
else:
return response_content

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe merge two functions like this:

def generate(self, messages: MessageList, **kwargs) -> str:
"""Generate a response from OpenAI LLM, optionally overriding generation params."""
temperature = kwargs.get("temperature", self.config.temperature)
max_tokens = kwargs.get("max_tokens", self.config.max_tokens)
top_p = kwargs.get("top_p", self.config.top_p)

response = self.client.chat.completions.create(
model=self.config.model_name_or_path,
messages=messages,
extra_body=self.config.extra_body,
temperature=temperature,
max_tokens=max_tokens,
top_p=top_p,
)

logger.info(f"Response from OpenAI: {response.model_dump_json()}")

response_content = response.choices[0].message.content
if self.config.remove_think_prefix:
return remove_thinking_tags(response_content)
return response_content

return zh + max(1, rest // 4)


class StrategyStructMemReader(SimpleStructMemReader, ABC):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I noticed there’s quite a bit of overlap between StrategyStructMemReader and SimpleStructMemReader — particularly in the shared logic for parsing and memory generation.
Would it make sense to consolidate them or refactor into a shared base class for clarity and easier maintenance?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

def find_project_root(marker=".git"):
"""Find the project root directory by marking the file"""
current = Path(file).resolve()
while current != current.parent:
if (current / marker).exists():
return current
current = current.parent
logger.warn(f"The project root directory tag file was not found: {marker}")

PROJECT_ROOT = find_project_root()
DEFAULT_STOPWORD_FILE = (
PROJECT_ROOT / "examples" / "data" / "config" / "stopwords.txt"
) # cause time delay

maybe at product env will not exist this path "examples" / "data" / "config" / "stopwords.txt"

@whipser030 whipser030 closed this Oct 29, 2025
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