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

wordpress 2 s外贸网站seo教程

wordpress 2 s,外贸网站seo教程,网站如何做注册类 cpa,朋友做色情网站挣了好多钱目录 1️⃣ 选择框架2️⃣开发操作导入Python库创建功能函数装载环境变量创建Agent运行Agent 学习参考资料: 微软 AI Agents for Beginners 代码仓库 1️⃣ 选择框架 semantic-kernel开发框架 导入库创建功能函数(Agent 要完成什么功能)…

目录

  • 1️⃣ 选择框架
  • 2️⃣开发操作
    • 导入Python库
    • 创建功能函数
    • 装载环境变量
    • 创建Agent
    • 运行Agent


学习参考资料:

  • 微软 AI Agents for Beginners
    • 代码仓库

1️⃣ 选择框架

semantic-kernel开发框架

  1. 导入库
  2. 创建功能函数(Agent 要完成什么功能)
  3. 创建客户端
    1. 加载环境变量(保存在.env,保证API_Key安全性)
    2. 配置基地址(URL
    3. 选择基座模型
  4. 创建Agent
    1. 将客户端配置到 service
    2. Agent 名称
  5. 运行Agent

可能头疼地方的解决方案:

  • 模型API付费:
    • 创建 Github Token
    • 基地址:https://models.inference.ai.azure.com/

2️⃣开发操作

导入Python库

import os 
from typing import Annotated
from openai import AsyncOpenAIfrom dotenv import load_dotenvfrom semantic_kernel.agents import ChatCompletionAgent, ChatHistoryAgentThread
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
from semantic_kernel.functions import kernel_function

创建功能函数

import random   # Define a sample plugin for the sampleclass DestinationsPlugin:"""A List of Random Destinations for a vacation."""def __init__(self):# List of vacation destinationsself.destinations = ["Barcelona, Spain","Paris, France","Berlin, Germany","Tokyo, Japan","Sydney, Australia","New York, USA","Cairo, Egypt","Cape Town, South Africa","Rio de Janeiro, Brazil","Bali, Indonesia"]# Track last destination to avoid repeatsself.last_destination = None@kernel_function(description="Provides a random vacation destination.")def get_random_destination(self) -> Annotated[str, "Returns a random vacation destination."]:# Get available destinations (excluding last one if possible)available_destinations = self.destinations.copy()if self.last_destination and len(available_destinations) > 1:available_destinations.remove(self.last_destination)# Select a random destinationdestination = random.choice(available_destinations)# Update the last destinationself.last_destination = destinationreturn destination

装载环境变量

load_dotenv()
client = AsyncOpenAI(api_key=os.environ.get("GITHUB_TOKEN"), base_url="https://models.inference.ai.azure.com/",
)# Create an AI Service that will be used by the `ChatCompletionAgent`
chat_completion_service = OpenAIChatCompletion(# 模型可自行选择ai_model_id="gpt-4o-mini",async_client=client,
)

创建Agent

agent = ChatCompletionAgent(service=chat_completion_service, plugins=[DestinationsPlugin()],name="TravelAgent",instructions="You are a helpful AI Agent that can help plan vacations for customers at random destinations",
)

运行Agent

async def main():# Create a new thread for the agent# If no thread is provided, a new thread will be# created and returned with the initial responsethread: ChatHistoryAgentThread | None = Noneuser_inputs = ["Plan me a day trip.",]for user_input in user_inputs:print(f"# User: {user_input}\n")first_chunk = Trueasync for response in agent.invoke_stream(messages=user_input, thread=thread,):# 5. Print the responseif first_chunk:print(f"# {response.name}: ", end="", flush=True)first_chunk = Falseprint(f"{response}", end="", flush=True)thread = response.threadprint()# Clean up the threadawait thread.delete() if thread else Noneawait main()

在这里插入图片描述

http://www.dtcms.com/wzjs/53315.html

相关文章:

  • 怎样让google收录网站关键词推广软件
  • 网站上传空间下一步关键词在线下载
  • 郑州做小程序的公司全网seo优化电话
  • 免费炫酷网站模板如何在百度上发布自己的文章
  • wordpress中图片集百度荤seo公司
  • 网站建设人员任职要求冯站长之家官网
  • 网站怎么做移动图片不显示不出来吗2021年关键词排名
  • wordpress的链接功能宁德seo培训
  • 找人做一个网站需要花多少钱谷歌seo营销
  • 怎么让网站快速被收录企业管理软件管理系统
  • 如何维护自己公司网站3小时百度收录新站方法
  • 徐州市做网站竞价关键词排名软件
  • 死链接对网站的影响微信小程序开发文档
  • 香港服务器网站推广厦门百度竞价
  • 网站运营 策划 推广 维护2023年7月疫情还会严重吗
  • 高端的镇江网站建设软文写作的技巧
  • wordpress打包主题优化手机流畅度的软件
  • 网站优化快照爱营销电信版下载app最新版
  • 个人做新闻网站处罚苹果自研搜索引擎或为替代谷歌
  • 免费请美女做爰网站友情链接还有用吗
  • 国外看新闻app推荐南京seo公司排名
  • 中交上航建设网站微信平台推广方法
  • 福建建设工程招投标信息网找seo外包公司需要注意什么
  • 有什么做礼品的卖家网站seo自学网官方
  • 成都双流 网站建设十大广告联盟
  • 长沙做网站网络营销推广的方法有哪些
  • 肇庆专业网站建设服务优化网络搜索引擎
  • 自己做网站用php最快么东莞互联网推广
  • 郑州+高端网站建设北京自动网络营销推广
  • 单页网站制作建站仿站酒吧营销用什么软件找客源