XiangJinYu commited on
Commit
adbda9f
·
verified ·
1 Parent(s): 85cc548

Update metagpt/ext/spo/utils/llm_client.py

Browse files
Files changed (1) hide show
  1. metagpt/ext/spo/utils/llm_client.py +2 -24
metagpt/ext/spo/utils/llm_client.py CHANGED
@@ -33,9 +33,9 @@ class SPO_LLM:
33
  raise ValueError("'model' parameter is required")
34
 
35
  try:
36
- model_config = ModelsConfig.default().get(model)
37
  if model_config is None:
38
- raise ValueError(f"Model '{model}' not found in configuration")
39
 
40
  config = model_config.model_copy()
41
 
@@ -83,25 +83,3 @@ def extract_content(xml_string: str, tag: str) -> Optional[str]:
83
  return match.group(1).strip() if match else None
84
 
85
 
86
- async def main():
87
- # test LLM
88
- SPO_LLM.initialize(
89
- optimize_kwargs={"model": "gpt-4o", "temperature": 0.7},
90
- evaluate_kwargs={"model": "gpt-4o-mini", "temperature": 0.3},
91
- execute_kwargs={"model": "gpt-4o-mini", "temperature": 0.3},
92
- )
93
-
94
- llm = SPO_LLM.get_instance()
95
-
96
- # test messages
97
- hello_msg = [{"role": "user", "content": "hello"}]
98
- response = await llm.responser(request_type=RequestType.EXECUTE, messages=hello_msg)
99
- logger(f"AI: {response}")
100
- response = await llm.responser(request_type=RequestType.OPTIMIZE, messages=hello_msg)
101
- logger(f"AI: {response}")
102
- response = await llm.responser(request_type=RequestType.EVALUATE, messages=hello_msg)
103
- logger(f"AI: {response}")
104
-
105
-
106
- if __name__ == "__main__":
107
- asyncio.run(main())
 
33
  raise ValueError("'model' parameter is required")
34
 
35
  try:
36
+ model_config = ModelsConfig.default().get("gpt-4o-mini")
37
  if model_config is None:
38
+ raise ValueError(f"Model gpt-4o-mini not found in configuration")
39
 
40
  config = model_config.model_copy()
41
 
 
83
  return match.group(1).strip() if match else None
84
 
85