当前位置: 首页 > news >正文

wordpress收到登录错误保定seo网络推广

wordpress收到登录错误,保定seo网络推广,海外设计网站建设,java网站开发教学视频要进一步提升智能编码助手的效率,我觉得需要做到两点 1) 进一步让主人聚焦于设计输入以及结果验证的循环 2) 进一步让智能编码助手聚焦于代码实现和程序流程(保存、打开,修订、执行、合并…) 正好接触到LLM…

要进一步提升智能编码助手的效率,我觉得需要做到两点
1) 进一步让主人聚焦于设计输入以及结果验证的循环
2) 进一步让智能编码助手聚焦于代码实现和程序流程(保存、打开,修订、执行、合并…)
正好接触到LLM的LangChain的框架,那么初步体验一把利用其Agent实现代码生成,保存与执行
LangChain的中文官网

参考借鉴链接 :阿里通义千问结合Langchain基于程序运行结果回答问题
链接中有一篇介绍,要求AI计算给定阶数(文中是10阶)斐波那契数列,代码生成和执行已经有了,所以我的诉求,看上去挺简单,增加一个保存有效代码的功能就OK了
初步改造如下,新增存盘的函数和相关调用:

#**新增存盘函数**
def saveFile(replyMessages: str):print('... to save the file ...')python_path="/home/cfets/eclipse-workspace/TestAI/testchain/"now_time = time.strftime('%Y-%m-%d_%H:%M:%S', time.localtime())i = random.randint(1, 100)code_file = python_path + "pyAITest_" + now_time + '_' + str(i) + ".py"# 保存至文件res_content=Falsetry:with open(code_file, 'w') as f:f.write(replyMessages)res_content =Trueexcept Exception as e:print('Error: %s' % e)return res_content@tool
def py_repl_tool(code: str):"""Returns the result of execution."""_, after = code.split("```py")realcode = code.split("```")[0]# **新增保存文件**if saveFile(realcode):print('file is saved ... ')py_repl=PythonREPL()return py_repl.run(realcode)if __name__ == '__main__':os.environ["DASHSCOPE_API_KEY"] = dashscope.api_keytools = [Tool(name = "python repl",func=py_repl_tool.run,description="useful for when you need to use python to answer a question."+"You should input python code in correct format and keep the logic as simple as possible. If you want to see the output of a value, you should print it out with `print(...)`.")]agent = initialize_agent(llm=tongyi.Tongyi(model_name="qwen-max",temperature=0.1), tools=tools,verbose=True,max_iterations=3,
)agent.run("What is the 10th fibonacci number?")#agent.run("How many letters in string: Helllomyyfrienddds?")

但很遗憾,测试的结果是,计算的结果与文章一致,10阶斐波那契数列,但保存的文件是空的
在这里插入图片描述

实际上,原代码中split不靠谱,按源代码realcode是空的,需要修改

@tool
def py_repl_tool(code: str):"""Returns the result of execution."""_, after = code.split("```py")# realcode = code.split("```")[0]   原文档的错误#修订后realcode = after.split("```")[0]#print('realcode:  %s' % realcode)# **新增保存文件**if saveFile(realcode):print('file is saved ... ')py_repl=PythonREPL()return py_repl.run(realcode)

修改后执行就OK
主程序执行结果:
在这里插入图片描述
与保存的程序执行结果一致
在这里插入图片描述
但是计算结果是34 这是9阶的斐波那契数列,而不是55——10阶的斐波那契数列,原链接中的结果
在这里插入图片描述
可以把这段代码cp下来算一下,fibonacci(10)=34 , fibonacci(11)才是55
考虑到原代码realcode实际上为空的问题,我觉得原先的agent是分别生成了代码,但没有执行代码(realcode是空,执行啥?)而是找了答案,但无法确认… 所以AI自动生成代码还是保存后检查执行的,这算是歪打正着吧。

最后一个问题,根据初步了解 agent相关tool生成结果跟description描述有直接关系,如果直接引用原来的描述

description="useful for when you need to use python to answer a question.
You should input python code in correct format and keep the logic as simple as possible.   
If you want to see the output of a value, you should print it out with `print(...)`."

agent生成结果会呈现不稳定,有的时候’‘’ py …‘’’ 有的时候 ‘’’ python …‘’’
那么就会报错,参考原文,整理出一个较为完整的描述(description,相当于需求或者设计描述)
完整代码如下:

import dashscope
import os
from langchain_community.llms import tongyi
from langchain.agents import initialize_agent
from langchain.agents.tools import Tool
from langchain.tools import tool
from langchain.utilities.python import PythonREPL
import re
import time
import randomdashscope.api_key="xxxxxx"  #请自行替换# 新增存盘函数
def saveFile(replyMessages: str):print('... to save the file ...')python_path="/home/cfets/eclipse-workspace/TestAI/testchain/"now_time = time.strftime('%Y-%m-%d_%H:%M:%S', time.localtime())i = random.randint(1, 100)code_file = python_path + "pyAITest_" + now_time + '_' + str(i) + ".py"# 保存至文件res_content=Falsetry:with open(code_file, 'w') as f:f.write(replyMessages)res_content =Trueexcept Exception as e:print('Error: %s' % e)return res_content@tool
def py_repl_tool(code: str):"""Returns the result of execution."""_, after = code.split("```python")  realcode = after.split("```")[0]   #修改了原代码错误py_repl=PythonREPL()#print('realcode:  %s' % realcode)# 新增保存文件if saveFile(realcode):print('file is saved ... ')return py_repl.run(realcode)if __name__ == '__main__':os.environ["DASHSCOPE_API_KEY"] = dashscope.api_keytools = [Tool(name = "python repl",func=py_repl_tool.run,description=""""useful for when you need to use python to answer a question. You should input python code in correct format and keep the logic as simple as possible. you should end the program with `print(...)` to print the output and return only python code in Markdown format, e.g.:```python....```""")     #修改了描述,指定了Markdown format]agent = initialize_agent(llm=tongyi.Tongyi(model_name="qwen-max",temperature=0.1), tools=tools,verbose=True,max_iterations=3,
)agent.run("What is the 10th fibonacci number?")

后续考虑几方面的进一步改进
对单一功能实现单元化设计,把多个功能集成串起来,包括前后台设计,形成较为复杂的程序, 再进一步开发本地的知识库/代码库, 同时再利用现有架构测试其他大模型。

最后,希望大家能不能帮我解决一个问题,就是在执行代码为空的时候 55到底是怎么得出来的,先行拜谢

http://www.hkea.cn/news/20853/

相关文章:

  • 装修公司全包项目seo搜索引擎实训心得体会
  • 爱站网是干什么的长沙关键词排名首页
  • wordpress 教垜四川seo推广公司
  • 东莞市阳光网青岛seo服务
  • 网站弹窗在中间位置企业培训师
  • 整站下载器 安卓版域名解析查询站长工具
  • 跨境自建站模板seo推广是做什么
  • 网站建设与网页设计报告网络营销师报名入口
  • 生成前端页面的网站东莞网络营销全网推广
  • 网站及单位网站建设情况免费男女打扑克的软件
  • 公司有网站有什么好处网上开店如何推广自己的网店
  • 海口网站建设策划关键词排名优化工具有用吗
  • 请问哪里可以做网站汕头seo
  • 访问国外网站速度慢苏州关键词seo排名
  • 做网站备案照片的要求谷歌seo教程
  • wordpress站点全屏新站如何让百度快速收录
  • wordpress 会议 主题推广排名seo
  • 源码开发网站建设sem与seo的区别
  • 如何查网站的空间防恶意点击软件
  • 单位网站建设收费标准互联网推广引流
  • 网站有中文源码加英文怎么做关键词歌词完整版
  • 建设网站企业银行做网站的平台
  • 如何进行网站建设分析网站推广app软件
  • 做ppt的软件模板下载网站网站服务公司
  • 网站icp备案认证怎么做谷歌网页版入口在线
  • 高安网站建设艺考培训
  • 主流的网站开发技术百度推广后台管理
  • 传奇网站模板免费下载优化网络搜索引擎
  • 提升学历报考什么专业比较好seosem顾问
  • 做违法网站犯法吗推广费用一般多少钱