weavel


Nameweavel JSON
Version 1.11.0 PyPI version JSON
download
home_pagehttps://github.com/weavel-ai/weavel-python
SummaryWeavel, automated prompt engineering and observability for LLM applications
upload_time2024-10-05 11:11:49
maintainerNone
docs_urlNone
authorweavel
requires_python>=3.8.10
licenseNone
keywords weavel agent llm evaluation llm evaluation prompt evaluation dataset curation prompt engineering prompt optimization ai prompt engineer
VCS
bugtrack_url
requirements httpx pydantic typer pendulum requests cryptography pyyaml InquirerPy python-dotenv websockets termcolor watchdog readerwriterlock pytest pytest-asyncio pytest-mock pytest-cov nest_asyncio tenacity
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
    <a href="https://www.weavel.ai">
        <img src="https://i.imgur.com/uQ7ulX3.png" title="Logo" style="" />
    </a>
    <h1>Weavel Python SDK</h1>
    <h3>Prompt Optimization & Evaluation for LLM Applications</h3>
    <div>
        <a href="https://pypi.org/project/weavel" target="_blank">
            <img src="https://img.shields.io/pypi/v/weavel.svg" alt="PyPI Version"/>
        </a>
    </div>
</div>

## Installation

```bash
pip install weavel
```

## Documentation

You can find our full documentation [here](https://weavel.ai/docs/python-sdk).

## How to use

### Option 1: Using OpenAI wrapper

```python
from weavel import WeavelOpenAI as OpenAI

openai = OpenAI()

response = openai.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "user", "content": "Hello, world!"}
    ],
    headers={
      "generation_name": "hello",
    }
)

```

### Option 2: Logging inputs/outputs of LLM calls

```python
from weavel import Weavel
from openai import OpenAI
from pydantic import BaseModel

openai = OpenAI()
# initialize Weavel
weavel = Weavel()

class Answer(BaseModel):
    reasoning: str
    answer: str

question = "What is x if x + 2 = 4?"
response = openai.beta.chat.completions.parse(
    model="gpt-4o-2024-08-06",
    messages=[
        {"role": "system", "content": "You are a math teacher."},
        {"role": "user", "content": question}
    ],
    response_format=Answer
).choices[0].message.parsed

# log the generation
weavel.generation(
    name="solve-math", # optional
    inputs={"question": question},
    outputs=response.model_dump()
)
```

### Option 3 (Advanced Usage): OTEL-compatible trace logging

```python
from weavel import Weavel

weavel = Weavel()

session = weavel.session(user_id = "UNIQUE_USER_ID")

session.message(
    role="user",
    content="Nice to meet you!"
)

session.track(
    name="Main Page Viewed"
)

trace = session.trace(
    name="retrieval_module"
)

trace.log(
    name="google_search"
)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/weavel-ai/weavel-python",
    "name": "weavel",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8.10",
    "maintainer_email": null,
    "keywords": "weavel, agent, llm, evaluation, llm evaluation, prompt evaluation, dataset curation, prompt engineering, prompt optimization, AI Prompt Engineer",
    "author": "weavel",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d6/dc/c9da0be2ab39a74fc7e95d9c6520ff18c48eb21a4d59d45afd5e702b29d1/weavel-1.11.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n    <a href=\"https://www.weavel.ai\">\n        <img src=\"https://i.imgur.com/uQ7ulX3.png\" title=\"Logo\" style=\"\" />\n    </a>\n    <h1>Weavel Python SDK</h1>\n    <h3>Prompt Optimization & Evaluation for LLM Applications</h3>\n    <div>\n        <a href=\"https://pypi.org/project/weavel\" target=\"_blank\">\n            <img src=\"https://img.shields.io/pypi/v/weavel.svg\" alt=\"PyPI Version\"/>\n        </a>\n    </div>\n</div>\n\n## Installation\n\n```bash\npip install weavel\n```\n\n## Documentation\n\nYou can find our full documentation [here](https://weavel.ai/docs/python-sdk).\n\n## How to use\n\n### Option 1: Using OpenAI wrapper\n\n```python\nfrom weavel import WeavelOpenAI as OpenAI\n\nopenai = OpenAI()\n\nresponse = openai.chat.completions.create(\n    model=\"gpt-4o\",\n    messages=[\n        {\"role\": \"user\", \"content\": \"Hello, world!\"}\n    ],\n    headers={\n      \"generation_name\": \"hello\",\n    }\n)\n\n```\n\n### Option 2: Logging inputs/outputs of LLM calls\n\n```python\nfrom weavel import Weavel\nfrom openai import OpenAI\nfrom pydantic import BaseModel\n\nopenai = OpenAI()\n# initialize Weavel\nweavel = Weavel()\n\nclass Answer(BaseModel):\n    reasoning: str\n    answer: str\n\nquestion = \"What is x if x + 2 = 4?\"\nresponse = openai.beta.chat.completions.parse(\n    model=\"gpt-4o-2024-08-06\",\n    messages=[\n        {\"role\": \"system\", \"content\": \"You are a math teacher.\"},\n        {\"role\": \"user\", \"content\": question}\n    ],\n    response_format=Answer\n).choices[0].message.parsed\n\n# log the generation\nweavel.generation(\n    name=\"solve-math\", # optional\n    inputs={\"question\": question},\n    outputs=response.model_dump()\n)\n```\n\n### Option 3 (Advanced Usage): OTEL-compatible trace logging\n\n```python\nfrom weavel import Weavel\n\nweavel = Weavel()\n\nsession = weavel.session(user_id = \"UNIQUE_USER_ID\")\n\nsession.message(\n    role=\"user\",\n    content=\"Nice to meet you!\"\n)\n\nsession.track(\n    name=\"Main Page Viewed\"\n)\n\ntrace = session.trace(\n    name=\"retrieval_module\"\n)\n\ntrace.log(\n    name=\"google_search\"\n)\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Weavel, automated prompt engineering and observability for LLM applications",
    "version": "1.11.0",
    "project_urls": {
        "Homepage": "https://github.com/weavel-ai/weavel-python"
    },
    "split_keywords": [
        "weavel",
        " agent",
        " llm",
        " evaluation",
        " llm evaluation",
        " prompt evaluation",
        " dataset curation",
        " prompt engineering",
        " prompt optimization",
        " ai prompt engineer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d95677881b451e9ad509c1645eb294cb406df95c554e7a154096ad65984710dc",
                "md5": "7b024d1a6e0c89acd3d25b378789e7ab",
                "sha256": "a048c28136e0f3bd65de264097c955c76180c2fd072fb662dd1a21f64514b54d"
            },
            "downloads": -1,
            "filename": "weavel-1.11.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7b024d1a6e0c89acd3d25b378789e7ab",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.10",
            "size": 32696,
            "upload_time": "2024-10-05T11:11:47",
            "upload_time_iso_8601": "2024-10-05T11:11:47.656262Z",
            "url": "https://files.pythonhosted.org/packages/d9/56/77881b451e9ad509c1645eb294cb406df95c554e7a154096ad65984710dc/weavel-1.11.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d6dcc9da0be2ab39a74fc7e95d9c6520ff18c48eb21a4d59d45afd5e702b29d1",
                "md5": "efd959b7f82bd617a4a9d9d87e30ac50",
                "sha256": "3d9373506a3486ffe54f5ece5813f19a1c37bd7297a7d2e10803da6852a8483c"
            },
            "downloads": -1,
            "filename": "weavel-1.11.0.tar.gz",
            "has_sig": false,
            "md5_digest": "efd959b7f82bd617a4a9d9d87e30ac50",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.10",
            "size": 28041,
            "upload_time": "2024-10-05T11:11:49",
            "upload_time_iso_8601": "2024-10-05T11:11:49.702875Z",
            "url": "https://files.pythonhosted.org/packages/d6/dc/c9da0be2ab39a74fc7e95d9c6520ff18c48eb21a4d59d45afd5e702b29d1/weavel-1.11.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-05 11:11:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "weavel-ai",
    "github_project": "weavel-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "httpx",
            "specs": []
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    ">=",
                    "2.4.2"
                ]
            ]
        },
        {
            "name": "typer",
            "specs": []
        },
        {
            "name": "pendulum",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "cryptography",
            "specs": []
        },
        {
            "name": "pyyaml",
            "specs": []
        },
        {
            "name": "InquirerPy",
            "specs": []
        },
        {
            "name": "python-dotenv",
            "specs": []
        },
        {
            "name": "websockets",
            "specs": [
                [
                    "==",
                    "10.4"
                ]
            ]
        },
        {
            "name": "termcolor",
            "specs": []
        },
        {
            "name": "watchdog",
            "specs": []
        },
        {
            "name": "readerwriterlock",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "pytest-asyncio",
            "specs": []
        },
        {
            "name": "pytest-mock",
            "specs": []
        },
        {
            "name": "pytest-cov",
            "specs": []
        },
        {
            "name": "nest_asyncio",
            "specs": []
        },
        {
            "name": "tenacity",
            "specs": []
        }
    ],
    "lcname": "weavel"
}
        
Elapsed time: 0.46736s