diff --git a/src/utils/llm.py b/src/utils/llm.py index c775e5b..0f4f73f 100644 --- a/src/utils/llm.py +++ b/src/utils/llm.py @@ -1,6 +1,15 @@ from litellm import completion +from langchain.prompts import PromptTemplate + from src.utils.config import CONFIG -print(CONFIG) + +def get_prompt(template: str, infos: dict) -> str: + """ + 根据模板,获取提示词 + """ + prompt_template = PromptTemplate(template=template) + return prompt_template.format(**infos) + def call_llm(prompt: str) -> str: """ @@ -8,7 +17,6 @@ def call_llm(prompt: str) -> str: Args: prompt: 输入的提示词 - custom_llm_provider: 自定义的LLM提供者 Returns: str: LLM返回的结果 """ diff --git a/test_call_llm.py b/test_call_llm.py deleted file mode 100644 index f83095b..0000000 --- a/test_call_llm.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python3 -""" -测试call_llm函数 -""" - -from src.utils.llm import call_llm - -def main(): - """测试call_llm函数""" - print("正在测试call_llm函数...") - - # 简单的测试提示词 - prompt = "你好,请简单回复一句话证明你能正常工作。" - - print(f"输入提示词: {prompt}") - - # 调用LLM - response = call_llm(prompt) - - print(f"LLM响应: {response}") - print("测试完成!") - -if __name__ == "__main__": - main()