Skip to content

Instantly share code, notes, and snippets.

@ashpreetbedi
Created November 15, 2023 23:41
Show Gist options
  • Save ashpreetbedi/c47fe82daea34c8bca345238a099c160 to your computer and use it in GitHub Desktop.
Save ashpreetbedi/c47fe82daea34c8bca345238a099c160 to your computer and use it in GitHub Desktop.
CSV AI built using OpenAI Assistant API. Checkout https://docs.phidata.com/assistants for more info
import typer
from rich.prompt import Prompt
from phi.assistant import Assistant
from phi.assistant.thread import Thread
from phi.assistant.file.url import UrlFile
from phi.assistant.tool import CodeInterpreter
imdb_movie_data_s3 = UrlFile(
url="https://phi-public.s3.amazonaws.com/imdb/IMDB-Movie-Data.csv"
).get_or_create()
def llm_app():
with Assistant(
name="CsvAI",
tools=[CodeInterpreter],
files=[imdb_movie_data_s3],
instructions="You are an expert at analyzing CSV data. Whenever you run an analysis, explain each step.",
) as csv_ai:
thread = Thread()
while True:
message = Prompt.ask(f"[bold] :sunglasses: User [/bold]")
if message in ("exit", "bye"):
break
thread.print_response(
message=message, assistant=csv_ai, current_message_only=True
)
if __name__ == "__main__":
typer.run(llm_app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment