Simpleaichat

Latest version: v0.2.2

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

Scan your dependencies

0.2.2

* Allow `fd` to take in arbitrary parameters that could be used for `Field` (I have a cool project with this in mind!)
* Use `argparse` for the CLI app 50 (TODO: remove `fire` dependency)
* Pass `str` urls for building `api_url` 52
* Added an assert if using `title` in an input/output schema, since it's a reserved keyword that we're already stripping. Note that this currently only affects the top-level schema.

0.2.1

This release updates simpleaichat to use Pydantic v2.0 and replace all depreciated functions therein. simpleaichat now requires `pydantic>=2.0`. There should be no breaking changes from this migration, but there should be a notable speedboost from the clientside!

Other changes

- Internal Refactoring 19
- API key from `AIChat` constructor has priority over `env` variable, for consistency 22
- `ChatMessage` string returns a stringified dictionary instead of the text only. 29
- A HTTP proxy can be specified by the `https_proxy` environment variable. **This behavior will likely change in an upcoming release** 34

0.2.0

This release supports schema input/output, courtesy of OpenAI's new function calling feature!

Schema

py3
from pydantic import BaseModel, Field

ai = AIChat(
console=False,
save_messages=False, with schema I/O, messages are never saved
model="gpt-3.5-turbo-0613",
params={"temperature": 0.0},
)

class get_event_metadata(BaseModel):
"""Event information"""

description: str = Field(description="Description of event")
city: str = Field(description="City where event occured")
year: int = Field(description="Year when event occured")
month: str = Field(description="Month when event occured")

returns a dict, with keys ordered as in the schema
ai("First iPhone announcement", output_schema=get_event_metadata)


txt
{'description': 'The first iPhone was announced by Apple Inc.',
'city': 'San Francisco',
'year': 2007,
'month': 'January'}


There's a lot you can do with it, and this implementation is just the beginning.

Notes:
- In all cases, no messages are saved when using schema to prevent unintended behavior. You will have to manage the intermediate output yourself for the time being, if you want to chain inputs.
- Input and Output schema works for normal generation, both sync and async.
- For streaming, only input schema will work, as streaming output structured data would not play nice.
- Neither is currently supported for working with tools; that still needs further testing.

Other changes:

- A session context manager was added (7) for cases where you want to script a temporary conversation, in both sync and async flavors.
- The `finish_reason` is saved from ChatGPT outputs (14)
- You can now pass an `output_path` to `save_session()`.

0.1.1

Fix missing dependency 1

0.1.0

0.0.1

Initial testing release (to reserve the name on PyPI and test on Colab)

Links

Releases

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.