Installation#
pip install taskgen-ai
Sponsors#
Taskgen is a community-driven open-source initiative that thrives on the generous contributions of our sponsors, enabling us to pursue innovative developments.
A huge thank you to our current sponsors:
We invite organizations and individuals to join our sponsorship program. By becoming a sponsor, you can play a pivotal role in our project’s growth.
Minimal Example#
At a minimum, make sure you have installed taskgen-ai.
First, create a file named app.py with the following contents:
# Set up API key and do the necessary imports
from taskgen import *
import os
# this is only if you use OpenAI as your LLM
os.environ['OPENAI_API_KEY'] = '<YOUR API KEY HERE>'
def llm(system_prompt: str, user_prompt: str) -> str:
''' Here, we use OpenAI for illustration, you can change it to your own LLM '''
# ensure your LLM imports are all within this function
from openai import OpenAI
# define your own LLM here
client = OpenAI()
response = client.chat.completions.create(
model='gpt-4o-mini',
temperature = 0,
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
]
)
return response.choices[0].message.content
# Verify that llm function is working
llm(system_prompt = 'You are a classifier to classify the sentiment of a sentence',
user_prompt = 'It is a beautiful and sunny day')
Then, run the following command:
python app.py
Now you can see your output in the terminal.
Positive