Skip to content

Commit 211d54c

Browse files
committed
format code
1 parent cc3ed0c commit 211d54c

File tree

4 files changed

+42
-44
lines changed

4 files changed

+42
-44
lines changed

src/memos/llms/openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def generate(self, messages: MessageList, **kwargs) -> str:
6565
temperature=self.config.temperature,
6666
max_tokens=self.config.max_tokens,
6767
top_p=self.config.top_p,
68-
**kwargs
68+
**kwargs,
6969
)
7070
logger.info(f"Response from OpenAI: {response.model_dump_json()}")
7171
response_content = response.choices[0].message.content

src/memos/llms/vllm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _generate_with_api_client(self, messages: list[MessageDict], **kwargs) -> st
106106
"max_tokens": int(getattr(self.config, "max_tokens", 1024)),
107107
"top_p": float(getattr(self.config, "top_p", 0.9)),
108108
"extra_body": {"chat_template_kwargs": {"enable_thinking": False}},
109-
**kwargs
109+
**kwargs,
110110
}
111111

112112
response = self.client.chat.completions.create(**completion_kwargs)

src/memos/mem_reader/simple_struct.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
SIMPLE_STRUCT_MEM_READER_EXAMPLE_ZH,
2828
SIMPLE_STRUCT_MEM_READER_PROMPT,
2929
SIMPLE_STRUCT_MEM_READER_PROMPT_ZH,
30-
reader_output_schema
30+
reader_output_schema,
3131
)
3232
from memos.utils import timed
3333

@@ -201,9 +201,9 @@ def _get_llm_response(self, mem_str: str) -> dict:
201201
prompt = prompt.replace(examples, "")
202202
messages = [{"role": "user", "content": prompt}]
203203
try:
204-
response_text = self.llm.generate(messages,
205-
response_format={"type": "json_object",
206-
"schema": reader_output_schema})
204+
response_text = self.llm.generate(
205+
messages, response_format={"type": "json_object", "schema": reader_output_schema}
206+
)
207207
response_json = self.parse_json_result(response_text)
208208
except Exception as e:
209209
logger.error(f"[LLM] Exception during chat generation: {e}")

src/memos/templates/mem_reader_prompts.py

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -419,46 +419,44 @@
419419
"""
420420

421421
reader_output_schema = {
422-
"$schema": "https://json-schema.org/draft/2020-12/schema",
423-
"type": "object",
424-
"properties": {
425-
"memory list": {
426-
"type": "array",
427-
"items": {
428-
"type": "object",
429-
"properties": {
430-
"key": {
431-
"type": "string",
432-
"description": "A brief title or identifier for the memory."
433-
},
434-
"memory_type": {
435-
"type": "string",
436-
"enum": ["LongTermMemory", "ShortTermMemory", "WorkingMemory"],
437-
"description": "The type of memory, expected to be 'LongTermMemory' in this context."
438-
},
439-
"value": {
440-
"type": "string",
441-
"description": "Detailed description of the memory, including viewpoint, time, and content."
442-
},
443-
"tags": {
422+
"$schema": "https://json-schema.org/draft/2020-12/schema",
423+
"type": "object",
424+
"properties": {
425+
"memory list": {
444426
"type": "array",
445427
"items": {
446-
"type": "string"
428+
"type": "object",
429+
"properties": {
430+
"key": {
431+
"type": "string",
432+
"description": "A brief title or identifier for the memory.",
433+
},
434+
"memory_type": {
435+
"type": "string",
436+
"enum": ["LongTermMemory", "ShortTermMemory", "WorkingMemory"],
437+
"description": "The type of memory, expected to be 'LongTermMemory' in this context.",
438+
},
439+
"value": {
440+
"type": "string",
441+
"description": "Detailed description of the memory, including viewpoint, time, and content.",
442+
},
443+
"tags": {
444+
"type": "array",
445+
"items": {"type": "string"},
446+
"description": "List of keywords or categories associated with the memory.",
447+
},
448+
},
449+
"required": ["key", "memory_type", "value", "tags"],
450+
"additionalProperties": False,
447451
},
448-
"description": "List of keywords or categories associated with the memory."
449-
}
452+
"description": "List of memory entries.",
453+
},
454+
"summary": {
455+
"type": "string",
456+
"description": "A synthesized summary of the overall situation based on all memories.",
450457
},
451-
"required": ["key", "memory_type", "value", "tags"],
452-
"additionalProperties": False
453-
},
454-
"description": "List of memory entries."
455458
},
456-
"summary": {
457-
"type": "string",
458-
"description": "A synthesized summary of the overall situation based on all memories."
459-
}
460-
},
461-
"required": ["memory list", "summary"],
462-
"additionalProperties": False,
463-
"description": "Structured output containing a list of memories and a summary."
464-
}
459+
"required": ["memory list", "summary"],
460+
"additionalProperties": False,
461+
"description": "Structured output containing a list of memories and a summary.",
462+
}

0 commit comments

Comments
 (0)