{"id":13940810,"url":"https://github.com/Yusuke710/nanoPerplexityAI","last_synced_at":"2025-07-20T04:30:41.735Z","repository":{"id":248256646,"uuid":"822985320","full_name":"Yusuke710/nanoPerplexityAI","owner":"Yusuke710","description":"The simplest open-source implementation of perplexity.ai","archived":false,"fork":false,"pushed_at":"2025-01-24T11:25:25.000Z","size":7528,"stargazers_count":284,"open_issues_count":1,"forks_count":24,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-24T12:25:32.427Z","etag":null,"topics":["ai-search-engine","large-language-models","nanoperplexityai","open-source-perplexity-ai","perplexity-ai","search-engine","searchgpt"],"latest_commit_sha":null,"homepage":"https://youtu.be/8zBDTnSYSoc?si=WVepg1koE2APzUCu","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/Yusuke710.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"publiccode":null,"codemeta":null}},"created_at":"2024-07-02T07:59:24.000Z","updated_at":"2025-01-24T11:39:24.000Z","dependencies_parsed_at":"2024-11-27T10:40:37.705Z","dependency_job_id":null,"html_url":"https://github.com/Yusuke710/nanoPerplexityAI","commit_stats":null,"previous_names":["yusuke710/nanoperplexityai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Yusuke710/nanoPerplexityAI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yusuke710%2FnanoPerplexityAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yusuke710%2FnanoPerplexityAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yusuke710%2FnanoPerplexityAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yusuke710%2FnanoPerplexityAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yusuke710","download_url":"https://codeload.github.com/Yusuke710/nanoPerplexityAI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yusuke710%2FnanoPerplexityAI/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266067254,"owners_count":23871324,"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":["ai-search-engine","large-language-models","nanoperplexityai","open-source-perplexity-ai","perplexity-ai","search-engine","searchgpt"],"created_at":"2024-08-08T02:00:55.932Z","updated_at":"2025-07-20T04:30:40.873Z","avatar_url":"https://github.com/Yusuke710.png","language":"Python","funding_links":[],"categories":["Python","A01_文本生成_文本对话","搜索 Search"],"sub_categories":["大语言对话模型及数据"],"readme":"# nanoPerplexityAI\n\nThe simplest and most intuitive open-source implementation of an open source [perplexity.ai](https://www.perplexity.ai/), a large language model(LLM) service which cites information from Google. **No fancy GUI or LLM agents** are involved, just **200 lines of python code**. Please check out [this video](https://youtu.be/8zBDTnSYSoc) for more explanations!\n\nCheck out the [conversations](/example_outputs/) nanoPerplexityAI has generated \n\n![overview](/assets/example_response.png)\n\n## Architecture\n\n1. Get the user query\n2. LLM checks the user query, decides whether to execute a Google search, and if searching, reformulates the user query into a Google-suited query to find relevant webpage URLs and fetch texts. (In practice, [PerplexityAI searches its already indexed sources](https://www.perplexity.ai/hub/faq/how-does-perplexity-work))\n3. Build a prompt using `system prompt + webpage context + user query`\n4. Call the LLM API to generate an answer\n5. As LLM perform stream completion, save the LLM response into a markdown file for better visualization. \n\n#PerplexityAI does not reformat the search results and therefore not all search results are used and cited in the LLM response. This is because they prioritize displaying search results quickly and streaming LLM completion for a better user experience.\n\n## Install\n```\npip install googlesearch-python requests beautifulsoup4 lxml backoff openai \n```\n\n## Quick Start\n```\nexport OPENAI_API_KEY=\u003cYour OpenAI API KEY\u003e\npython nanoPerplexityAI.py\n```\n\nThe script will prompt you to type your question, then it will generate an answer in `playground.md`\nYou can type a key s for [s]ave and q for [q]uit\n\n## View Real Time Generation\nYou can utilise Visual Studio Code to replicate the simpler version of PerplexityAI GUI. Open Preview of `playground.md` as you run `python nanoPerplexityAI.py` and you will see the real time generation!\n\n### DEMO\n\n![Gid](/assets/demo.gif)\n\nOther ways involve opening in [Markdown Playground](https://dotmd-editor.vercel.app/) or pushing the output markdown files to your github repo for displaying markdown\n\n\n## Acknowledgements\nThank you [perplexity.ai](https://www.perplexity.ai/) for the amazing idea and [clarity-ai](https://github.com/mckaywrigley/clarity-ai) and [Perplexica](https://github.com/ItzCrazyKns/Perplexica) for coding inspirations on the open-source implementation of perplexity.ai. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYusuke710%2FnanoPerplexityAI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FYusuke710%2FnanoPerplexityAI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYusuke710%2FnanoPerplexityAI/lists"}