1 Star 3 Fork 5

火云牌神/Programming with local large language model

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
00_chat.py 721 Bytes
一键复制 编辑 原始数据 按行查看 历史
火云牌神 提交于 1个月前 . rename
#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author : 刘立军
# @time : 2025-01-06
# @function: 测试llama3.1 8b模型
# @version : V0.5
from langchain_core.prompts import ChatPromptTemplate
from langchain_ollama.llms import OllamaLLM
# llama3.1 EntropyYue/chatglm3
model_name = "EntropyYue/chatglm3"
def ask(question):
template = """Question: {question}
Answer: Let's think step by step.
请用简体中文回复。
"""
prompt = ChatPromptTemplate.from_template(template)
model = OllamaLLM(model=model_name)
chain = prompt | model
result = chain.invoke({"question": question})
return result
if __name__ == '__main__':
print(ask("你是谁?你有什么本事?"))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/liupras/programming-with-local-large-language-model.git
git@gitee.com:liupras/programming-with-local-large-language-model.git
liupras
programming-with-local-large-language-model
Programming with local large language model
master

搜索帮助