Build AI Assistants Fast
Project description
CyberChipped
Introduction
CyberChipped powers the best AI Companion - CometHeart!
In a few lines of code build a conversational AI Assistant!
Install
pip install cyberchipped
OpenAI Assistant
Audio Conversation
from cyberchipped.ai import SQLiteDatabase, AI
from fastapi import UploadFile, File
from fastapi.responses import StreamingResponse
import os
database = SQLiteDatabase("sqlite.db")
@app.post("/conversation/{user_id}")
async def conversation_endpoint(user_id: str, audio_file: UploadFile = File(...)):
async with AI(
api_key=os.getenv("OPENAI_API_KEY"),
name="CometHeart AI Simple",
instructions="You are CometHeart an AI voice assistant - you answer questions and help with tasks. You keep your responses brief and tailor them for speech.",
database=database
) as ai:
ai.add_tool
async def get_current_temperature(location: str, unit: str) -> Dict[str, Any]:
"""Get the current temperature for a specific location"""
return {"temperature": 22, "unit": unit, "location": location}
audio_generator = await ai.conversation(user_id, audio_file)
return StreamingResponse(
content=audio_generator,
media_type="audio/x-aac",
)
Text Conversation
from cyberchipped.ai import SQLiteDatabase, AI
from fastapi import UploadFile, File
from fastapi.responses import StreamingResponse
import os
from pydantic import BaseClass
database = SQLiteDatabase("sqlite.db")
class Text(BaseClass):
text: str
@app.post("/conversation/{user_id}")
async def conversation_endpoint(user_id: str, text: Text, audio_file: UploadFile = File(...)):
async with AI(
api_key=os.getenv("OPENAI_API_KEY"),
name="CometHeart AI Simple",
instructions="You are CometHeart an AI voice assistant - you answer questions and help with tasks. You keep your responses brief and tailor them for speech.",
database=database
) as ai:
ai.add_tool
async def get_current_temperature(location: str, unit: str) -> Dict[str, Any]:
"""Get the current temperature for a specific location"""
return {"temperature": 22, "unit": unit, "location": location}
text_generator = await ai.text(user_id, text.text)
return text_generator
Run Tests
poetry run pytest
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
cyberchipped-1.2.0.tar.gz
(5.3 kB
view hashes)
Built Distribution
Close
Hashes for cyberchipped-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f727f776afb773b6a1c4a542cff416910e498b8b0523c176b5615cdd895ea605 |
|
MD5 | 3e487da1d8ab0d25920645f0c7eb171c |
|
BLAKE2b-256 | 1ed1059e9df3d1ea04f7d52afb52be54a5a3e339134ddad13fa8a4c86413b7e5 |