A library for 'gemini' models without unnecessary dependencies.
Project description
castor-pollux
Castor-Pollux (the twin sons of Zeus, routinely called 'gemini') is a pure REST API library for interacting with Google Generative AI API.
Without (!!!):
- any whiff of 'Vertex' or GCP;
- any signs of 'Pydantic' or unnecessary (and mostly useless) typing;
- any other dependencies of other google packages trashed into the dumpster
google-genaipackage.
Installation:
pip install castor-pollux
Then:
# Python
import castor_pollux.rest as cp
A text continuation request:
import castor_pollux.rest as cp
from yaml import safe_load as yl
from yaml import safe_dump as yd
from yaml import YAMLError as ERR
kwargs = """ # this is a string in YAML format
model: gemini-2.5-pro-exp-03-25 # thingking model
# system_instruction: '' # will prevail if put here
mime_type: text/plain #
modalities:
- TEXT # text for text
max_tokens: 10000
n: 2 # 1 is not mandatory
stop_sequences:
- STOP
- "\nTitle"
temperature: 0.5 # 0 to 1.0
top_k: 10 # number of tokens to consider.
top_p: 0.5 # 0 to 1.0
thinking: 24576 # thinking tokens budget.
"""
instruction = 'You are Joseph Jacobs, you retell folk tales.'
text_to_continue = 'Once upon a time, when pigs drank wine '
machine_responses = cp.continuation(
text=text_to_continue,
instruction=instruction,
**yl(kwargs)
)
file_name = 'yaml_test.yaml'
with open(file_name, "w") as stream:
try:
yd(machine_responses, stream)
except ERR as exc:
print(exc)
# texts = yd(machine_responses)
with open(file_name, 'r') as stream:
try:
texts = yl(stream)
except ERR as exc:
print(exc)
A multi-turn conversation continuation request:
import castor_pollux.rest as cp
from yaml import safe_load as yl
from yaml import safe_dump as yd
from yaml import YAMLError as ERR
kwargs = """ # this is a string in YAML format
model: gemini-2.5-pro-exp-03-25
system: Always answer concisely
max_tokens: 5
stop_sequences:
- stop
- "\n\n\nHuman:"
stream: False
"""
previous_turns = """
- role: human # not the idiotic 'user', God forbid.
text: Can we change human nature?
- role: machine # not the idiotic 'model'
text: Of course, nothing can be simpler. You just re-educate them.
"""
human_response_to_the_previous_turn = 'That is not true. Think again.'
instruction = 'I am an expert in critical thinking. I analyse.'
machine_responses = cp.continuation(
text=human_response_to_the_previous_turn,
contents=yl(previous_turns),
instruction=instruction,
**yl(kwargs)
)
file_name = 'yaml_test.yaml'
with open(file_name, "w") as stream:
try:
yd(machine_responses, stream)
except ERR as exc:
print(exc)
# texts = yd(machine_responses)
with open(file_name, 'r') as stream:
try:
texts = yl(stream)
except ERR as exc:
print(exc)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
castor_pollux-0.0.8.tar.gz
(8.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file castor_pollux-0.0.8.tar.gz.
File metadata
- Download URL: castor_pollux-0.0.8.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54c80597b51976379f8bc3fb572a1bc1530341fc9d4ba3fd247f5292d5f93a2f
|
|
| MD5 |
7e7be5b64f104a82d9e0dc5868b9f6d2
|
|
| BLAKE2b-256 |
115325f7cd00c3c85bfe92ae4119b7c1f95ff62d5d062cee6e818c593fb803f9
|
File details
Details for the file castor_pollux-0.0.8-py3-none-any.whl.
File metadata
- Download URL: castor_pollux-0.0.8-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
673173675fecdf5023939cde1d40f4be9d3a15d5fbbd4dd875de1e80c83c6a13
|
|
| MD5 |
34d2eed17d3e41a1cd32344ccff213ff
|
|
| BLAKE2b-256 |
8f46441bc7071a8d1754ba0e4f0cfd354c7d8903f6ab50d4d6d3e0a50cf7f102
|