{"id":14959435,"url":"https://github.com/tomasonjo/llm-movieagent","last_synced_at":"2025-04-09T09:09:50.842Z","repository":{"id":215958412,"uuid":"740001834","full_name":"tomasonjo/llm-movieagent","owner":"tomasonjo","description":"Semantic layer on top of a graph database to provide an LLM with a set of robust tools to interact with the database","archived":false,"fork":false,"pushed_at":"2024-04-25T05:10:00.000Z","size":216,"stargazers_count":226,"open_issues_count":3,"forks_count":40,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-02T08:09:08.129Z","etag":null,"topics":["agent","function-calling","langchain","llm","neo4j","openai","streamlit"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomasonjo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-07T07:55:14.000Z","updated_at":"2025-03-23T06:00:19.000Z","dependencies_parsed_at":"2024-04-01T12:29:27.322Z","dependency_job_id":"558a9d0e-9cb5-4d76-b9c1-5cbe29adc523","html_url":"https://github.com/tomasonjo/llm-movieagent","commit_stats":null,"previous_names":["tomasonjo/llm-movieagent"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasonjo%2Fllm-movieagent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasonjo%2Fllm-movieagent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasonjo%2Fllm-movieagent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasonjo%2Fllm-movieagent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomasonjo","download_url":"https://codeload.github.com/tomasonjo/llm-movieagent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008630,"owners_count":21032556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","function-calling","langchain","llm","neo4j","openai","streamlit"],"created_at":"2024-09-24T13:19:43.517Z","updated_at":"2025-04-09T09:09:50.825Z","avatar_url":"https://github.com/tomasonjo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# llm-movieagent\n\nThis project is designed to implement an agent capable of interacting with a graph database like Neo4j through a semantic layer using OpenAI function calling.\nThe semantic layer equips the agent with a suite of robust tools, allowing it to interact with the graph database based on the user's intent. Read more in the [blog post](https://towardsdatascience.com/enhancing-interaction-between-language-models-and-graph-databases-via-a-semantic-layer-0a78ad3eba49).\n\n![Workflow diagram](https://raw.githubusercontent.com/tomasonjo/llm-movieagent/main/api/packages/neo4j-semantic-layer/static/workflow.png)\n\nTo start the project, run the following command:\n\n```\ndocker-compose up\n```\n\nOpen `http://localhost:8501` in your browser to interact with the agent.\n\n## Tools\n\nThe agent utilizes several tools to interact with the Neo4j graph database effectively:\n\n1. **Information tool**:\n   - Retrieves data about movies or individuals, ensuring the agent has access to the latest and most relevant information.\n2. **Recommendation Tool**:\n   - Provides movie recommendations based upon user preferences and input.\n3. **Memory Tool**:\n   - Stores information about user preferences in the knowledge graph, allowing for a personalized experience over multiple interactions.\n\n## Environment Setup\n\nYou need to define the following environment variables in the `.env` file.\n\n```\nOPENAI_API_KEY=\u003cYOUR_OPENAI_API_KEY\u003e\nNEO4J_URI=\u003cYOUR_NEO4J_URI\u003e\nNEO4J_USERNAME=\u003cYOUR_NEO4J_USERNAME\u003e\nNEO4J_PASSWORD=\u003cYOUR_NEO4J_PASSWORD\u003e\n```\n\n## Docker containers\n\nThis project contains the following services wrapped as docker containers\n\n1. **Neo4j**:\n   - Neo4j, a graph database, is used to store the information about actors, movies, and their ratings.\n2. **API**:\n   - Uses LangChain's `neo4j-semantic-layer` template to implement the OpenAI LLM and function calling capabilities.\n3. **UI**:\n   - Simple streamlit chat user interface. Available on `localhost:8501`.\n\n## Populating with data\n\nIf you want to populate the DB with an example movie dataset, you can run [`ingest.py`](api/ingest.py).\nThe script imports information about movies and their rating by users. \nTo run within the api docker container (recommended) do the following:\n```bash\n# access container shell\ndocker exec -it \u003ccontainer id for llm-movieagent-api\u003e bash\n# run script\npython ingest.py\n```\nAdditionally, the script creates two [fulltext indices](https://neo4j.com/docs/cypher-manual/current/indexes-for-full-text-search/), which are used to map information from user input to the database.\nThe dataset is based on the MovieLens dataset, which is also available as the `Recommendation` project in [Neo4j Sandbox](https://sandbox.neo4j.com/?usecase=recommendations).\n\n## Contributions\n\nContributions are welcomed!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasonjo%2Fllm-movieagent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomasonjo%2Fllm-movieagent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasonjo%2Fllm-movieagent/lists"}