Skip to content

Commit

Permalink
Merge pull request #915 from julep-ai/dev
Browse files Browse the repository at this point in the history
main <- dev
  • Loading branch information
Vedantsahai18 authored Nov 29, 2024
2 parents 0a104ea + 3666873 commit 24340ec
Show file tree
Hide file tree
Showing 52 changed files with 5,136 additions and 1,135 deletions.
2 changes: 2 additions & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

<div align="center" id="top">
<img src="https://github.com/user-attachments/assets/10ba11e4-4ced-400e-a400-ee0f72541780" alt="julep" width="640" height="320" />
<img src="https://github.com/user-attachments/assets/10ba11e4-4ced-400e-a400-ee0f72541780" alt="julep" width="640" height="320" />
</div>

<p align="center">
<br />
<a href="https://docs.julep.ai" rel="dofollow">探索文档(正在开发中)</a>
<a href="https://docs.julep.ai" rel="dofollow">探索文档(正在开发中)</a>
·
<a href="https://discord.com/invite/JTSBGRZrzj" rel="dofollow">不和谐</a>
·
Expand Down
16 changes: 9 additions & 7 deletions README-FR.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

<div align="center" id="top">
<img src="https://github.com/user-attachments/assets/10ba11e4-4ced-400e-a400-ee0f72541780" alt="julep" width="640" height="320" />
<img src="https://github.com/user-attachments/assets/10ba11e4-4ced-400e-a400-ee0f72541780" alt="julep" width="640" height="320" />
</div>

<p align="center">
<br />
<a href="https://docs.julep.ai" rel="dofollow">Explorer les documents (en cours)</a>
<a href="https://docs.julep.ai" rel="dofollow">Explorer les documents (en cours)</a>
·
<a href="https://discord.com/invite/JTSBGRZrzj" rel="dofollow">Discorde</a>
·
Expand Down Expand Up @@ -79,13 +81,13 @@ Vos contributions, grandes ou petites, sont précieuses pour nous. Construisons
- [Gestion des sessions et des utilisateurs](#managing-sessions-and-users)
- [Intégration et recherche de documents](#document-integration-and-search)
- [Référence](#référence)
- [Référence SDK](#sdk-reference)
- [Référence API](#api-reference)
- [Démarrage rapide local](#local-quickstart)
- [Quelle est la différence entre Julep et LangChain etc ?](#quelle-est-la-différence-entre-julep-et-langchain-etc)
- [Différents cas d'utilisation](#different-use-cases)
- [Facteur de forme différent](#different-form-factor)
- [En résumé](#en-resumé)
- [Référence du SDK](#référence-du-sdk)
- [Référence API](#référence-api)
- [Démarrage rapide local](#démarrage-rapide-local)
- [Quelle est la différence entre Julep et LangChain etc ?](#quelle-est-la-différence-entre-julep-et-langchain-etc-)
- [Différents cas d'utilisation](#différents-cas-dutilisation)
- [Facteur de forme différent](#facteur-de-forme-différent)
- [En résumé](#en-résumé)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down
80 changes: 42 additions & 38 deletions README-JA.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

<div align="center" id="top">
<img src="https://github.com/user-attachments/assets/10ba11e4-4ced-400e-a400-ee0f72541780" alt="julep" width="640" height="320" />
<img src="https://github.com/user-attachments/assets/10ba11e4-4ced-400e-a400-ee0f72541780" alt="julep" width="640" height="320" />
</div>

<p align="center">
<br />
<a href="https://docs.julep.ai" rel="dofollow">ドキュメントを探索 (wip)</a>
<a href="https://docs.julep.ai" rel="dofollow">ドキュメントを探索 (wip)</a>
·
<a href="https://discord.com/invite/JTSBGRZrzj" rel="dofollow">不和</a>
·
Expand Down Expand Up @@ -49,43 +51,41 @@ Julep プロジェクトに新しい貢献者を迎えられることを嬉し
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
<h3>📖 目次</h3>

- [貢献者募集🌟](#call-for-contributors-)
- [はじめに](#introduction)
- [主な特徴](#key-features)
- [簡単な例](#quick-example)
- [インストール](#installation)
- [Python クイックスタート 🐍](#python-quick-start-)
- [Node.js クイック スタート 🟩](#nodejs-quick-start-)
- [コンポーネント](#components)
- [メンタルモデル](#mental-model)
- [コンセプト](#concepts)
- [タスクの理解](#understanding-tasks)
- [タスクのライフサイクル](#lifecycle-of-a-task)
- [ワークフロー ステップの種類](#types-of-workflow-steps)
- [共通手順](#common-steps)
- [キーと値のステップ](#key-value-steps)
- [反復ステップ](#iteration-steps)
- [条件付きステップ](#conditional-steps)
- [その他の制御フロー](#other-control-flow)
- [ツールの種類](#tool-types)
- [ユーザー定義の `functions`](#user-defined-functions)
- [`システム` ツール](#system-tools)
- [利用可能な `system` リソースと操作](#available-system-resources-and-operations)
- [組み込みの `integrations`](#built-in-integrations)
- [直接の `api_calls`](#direct-api_calls)
- [統合](#integrations)
- [その他の機能](#other-features)
- [エージェントへのツールの追加](#adding-tools-to-agents)
- [セッションとユーザーの管理](#managing-sessions-and-users)
- [ドキュメントの統合と検索](#document-integration-and-search)
- [参考](#reference)
- [SDKリファレンス](#sdk-reference)
- [APIリファレンス](#api-reference)
- [ローカルクイックスタート](#local-quickstart)
- [Julep と LangChain などの違いは何ですか?](#whats-the-difference-between-julep-and-langchain-etc)
- [さまざまなユースケース](#different-use-cases)
- [異なるフォームファクター](#different-form-factor)
- [要約](#in-summary)
- [貢献者募集🌟](#貢献者募集)
- [主な特徴](#主な特徴)
- [簡単な例](#簡単な例)
- [インストール](#インストール)
- [Python クイックスタート 🐍](#python-クイックスタート-)
- [Node.js Quick Start 🟩](#nodejs-quick-start-)
- [Components](#components)
- [Mental Model](#mental-model)
- [Concepts](#concepts)
- [Understanding Tasks](#understanding-tasks)
- [Lifecycle of a Task](#lifecycle-of-a-task)
- [Types of Workflow Steps](#types-of-workflow-steps)
- [Common Steps](#common-steps)
- [Key-Value Steps](#key-value-steps)
- [Iteration Steps](#iteration-steps)
- [Conditional Steps](#conditional-steps)
- [Other Control Flow](#other-control-flow)
- [Tool Types](#tool-types)
- [User-defined `functions`](#user-defined-functions)
- [`system` tools](#system-tools)
- [Available `system` resources and operations](#available-system-resources-and-operations)
- [Built-in `integrations`](#built-in-integrations)
- [Direct `api_calls`](#direct-api_calls)
- [Integrations](#integrations)
- [Other Features](#other-features)
- [Adding Tools to Agents](#adding-tools-to-agents)
- [Managing Sessions and Users](#managing-sessions-and-users)
- [Document Integration and Search](#document-integration-and-search)
- [SDK リファレンス](#sdk-リファレンス)
- [API リファレンス](#api-リファレンス)
- [ローカルクイックスタート](#ローカルクイックスタート)
- [Julep と LangChain などの違いは何ですか?](#julep-と-langchain-などの違いは何ですか)
- [さまざまなユースケース](#さまざまなユースケース)
- [異なるフォームファクタ](#異なるフォームファクタ)


<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -114,6 +114,7 @@ Julep を使用すると、意思決定、ループ、並列処理、多数の
4.**タスク管理**: 無期限に実行される可能性のある長時間実行タスクを処理します。
5. 🛠️ **組み込みツール**: タスクで組み込みツールと外部 API を使用します。
6. 🔧 **自己修復**: Julep は失敗したステップを自動的に再試行し、メッセージを再送信し、一般的にタスクがスムーズに実行されるようにします。
6. 🔧 **自己修復**: Julep は失敗したステップを自動的に再試行し、メッセージを再送信し、一般的にタスクがスムーズに実行されるようにします。
7. 📚 **RAG**: Julep のドキュメント ストアを使用して、独自のデータを取得して使用するためのシステムを構築します。

![機能](https://github.com/user-attachments/assets/4355cbae-fcbd-4510-ac0d-f8f77b73af70)
Expand Down Expand Up @@ -590,6 +591,7 @@ const タスク = client.tasks.create(agentId, yaml.parse(taskYaml)) を待機
非同期関数executeTask(taskId) {
const 実行 = クライアント.実行.作成(taskId, {
const 実行 = クライアント.実行.作成(taskId, {
入力: { アイデア: 「飛ぶことを学ぶ猫」 },
});
Expand Down Expand Up @@ -1493,8 +1495,8 @@ base64: 文字列 # (オプション) return_base64 が true の場合、base64
<td>

**Example cookbook**: [cookbooks/05-video-processing-with-natural-language.ipynb](https://github.com/julep-ai/julep/blob/dev/cookbooks/05-video-processing-with-natural-language.ipynb)

</td>

</tr>

</table>
Expand Down Expand Up @@ -1545,6 +1547,7 @@ context_overflow="適応型"
# 同じセッションで会話を続ける
レスポンス = client.sessions.chat(
session_id=セッションID、
session_id=セッションID、
メッセージ=[
{
「役割」: 「ユーザー」、
Expand Down Expand Up @@ -1618,6 +1621,7 @@ metadata_filter={"category": "研究論文"}
2. `cd ジュレップ`
3. `docker volume create cozo_backup`
4. docker ボリュームを作成します cozo_data
4. docker ボリュームを作成します cozo_data
5. `cp .env.example .env # <-- このファイルを編集します`
6. `docker compose --env-file .env --profile temporal-ui --profile single-tenant --profile self-hosted-db up --build`

Expand Down
1 change: 0 additions & 1 deletion agents-api/agents_api/activities/execute_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ async def execute_integration(
if integration.provider == "dummy":
return arguments

integration_service_response = await integrations.run_integration_service(
integration_service_response = await integrations.run_integration_service(
provider=integration.provider,
setup=setup,
Expand Down
27 changes: 21 additions & 6 deletions agents-api/agents_api/activities/execute_system.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import asyncio
from concurrent.futures import ProcessPoolExecutor
from functools import partial
from typing import Any
from uuid import UUID

Expand All @@ -16,15 +18,15 @@
TextOnlyDocSearchRequest,
VectorDocSearchRequest,
)
from ..autogen.Sessions import CreateSessionRequest
from ..autogen.Tools import SystemDef
from ..common.protocol.remote import RemoteObject
from ..common.protocol.tasks import StepContext
from ..common.storage_handler import auto_blob_store, load_from_blob_store_if_remote
from ..env import testing
from ..models.developer import get_developer
from .utils import get_handler

# For running synchronous code in the background
process_pool_executor = ProcessPoolExecutor()


@auto_blob_store(deep=True)
@beartype
Expand All @@ -36,7 +38,7 @@ async def execute_system(
arguments: dict[str, Any] = system.arguments or {}

if set(arguments.keys()) == {"bucket", "key"}:
arguments = load_from_blob_store_if_remote(arguments)
arguments = await load_from_blob_store_if_remote(arguments)

arguments["developer_id"] = context.execution_input.developer_id

Expand Down Expand Up @@ -108,13 +110,26 @@ async def execute_system(
developer_id = arguments.pop("developer_id")
session_id = arguments.pop("session_id", None)
data = CreateSessionRequest(**arguments)
return handler(developer_id=developer_id, session_id=session_id, data=data)

# In case sessions.create becomes asynchronous in the future
if asyncio.iscoroutinefunction(handler):
return await handler()

# Run the synchronous function in another process
loop = asyncio.get_running_loop()
return await loop.run_in_executor(
process_pool_executor, partial(handler, developer_id, session_id, data)
)

# Handle regular operations
if asyncio.iscoroutinefunction(handler):
return await handler(**arguments)
return handler(**arguments)

# Run the synchronous function in another process
loop = asyncio.get_running_loop()
return await loop.run_in_executor(
process_pool_executor, partial(handler, **arguments)
)
except BaseException as e:
if activity.in_activity():
activity.logger.error(f"Error in execute_system_call: {e}")
Expand Down
9 changes: 7 additions & 2 deletions agents-api/agents_api/activities/sync_items_remote.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
from typing import Any

from beartype import beartype
Expand All @@ -10,14 +11,18 @@
async def save_inputs_remote_fn(inputs: list[Any]) -> list[Any | RemoteObject]:
from ..common.storage_handler import store_in_blob_store_if_large

return [store_in_blob_store_if_large(input) for input in inputs]
return await asyncio.gather(
*[store_in_blob_store_if_large(input) for input in inputs]
)


@beartype
async def load_inputs_remote_fn(inputs: list[Any | RemoteObject]) -> list[Any]:
from ..common.storage_handler import load_from_blob_store_if_remote

return [load_from_blob_store_if_remote(input) for input in inputs]
return await asyncio.gather(
*[load_from_blob_store_if_remote(input) for input in inputs]
)


save_inputs_remote = activity.defn(name="save_inputs_remote")(save_inputs_remote_fn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def evaluate_step(
else context.current_step.evaluate
)

values = context.prepare_for_step(include_remote=True) | additional_values
values = await context.prepare_for_step(include_remote=True) | additional_values

output = simple_eval_dict(expr, values)
result = StepOutcome(output=output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def for_each_step(context: StepContext) -> StepOutcome:
assert isinstance(context.current_step, ForeachStep)

output = await base_evaluate(
context.current_step.foreach.in_, context.prepare_for_step()
context.current_step.foreach.in_, await context.prepare_for_step()
)
return StepOutcome(output=output)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async def if_else_step(context: StepContext) -> StepOutcome:
assert isinstance(context.current_step, IfElseWorkflowStep)

expr: str = context.current_step.if_
output = await base_evaluate(expr, context.prepare_for_step())
output = await base_evaluate(expr, await context.prepare_for_step())
output: bool = bool(output)

result = StepOutcome(output=output)
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/activities/task_steps/log_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def log_step(context: StepContext) -> StepOutcome:
template: str = context.current_step.log
output = await render_template(
template,
context.prepare_for_step(include_remote=True),
await context.prepare_for_step(include_remote=True),
skip_vars=["developer_id"],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async def map_reduce_step(context: StepContext) -> StepOutcome:
assert isinstance(context.current_step, MapReduceStep)

output = await base_evaluate(
context.current_step.over, context.prepare_for_step()
context.current_step.over, await context.prepare_for_step()
)

return StepOutcome(output=output)
Expand Down
10 changes: 1 addition & 9 deletions agents-api/agents_api/activities/task_steps/prompt_step.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
from typing import Callable

from anthropic.types.beta.beta_message import BetaMessage
from beartype import beartype
from langchain_core.tools import BaseTool
from langchain_core.tools.convert import tool as tool_decorator
from litellm.types.utils import ModelResponse
from litellm.types.utils import ModelResponse
from temporalio import activity
from temporalio.exceptions import ApplicationError

from ...autogen.openapi_model import Tool
from ...autogen.openapi_model import Tool
from ...clients import (
litellm, # We dont directly import `acompletion` so we can mock it
Expand All @@ -18,7 +11,6 @@
from ...common.storage_handler import auto_blob_store
from ...common.utils.template import render_template
from ...env import debug
from ..utils import get_handler_with_filtered_params
from .base_evaluate import base_evaluate

COMPUTER_USE_BETA_FLAG = "computer-use-2024-10-22"
Expand Down Expand Up @@ -75,7 +67,7 @@ def format_tool(tool: Tool) -> dict:
async def prompt_step(context: StepContext) -> StepOutcome:
# Get context data
prompt: str | list[dict] = context.current_step.model_dump()["prompt"]
context_data: dict = context.prepare_for_step(include_remote=True)
context_data: dict = await context.prepare_for_step(include_remote=True)

# If the prompt is a string and starts with $_ then we need to evaluate it
should_evaluate_prompt = isinstance(prompt, str) and prompt.startswith(
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/activities/task_steps/return_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def return_step(context: StepContext) -> StepOutcome:
assert isinstance(context.current_step, ReturnStep)

exprs: dict[str, str] = context.current_step.return_
output = await base_evaluate(exprs, context.prepare_for_step())
output = await base_evaluate(exprs, await context.prepare_for_step())

result = StepOutcome(output=output)
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def set_value_step(
try:
expr = override_expr if override_expr is not None else context.current_step.set

values = context.prepare_for_step() | additional_values
values = await context.prepare_for_step() | additional_values
output = simple_eval_dict(expr, values)
result = StepOutcome(output=output)

Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/activities/task_steps/switch_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def switch_step(context: StepContext) -> StepOutcome:
output: int = -1
cases: list[str] = [c.case for c in context.current_step.switch]

evaluator = get_evaluator(names=context.prepare_for_step())
evaluator = get_evaluator(names=await context.prepare_for_step())

for i, case in enumerate(cases):
result = evaluator.eval(case)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def tool_call_step(context: StepContext) -> StepOutcome:
raise ApplicationError(f"Tool {tool_name} not found in the toolset")

arguments = await base_evaluate(
context.current_step.arguments, context.prepare_for_step()
context.current_step.arguments, await context.prepare_for_step()
)

call_id = generate_call_id()
Expand Down
Loading

0 comments on commit 24340ec

Please sign in to comment.