Magentic

Latest version: v0.24.0

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

Scan your dependencies

Page 1 of 7

0.25.0a0

Prerelease for testing PR 214

0.24.0

> [!WARNING]
> The default model for magentic is now gpt-4o instead of gpt-4-turbo. See [Configuration](https://magentic.dev/configuration/) for how to change this.

What's Changed
* docs: update README.md by eltociear in https://github.com/jackmpcollins/magentic/pull/206
* Make GPT-4o the default OpenAI model by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/212
* Skip validation for message serialization by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/213

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

**Full Changelog**: https://github.com/jackmpcollins/magentic/compare/v0.23.0...v0.24.0

0.23.0

What's Changed

- 🦙 Ollama can now return structured outputs / function calls (it takes a little prompting to make it reliable).

python
from magentic import prompt
from magentic.chat_model.litellm_chat_model import LitellmChatModel


prompt(
"Count to {n}. Use the tool to return in the format [1, 2, 3, ...]",
model=LitellmChatModel("ollama_chat/llama2", api_base="http://localhost:11434")
)
def count_to(n: int) -> list[int]: ...


count_to(5)
> [1, 2, 3, 4, 5]


PRs
* poetry update by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/202
* Support ollama structured outputs / function calling by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/204


**Full Changelog**: https://github.com/jackmpcollins/magentic/compare/v0.22.0...v0.23.0

0.22.0

What's Changed

- 🚀 Forced function calling using the new `tool_choice: "required"` argument from OpenAI. This means no more `StructuredOutputError` caused by the model returning a string when it was not in the return annotation (for prompt-functions with a union return type. Single return types were already forced).

PRs

* Use tool_choice required for OpenaiChatModel by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/201
* Bump tqdm from 4.66.2 to 4.66.3 by dependabot in https://github.com/jackmpcollins/magentic/pull/200
* Bump mkdocs from 1.5.3 to 1.6.0 by dependabot in https://github.com/jackmpcollins/magentic/pull/198
* Bump pytest from 8.1.1 to 8.2.0 by dependabot in https://github.com/jackmpcollins/magentic/pull/197
* Bump mypy from 1.9.0 to 1.10.0 by dependabot in https://github.com/jackmpcollins/magentic/pull/196

**Full Changelog**: https://github.com/jackmpcollins/magentic/compare/v0.21.1...v0.22.0

0.21.1

What's Changed
* Remove duplicate chat prompting section from readme by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/193
* Bump ruff from 0.3.0 to 0.4.1 by dependabot in https://github.com/jackmpcollins/magentic/pull/192
* Bump openai from 1.17.1 to 1.23.2 by dependabot in https://github.com/jackmpcollins/magentic/pull/190
* Bump pydantic from 2.6.3 to 2.7.0 by dependabot in https://github.com/jackmpcollins/magentic/pull/191
* Include generated text in error message for "string not expected" by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/195


**Full Changelog**: https://github.com/jackmpcollins/magentic/compare/v0.21.0...v0.21.1

---

The error message for when the model returns a string when not expected now contains the start of the returned string. For example:


StructuredOutputError: String was returned by model but not expected. You may need to update your prompt to encourage the model to return a specific type. Model output: '{ "name": "return_list_of_int", "arguments": { "properties": { "value": { "items": [1, 2, 3], [...]'

0.21.0

What's Changed
* Improve function calling docs by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/186
* Add vision example: renaming screenshots by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/187
* Improve RAG example notebook using GitHub search by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/188
* Add Mistral backend by jackmpcollins in https://github.com/jackmpcollins/magentic/pull/189


**Full Changelog**: https://github.com/jackmpcollins/magentic/compare/v0.20.1...v0.21.0

---

Mistral API now supported natively 🚀

with full support for `StreamedStr`, `ParallelFunctionCall`, etc. Example:

python
from magentic import prompt
from magentic.chat_model.mistral_chat_model import MistralChatModel
from pydantic import BaseModel


class Superhero(BaseModel):
name: str
age: int
power: str
enemies: list[str]


prompt(
"""Create a Superhero named {name}""",
model=MistralChatModel("mistral-large-latest"),
)
def create_superhero(name: str) -> Superhero: ...


create_superhero("Garden Man")
Superhero(name='Garden Man', age=35, power='Plant control', enemies=['Smog', 'Deforestator'])

Page 1 of 7

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.