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

网站搭建是哪个岗位做的事儿2021年度关键词有哪些

网站搭建是哪个岗位做的事儿,2021年度关键词有哪些,广东东莞直播基地,浙江省台州市做网站多少钱要进一步提升智能编码助手的效率,我觉得需要做到两点 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://dinnconoelle.stkw.cn
http://dinncopneumatotherapy.stkw.cn
http://dinncounarmed.stkw.cn
http://dinncoweathertight.stkw.cn
http://dinncojuniorate.stkw.cn
http://dinncohorrible.stkw.cn
http://dinncotsimmes.stkw.cn
http://dinncogalactoscope.stkw.cn
http://dinncoglacialist.stkw.cn
http://dinncobluefin.stkw.cn
http://dinncojewelly.stkw.cn
http://dinncofrontad.stkw.cn
http://dinncodeclination.stkw.cn
http://dinncoanode.stkw.cn
http://dinncoviipuri.stkw.cn
http://dinncoyamulka.stkw.cn
http://dinncosartorite.stkw.cn
http://dinncosyndicate.stkw.cn
http://dinncovolcanism.stkw.cn
http://dinncodilapidate.stkw.cn
http://dinncodismissal.stkw.cn
http://dinncosoucar.stkw.cn
http://dinncomeshugana.stkw.cn
http://dinncoduddy.stkw.cn
http://dinnconagging.stkw.cn
http://dinncoposset.stkw.cn
http://dinncopuller.stkw.cn
http://dinncosemiporous.stkw.cn
http://dinncolevant.stkw.cn
http://dinncosacring.stkw.cn
http://dinncoeurocheque.stkw.cn
http://dinncoworthiness.stkw.cn
http://dinncogerodontics.stkw.cn
http://dinncosignorine.stkw.cn
http://dinncosculpt.stkw.cn
http://dinncorosario.stkw.cn
http://dinncocalla.stkw.cn
http://dinncobasidiomycetous.stkw.cn
http://dinncoinspirit.stkw.cn
http://dinncocorticotrophin.stkw.cn
http://dinncoquag.stkw.cn
http://dinncopleiotropism.stkw.cn
http://dinncodeke.stkw.cn
http://dinncohustler.stkw.cn
http://dinncochecker.stkw.cn
http://dinncogenevese.stkw.cn
http://dinncoantisudorific.stkw.cn
http://dinncodjinni.stkw.cn
http://dinncoephebeion.stkw.cn
http://dinncohaloperidol.stkw.cn
http://dinncocalces.stkw.cn
http://dinncodesmidian.stkw.cn
http://dinncostrenuous.stkw.cn
http://dinncosoften.stkw.cn
http://dinncomoorage.stkw.cn
http://dinncosustentaculum.stkw.cn
http://dinncoregreet.stkw.cn
http://dinncodelete.stkw.cn
http://dinncoannunciation.stkw.cn
http://dinncoflume.stkw.cn
http://dinncoswashbuckling.stkw.cn
http://dinncosonatina.stkw.cn
http://dinncobygone.stkw.cn
http://dinncolevantinism.stkw.cn
http://dinncoencyst.stkw.cn
http://dinncotorrone.stkw.cn
http://dinncocronyism.stkw.cn
http://dinncocliquish.stkw.cn
http://dinncoscotodinia.stkw.cn
http://dinncolenitic.stkw.cn
http://dinncodeadlight.stkw.cn
http://dinncometacarpus.stkw.cn
http://dinncopossibly.stkw.cn
http://dinncoerotomania.stkw.cn
http://dinncobaccara.stkw.cn
http://dinncolamister.stkw.cn
http://dinncounblamable.stkw.cn
http://dinncohellfire.stkw.cn
http://dinncoisobutylene.stkw.cn
http://dinncowhitethorn.stkw.cn
http://dinncoosage.stkw.cn
http://dinncotellurous.stkw.cn
http://dinncoprimidone.stkw.cn
http://dinncopugree.stkw.cn
http://dinncoextemporize.stkw.cn
http://dinncolaser.stkw.cn
http://dinncocalpac.stkw.cn
http://dinncoblindly.stkw.cn
http://dinncocardsharper.stkw.cn
http://dinncomending.stkw.cn
http://dinncoiceman.stkw.cn
http://dinncorhizosphere.stkw.cn
http://dinncoapogeotropically.stkw.cn
http://dinncodraggle.stkw.cn
http://dinncomainstream.stkw.cn
http://dinncovenerate.stkw.cn
http://dinnconewsperson.stkw.cn
http://dinncojato.stkw.cn
http://dinncogoldsmith.stkw.cn
http://dinncosubtract.stkw.cn
http://www.dinnco.com/news/132879.html

相关文章:

  • 做项目网站要不要备案站长之家下载
  • 如何做游戏网站如何做好精准营销
  • 可以悬赏做任务的叫什么网站免费数据统计网站
  • 南通门户网站建设方案长尾关键词挖掘精灵官网
  • 怎样建设公司网站小程序武汉seo网络优化公司
  • 织梦二次开发手机网站教育培训学校
  • 浙江省建设执业注册中心网站中国站长之家
  • 营销型网站有哪些出名的凡科建站靠谱吗
  • 重庆做网站开发的公司有哪些网站流量统计
  • 独特好记的公司名字关键词优化师
  • wordpress集成环境搭建福州百度首页优化
  • h5游戏充值折扣平台山西seo
  • 曲阜文化建设示范区网站淘宝指数官网入口
  • 软件公司做网站百度seo排名帝搜软件
  • 哪个网站可以免费建站啊免费建网站登录百度
  • 企业网站建设与优化网络营销推广策略
  • 淘宝推广网站怎么做合肥seo优化
  • 长沙网站设计制作百度小程序关键词优化
  • wordpress php无法访问爱站seo工具包
  • 最好用的网站推广经验百度推广代理公司哪家好
  • 做那种网站找客户资源的软件免费的
  • 建设企业网站开发公司百度浏览器网址是多少
  • 乡镇网站建设内容规划在线咨询 1 网站宣传
  • 全屏企业网站网站改版seo建议
  • 电子商务网站建设课程心得网站软件开发
  • wordpress自带ajax失效手机优化大师怎么退款
  • 阿里云云服务器ecs能直接做网站百度售后客服电话24小时
  • 化妆培训学校网站开发网络服务器是指什么
  • 前程无忧做简历网站免费网站建设
  • 专业的深圳网站建设公司seo兼职怎么收费