Magentic

Latest version: v0.32.0

Safety actively analyzes 682416 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 8 of 10

0.7.1

What's Changed
* Bump urllib3 from 2.0.4 to 2.0.6 by dependabot in https://github.com/jackmpcollins/magentic/pull/36
* add optional max_calls argument to prompt_chain by pachacamac in https://github.com/jackmpcollins/magentic/pull/39
* Add instructions for setting OPENAI_API_BASE by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/40

New Contributors
* pachacamac made their first contribution in https://github.com/jackmpcollins/magentic/pull/39

**Full Changelog**: https://github.com/jackmpcollins/magentic/compare/v0.7.0...v0.7.1

0.7.0

What's Changed
* Add Asyncio section to README by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/28
* Add chatprompt decorator by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/34
* Make openai tests less flaky by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/35


**Full Changelog**: https://github.com/jackmpcollins/magentic/compare/v0.6.0...v0.7.0

---

Chat Prompting

The `chatprompt` decorator works just like `prompt` but allows you to pass chat messages as a template rather than a single text prompt. This can be used to provide a system message or for few-shot prompting where you provide example responses to guide the model's output. Format fields denoted by curly braces `{example}` will be filled in all messages - use the `escape_braces` function to prevent a string being used as a template.

python
from magentic import chatprompt, AssistantMessage, SystemMessage, UserMessage
from magentic.chatprompt import escape_braces

from pydantic import BaseModel


class Quote(BaseModel):
quote: str
character: str


chatprompt(
SystemMessage("You are a movie buff."),
UserMessage("What is your favorite quote from Harry Potter?"),
AssistantMessage(
Quote(
quote="It does not do to dwell on dreams and forget to live.",
character="Albus Dumbledore",
)
),
UserMessage("What is your favorite quote from {movie}?"),
)
def get_movie_quote(movie: str) -> Quote:
...


get_movie_quote("Iron Man")
Quote(quote='I am Iron Man.', character='Tony Stark')

0.6.0

What's Changed
* Move function schemas into own file by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/18
* Bump certifi from 2023.5.7 to 2023.7.22 by dependabot in https://github.com/jackmpcollins/magentic/pull/21
* Bump jupyter-server from 2.7.0 to 2.7.2 by dependabot in https://github.com/jackmpcollins/magentic/pull/20
* Bump tornado from 6.3.2 to 6.3.3 by dependabot in https://github.com/jackmpcollins/magentic/pull/19
* Add example notebook for Chain of Verification by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/22
* Handle Iterable type with no item type by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/24
* Handle BaseModel parameters in functions by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/23
* Make AsyncIterableFunctionSchema.serialize_args raise NotImplementedError by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/25
* Rename chat_model files by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/26

New Contributors
* dependabot made their first contribution in https://github.com/jackmpcollins/magentic/pull/21

**Full Changelog**: https://github.com/jackmpcollins/magentic/compare/v0.5.0...v0.6.0

0.5.0

What's Changed
* Add docstrings where useful by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/14
* Enable async prompt_chain. Remove FunctionCallMessage by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/17


**Full Changelog**: https://github.com/jackmpcollins/magentic/compare/v0.4.1...v0.5.0

---

python
from magentic import prompt_chain


async def get_current_weather(location, unit="fahrenheit"):
"""Get the current weather in a given location"""
return {
"location": location,
"temperature": "72",
"unit": unit,
"forecast": ["sunny", "windy"],
}


prompt_chain(
template="What's the weather like in {city}?",
functions=[get_current_weather],
)
async def describe_weather(city: str) -> str:
...


output = await describe_weather("Boston")

0.4.1

What's Changed
* Add GitHub actions workflow to run unit-tests by manuelzander in https://github.com/jackmpcollins/magentic/pull/1
* Enable more linting rules with Ruff. Update pre-commit hooks by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/13

New Contributors
* manuelzander made their first contribution in https://github.com/jackmpcollins/magentic/pull/1

**Full Changelog**: https://github.com/jackmpcollins/magentic/compare/v0.4.0...v0.4.1

0.4.0

What's Changed
* Use pydantic models for OpenAI inputs/outputs by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/9
* Fix object streaming example in README by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/10
* Add test for async/coroutine function with FunctionCall by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/11
* Support setting OpenAI params using environment variables by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/12


**Full Changelog**: https://github.com/jackmpcollins/magentic/compare/v0.3.0...v0.4.0

---

Configuration

The order of precedence of configuration is

1. Arguments passed when initializing an instance in Python
2. Environment variables

The following environment variables can be set.

| Environment Variable | Description |
| --------------------------- | ------------------------- |
| MAGENTIC_OPENAI_MODEL | OpenAI model e.g. "gpt-4" |
| MAGENTIC_OPENAI_TEMPERATURE | OpenAI temperature, float |

Page 8 of 10

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.