综合介绍
Julep AI 是一个用于创建和管理AI智能体的平台,这些智能体可以记住过去的互动,并执行复杂的多步骤任务。Julep AI 提供了长期记忆和多步骤流程管理功能,支持与外部工具和 API 的集成,使其能够处理复杂的场景。用户可以通过编写简单的 YAML 文件来定义任务的各个步骤、决策点、循环和并行处理等,并在云端自动执行这些任务。
Julep AI 引入了一种新的领域特定语言(DSL)和服务器,用于管理 AI 智能体和多步骤任务。这种 DSL 使得用户能够更直观地描述和管理复杂的工作流,而无需编写大量的传统代码。Julep AI 的云平台负责执行这些任务,确保任务的可靠性和高效性。
功能列表
- 持久 AI 代理:智能体能够记住上下文和信息,支持长期交互。
- 状态会话:跟踪过去的互动,提供个性化的响应。
- 多步骤任务:通过循环和决策构建复杂的多步骤流程。
- 任务管理:处理可以长时间运行的任务,确保任务顺利完成。
- 内置工具和 API 集成:支持使用内置工具和外部 API,扩展智能体的功能。
- 自我修复:自动重试失败的步骤,重新发送消息,确保任务顺利运行。
- RAG(检索增强生成):使用文档存储构建一个用于检索和使用自己数据的系统。
使用帮助
安装流程
- 注册账号:访问 Julep AI 官网,点击“注册”按钮,填写必要信息完成注册。
- 获取API密钥:登录后,在用户面板中找到API密钥生成选项,生成并保存API密钥。
- 下载SDK:根据平台需求,下载相应的SDK(如Python、Node.js等),并按照文档进行安装。
使用指南
创建智能体
- 定义智能体:在控制面板中,点击“创建智能体”,填写智能体名称和描述。
- 配置模型:选择适合的AI模型(如GPT-4),并设置默认参数(如温度、最大token数等)。
- 添加工具:为智能体添加所需工具,如网络搜索、API调用等。
定义多步骤流程
- 编写YAML文件:在控制面板中,使用YAML编写多步骤流程,定义决策树、循环和并行执行。
- 上传文件:将编写好的YAML文件上传至平台,并进行测试。
- 部署流程:测试通过后,点击“部署”按钮,将流程上线。
快速原型设计
- 创建新项目:在控制面板中,点击“新建项目”,填写项目名称和描述。
- 添加功能模块:根据需求,选择并添加所需功能模块(如RAG、状态管理等)。
- 测试和迭代:在平台上进行测试,实时调整和优化功能模块。
生产级准备
- 配置基础设施:在控制面板中,配置基础设施选项,如自动扩展、负载均衡等。
- 设置错误处理:定义错误处理机制,确保任务在失败时自动重试。
- 上线项目:完成配置后,点击“上线”按钮,将项目推向生产环境。
模块化设计
- 选择模块:在控制面板中,浏览并选择所需模块(如外部API连接、LLM切换等)。
- 拖放集成:使用拖放界面,将模块集成到项目中。
- 测试和优化:实时测试模块功能,进行优化和调整。
无限扩展
- 配置扩展选项:在控制面板中,配置自动扩展和负载均衡选项。
- 监控性能:使用平台提供的监控工具,实时监控系统性能和用户并发量。
- 调整配置:根据监控数据,调整扩展和负载均衡配置,确保系统稳定运行。
未来保障
- 添加新模型:在控制面板中,点击“添加新模型”,选择并配置新AI模型。
- 集成新工具:浏览平台提供的新工具,选择并集成到现有项目中。
- 测试和部署:对新模型和工具进行测试,确保兼容性和稳定性,然后部署上线。
示例任务
Julep 非常适合需要超越简单的提示响应模型的 AI 用例的应用程序。
快速示例
想象一下一个可以执行以下操作的研究 AI 代理:
- 选择一个主题
- 针对该主题提出 30 个搜索查询
- 同时进行网页搜索
- 总结结果
- 将摘要发送至 Discord
在 Julep 中,这将是一项单独的任务,80行代码然后运行完全托管全部独立完成。所有步骤都在 Julep 自己的服务器上执行,您无需动手。
这是一个有效的例子:
name: Research Agent
# Optional: Define the input schema for the task
input_schema:
type: object
properties:
topic:
type: string
description: The main topic to research
num_questions:
type: integer
description: The number of search queries to generate
# Define the tools that the agent can use
tools:
- name: web_search
type: integration
integration:
provider: brave
setup:
api_key: <your-brave-api-key>
- name: discord_webhook
type: api_call
api_call:
url: https://discord.com/api/webhooks/<your-webhook-id>/<your-webhook-token>
method: POST
headers:
Content-Type: application/json
# Special variables:
# - inputs: for accessing the input to the task
# - outputs: for accessing the output of previous steps
# - _: for accessing the output of the previous step
# Define the main workflow
main:
- prompt:
- role: system
content: >-
You are a research assistant.
Generate {{inputs[0].num_questions|default(30, true)}} diverse search queries related to the topic:
{{inputs[0].topic}}
Write one query per line.
unwrap: true
# Evaluate the search queries using a simple python expression
- evaluate:
search_queries: "_.split(NEWLINE)"
# Run the web search in parallel for each query
- over: "_.search_queries"
map:
tool: web_search
arguments:
query: "_"
parallelism: 5
# Collect the results from the web search
- evaluate:
search_results: _
# Summarize the results
- prompt:
- role: system
content: >
You are a research summarizer. Create a comprehensive summary of the following research results on the topic {{inputs[0].topic}}.
The summary should be well-structured, informative, and highlight key findings and insights. Keep the summary concise and to the point.
The length of the summary should be less than 150 words.
Here are the search results:
{{_.search_results}}
unwrap: true
settings:
model: gpt-4o-mini
- evaluate:
discord_message: |-
f'''
**Research Summary for {inputs[0].topic}**
{_}
'''
# Send the summary to Discord
- tool: discord_webhook
arguments:
json_:
content: _.discord_message[:2000] # Discord has a 2000 character limit
在这个例子中,Julep 将自动管理并行执行,重试失败的步骤,重新发送 API 请求,并保持任务可靠运行直到完成。
输出结果示例
这在 30 秒内运行并返回以下输出:
人工智能研究摘要
人工智能(AI)研究成果摘要
简介
近年来,人工智能 (AI) 领域取得了重大进展,其特点是方法和技术的发展,使机器能够感知环境、从数据中学习并做出决策。本摘要主要关注从与 AI 相关的各种研究成果中获得的见解。主要发现
- 人工智能的定义和范围 :
人工智能被定义为计算机科学的一个分支,专注于创建能够执行需要类似人类智能的任务的系统,包括学习、推理和解决问题(维基百科)。它涵盖了各种子领域,包括机器学习、自然语言处理、机器人和计算机视觉。- 影响与应用 :
AI 技术正在融入众多领域,提高效率和生产力。应用范围从自动驾驶汽车和医疗诊断到客户服务自动化和财务预测(OpenAI)。谷歌致力于让人工智能造福每个人,这凸显了其通过增强各个平台的用户体验(谷歌人工智能)显著改善日常生活的潜力。- 道德考虑 :
关于人工智能的伦理影响的讨论一直在进行中,包括对隐私、偏见和决策过程中的责任的担忧。强调需要一个确保安全和负责任地使用人工智能技术的框架(OpenAI)。- 学习机制 :
AI 系统利用不同的学习机制,例如监督学习、无监督学习和强化学习。这些方法允许 AI 通过从过去的经验和数据中学习来提高性能(维基百科)。监督学习和无监督学习之间的区别至关重要;监督学习依赖于标记数据,而无监督学习则识别没有预定义标签的模式(无监督)。- 未来方向 :
未来人工智能的发展预计将专注于增强人工智能系统的可解释性和透明度,确保它们能够提供合理的决策和行动(OpenAI)。人们还在努力使人工智能系统更易于访问和用户友好,鼓励不同人群和行业更广泛地采用它(谷歌人工智能)。结论
人工智能代表着跨多个领域的变革力量,有望重塑行业并改善生活质量。然而,随着其能力的扩展,解决随之而来的伦理和社会影响至关重要。技术专家、伦理学家和政策制定者之间的持续研究和合作对于驾驭人工智能的未来格局至关重要。
Python 部署过程
要开始使用 Julep,请使用 pip 安装它:
pip install julep
从此处获取您的 API 密钥。
### Step 0: Setup import time import yaml from julep import Julep # or AsyncJulep client = Julep(api_key="your_julep_api_key") ### Step 1: Create an Agent agent = client.agents.create( name="Storytelling Agent", model="claude-3.5-sonnet", about="You are a creative storyteller that crafts engaging stories on a myriad of topics.", ) ### Step 2: Create a Task that generates a story and comic strip task_yaml = """ name: Storyteller description: Create a story based on an idea. tools: - name: research_wikipedia type: integration integration: provider: wikipedia method: search main: # Step 1: Generate plot idea - prompt: - role: system content: You are {{agent.name}}. {{agent.about}} - role: user content: > Based on the idea '{{_.idea}}', generate a list of 5 plot ideas. Go crazy and be as creative as possible. Return your output as a list of long strings inside ```yaml 标签位于您的回复末尾。 展开:true - 评价: 情节想法:load_yaml(_.split('```yaml')[1].split('```')[0].strip()) # 第二步:从情节思路中提取研究领域 - 迅速的: - 角色:系统 内容:您是 {{agent.name}}。{{agent.about}} - 角色:用户 内容: > 以下是一些故事情节的想法: {% 表示 _.plot_ideas 中的想法 %} - {{主意}} {% 结束 %} 为了发展故事情节,我们需要研究情节思路。 我们应该研究什么?写下你认为有趣的情节想法的维基百科搜索查询。 将输出作为 yaml 列表返回```yaml tags at the end of your response. unwrap: true settings: model: gpt-4o-mini temperature: 0.7 - evaluate: research_queries: load_yaml(_.split('```yaml')[1].split('```')[0].strip()) # Step 3: Research each plot idea - foreach: in: _.research_queries do: tool: research_wikipedia arguments: query: _ - evaluate: wikipedia_results: 'NEWLINE.join([f"- {doc.metadata.title}: {doc.metadata.summary}" for item in _ for doc in item.documents])' # Step 4: Think and deliberate - prompt: - role: system content: You are {{agent.name}}. {{agent.about}} - role: user content: |- Before we write the story, let's think and deliberate. Here are some plot ideas: {% for idea in outputs[1].plot_ideas %} - {{idea}} {% endfor %} Here are the results from researching the plot ideas on Wikipedia: {{_.wikipedia_results}} Think about the plot ideas critically. Combine the plot ideas with the results from Wikipedia to create a detailed plot for a story. Write down all your notes and thoughts. Then finally write the plot as a yaml object inside ```yaml 标签位于响应末尾。yaml 对象应具有以下结构: ```yaml title: "<string>" characters: - name: "<string>" about: "<string>" synopsis: "<string>" scenes: - title: "<string>" description: "<string>" characters: - name: "<string>" role: "<string>" plotlines: - "<string>"``` 确保 yaml 有效,且角色和场景不为空。还要注意分号和编写 yaml 的其他问题。 展开:true - 评价: 情节:“load_yaml(_.split('```yaml')[1].split('```')[0].strip())” """ 任务 = 客户端.任务.创建( agent_id=代理.id, **yaml.safe_load(任务_yaml) ) ### 步骤 3:执行任务 执行 = 客户端.执行.创建( 任务ID=任务ID, 输入={“idea”:“一只学飞的猫”} ) # 🎉 观看故事和漫画面板的生成 while (result := client.executions.get(execution.id)).status 不在 ['成功', '失败'] 中: 打印(结果.状态,结果.输出) 时间.睡眠(1) # 📦执行完成后,检索结果 如果 result.status ==“成功”: 打印(结果.输出) 别的: 引发异常(结果.错误)