Skip to main content

YORG Test Package

this is a test package

test version

how to use

  • Set up test version package
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple yorg-test
  • Set up openapikey (If you are in China, please set up a proxy to ensure that you can connect to openai.)
import os
#os.environ['http_proxy'] = 'http://127.0.0.1:10809'  # 这里设置自己的代理端口号
#os.environ['https_proxy'] = 'http://127.0.0.1:10809'  # 这里设置自己的代理端口号
os.environ['OPENAI_CHAT_API_KEY'] = 'sk-br3j7Gxxxxxxxxvt8r'
  • set up yaml file We have some tools built in eg.code_interpreter,swe_tool

tools.yaml

YORG: 0.0.1
info:
  title: yorg_tools_document
  description: yorg tool define document.
  version: 'v1'
tools:
  code_interpreter:
    name: code_interpreter
    entity_name: code_interpreter
    summary: Run the code through code_interpreter and return the result of the code run. If your query is about math, computer science, or data science, you can use this tool to get the result of the code run.
    parameters:
      - name: code
        description: code text that requires code_interpreter to run
        required: true
        parameter_schema:
          type: string
    responses:
      success:
        description: OK
        content:
          result:
            type: string
            description: the result of the code run
  example_stateful_tool:
    name: example_stateful_tool
    entity_name: example_stateful_tool
    summary: This tool is an example of a stateful tool. It will get two number from user input and return the sum of the two numbers.
    parameters: []
    responses: {}  
  swe_tool:
    name: sew_tool
    entity_name: swe_tool
    summary: SoftWare Engineer Agent(swe_tool) specializes in working with code files.
    parameters: []
    responses: {}  

Tools are categorized into stateful tools and function tools, Function tools can describe parameters and return values directly in tools.yaml Functions can be registered using decorators

from yorg_test.core.assistant.tools.tools import register_function_tool
@register_function_tool
def code_test(code: str):
    return {
        "type": "success",
        "content": {
            "result": "Hello, World!",
        },
    }

If it's a stateful tool you need to write an additional yaml file with a stateful description

start_stage: "init"
finish_stage: "finish"
all_stages:
  init:
    name: "init"
    next_stage_entry: 
      stage_1:
        - name: x
          required: true
          parameter_schema:
            type: number
            description: "input value x"
    need_llm_generate_parameters: false
    need_llm_generate_response: false
  stage_1:
    name: "stage_1"
    next_stage_entry: 
      stage_2:
        - name: y 
          required: true
          parameter_schema:
            type: number
            description: "input value y"
    need_llm_generate_parameters: false 
    need_llm_generate_response: false
  stage_2:
    name: "stage_2"
    next_stage_entry: 
      stage_3: []
    need_llm_generate_parameters: false
    need_llm_generate_response: false
  stage_3:
    name: "stage_3"
    next_stage_entry: 
      finish: []
    need_llm_generate_parameters: false
    need_llm_generate_response: false
  finish:
    name: "finish"
    next_stage_entry: {}
    need_llm_generate_parameters: false
    need_llm_generate_response: false

Stateful tools can also be registered using decorators. The yaml file is registered in init.

from yorg_test.core.assistant.tools.tools import register_stateful_tool
from yorg_test.core.assistant.tools.stateful_tool_entity import StatefulToolEntity
@register_stateful_tool
class ExampleStatefulToolEntity(StatefulToolEntity):
    """
    This example tool entity is stateful, and it has 3 inner stages.

    stage1: take integer x as input
    stage2: take integer y as input
    stage3: no input, return x + y
    """
    def __init__(self):
        super().__init__("example_stateful_tool.yaml")
    def _call(self, **kwargs):
        if "goto" not in kwargs:
            if self.current_stage.name == self.config.start_stage:
                return {
                    "type": "success",
                    "content": {"message": "stateful tool is started"},
                }
            else:
                return {
                    "type": "error",
                    "content": {"message": "please provide `goto` parameter"},
                }
        request_next_stage = kwargs["goto"]
        if request_next_stage not in self.config.all_stages:
            return {
                "type": "error",
                "content": {"message": f"stage {request_next_stage} not found"},
            }
        self.current_stage = self.config.all_stages[request_next_stage]
        match self.current_stage.name:
            case "stage_1":
                return self._stage1(kwargs["x"])
            case "stage_2":
                return self._stage2(kwargs["y"])
            case "stage_3":
                return self._stage3()
            case self.config.finish_stage:
                return self._finish()
            case _:
                return {
                    "type": "error",
                    "content": {
                        "message": f"stage {self.current_stage.name} not found"
                    },
                }
    def _stage1(self, x: int):
        self.x = x
        return {"type": "success", "content": {"message": "stage1 done"}}
    def _stage2(self, y: int):
        self.y = y
        return {"type": "success", "content": {"message": "stage2 done"}}
    def _stage3(self):
        return {"type": "success", "content": {"result": self.x + self.y}}
    def _finish(self):
        return {"type": "success", "content": {"message": "stateful tool is finished"}}
  • run example
import yorg_test
threads = yorg_test.Threads.create('tools.yaml')
assistant = yorg_test.Assistants.create(name="Test Assistant", model="gpt-4-1106-preview", instructions="Use swe tool auto fix code files", tools=[{'type':'swe_tool'}])
print(assistant.id)
# 运行 Threads 对象
result = threads.run(assistant.id, "Use SoftWare Engineer Agent swe tool auto fix code files.")
print(result)

result = threads.run(assistant.id, "the repo url is https://github.com/YORG-AI/Open-Assistant",goto="stage_1")
print(result)

result = threads.run(assistant.id, "add helloworld feature to readme",  goto="stage_2")
print(result)

result = threads.run(assistant.id, "focus_files_name_list = [README.md]", goto="stage_3")
print(result)

result = threads.run(assistant.id, "action=3", goto="stage_4")
print(result)

result = threads.run(assistant.id, "", goto="stage_5")
print(result)

result = threads.run(assistant.id, "action=0,action_idx=0", goto="stage_6")
print(result)

result = threads.run(assistant.id, "", goto="finish")
print(result)

Metadata

Release files for phireact 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for phireact 0.0.1
File Size Uploaded
phireact-0.0.1.tar.gz 50.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for phireact 0.0.1
File Interpreter ABI Platform
phireact-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 124.5 kB

Release files / phireact-0.0.1.tar.gz

Download URL phireact-0.0.1.tar.gz
Size 50.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d7ce3a153f317abe7d26a54dd328ff5c4f171e0e7ca3dafed63d92487c2e9f58
BLAKE2b-256 checksum
How to use checksums
a0f7110901c22c0f40262b5f3f4f1a372ead4fd3d313b863eb6a98e815b937f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / phireact-0.0.1-py3-none-any.whl

Download URL phireact-0.0.1-py3-none-any.whl
Size 74.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55e0975a63128df7b2486da9e696c77e37897a3f19bf0960913d64588a1fb369
BLAKE2b-256 checksum
How to use checksums
7345614000abf87b71e2fb963429e100d38b59771c878661bfca5c6df97b2d08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page