Easily connect large language models into your application
Project description
llmio
Easily connect large language models into your application
llmio uses type hints to enable function execution with OpenAIs API.
Setup
pip install llmio
Example
import asyncio
import openai
from llmio import Assistant
assistant = Assistant(
instruction="""
You are a calculating assistant.
Always use commands to calculate things.
Never try to calculate things on your own.
""",
client=openai.AsyncOpenAI(api_key=os.environ["OPENAI_TOKEN"]),
model="gpt-4o-mini",
)
@assistant.command()
async def add(num1: float, num2: float) -> float:
"""
Add two numbers
"""
print(f"Adding {num1} + {num2}")
return num1 + num2
@assistant.command()
async def multiply(num1: float, num2: float) -> float:
"""
Multiply two numbers
"""
print(f"Multiplying {num1} * {num2}")
return num1 * num2
async def main():
history = []
async for reply, history in assistant.speak(input(">>"), history):
print(reply)
if __name__ == "__main__":
asyncio.run(main())
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
llmio-0.3.0.tar.gz
(4.8 kB
view hashes)
Built Distribution
llmio-0.3.0-py3-none-any.whl
(5.5 kB
view hashes)