{"id":28233640,"url":"https://github.com/justcodeit7/github_repo_chat","last_synced_at":"2025-10-08T15:15:56.823Z","repository":{"id":286041145,"uuid":"960168420","full_name":"JustCodeIt7/GitHub_Repo_Chat","owner":"JustCodeIt7","description":"Allows you to chat with a GitHub Repo using Streamlit, LangChain, and Ollama","archived":false,"fork":false,"pushed_at":"2025-08-22T12:46:06.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-22T14:42:28.640Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JustCodeIt7.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-04T01:09:44.000Z","updated_at":"2025-08-22T12:46:10.000Z","dependencies_parsed_at":"2025-04-04T02:24:01.065Z","dependency_job_id":"1c82825c-f925-4c87-8393-224eb83addbb","html_url":"https://github.com/JustCodeIt7/GitHub_Repo_Chat","commit_stats":null,"previous_names":["justcodeit7/github_repo_chat"],"tags_count":0,"template":false,"template_full_name":"JustCodeIt7/Python_Template","purl":"pkg:github/JustCodeIt7/GitHub_Repo_Chat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustCodeIt7%2FGitHub_Repo_Chat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustCodeIt7%2FGitHub_Repo_Chat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustCodeIt7%2FGitHub_Repo_Chat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustCodeIt7%2FGitHub_Repo_Chat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JustCodeIt7","download_url":"https://codeload.github.com/JustCodeIt7/GitHub_Repo_Chat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustCodeIt7%2FGitHub_Repo_Chat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278965553,"owners_count":26076924,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-05-18T21:10:25.209Z","updated_at":"2025-10-08T15:15:56.788Z","avatar_url":"https://github.com/JustCodeIt7.png","language":"Python","readme":"# GitHub Repo Chatbot with PydanticAI \u0026 Ollama\n\nA Streamlit application that lets you chat with the contents of any GitHub repository. It uses FAISS for vector storage, Ollama for embeddings and language model, and PydanticAI as the agent framework to handle retrieval and question-answering.\n\n---\n\n## Table of Contents\n\n* [Features](#features)\n* [Demo](#demo)\n* [Prerequisites](#prerequisites)\n* [Installation](#installation)\n* [Configuration](#configuration)\n* [Usage](#usage)\n* [Project Structure](#project-structure)\n* [How It Works](#how-it-works)\n* [Customization](#customization)\n* [Contributing](#contributing)\n* [License](#license)\n\n---\n\n## Features\n\n* **GitHub Repo Cloning**: Clone any public GitHub repository and extract text from code and documentation files.\n* **Text Chunking**: Split large text into manageable chunks for efficient vector storage.\n* **Vector Search**: Build a FAISS index of embeddings to enable semantic similarity search.\n* **PydanticAI Agent**: Leverage PydanticAI’s agent-and-tool architecture to handle retrieval and LLM calls.\n* **Ollama Integration**: Use Ollama’s local LLM and embedding models for both embeddings and chat completions.\n* **Streamlit UI**: Interactive web interface for loading repos and chatting with contents.\n\n---\n\n## Demo\n\n![Chat Demo](docs/chat-demo.gif)\n\n---\n\n## Prerequisites\n\n* **Python 3.10+**\n* **Ollama** installed and running locally (default HTTP endpoint `http://localhost:11434/v1`)\n* Git installed on your system\n\n---\n\n## Installation\n\n1. **Clone this repository**\n\n   ```bash\n   git clone https://github.com/YourUsername/github-repo-chatbot-pydanticai.git\n   cd github-repo-chatbot-pydanticai\n   ```\n\n2. **Create and activate a virtual environment**\n\n   ```bash\n   python3 -m venv venv\n   source venv/bin/activate\n   ```\n\n3. **Install dependencies**\n\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n   *`requirements.txt` should include:*\n\n   ```text\n   streamlit\n   pydantic-ai\n   langchain-community\n   langchain-ollama\n   faiss-cpu            # or faiss-gpu if you have GPU support\n   ```\n\n---\n\n## Configuration\n\n1. **Run Ollama daemon**\n\n   Ensure Ollama is up and running. By default it listens on `http://localhost:11434/v1`.\n\n2. **Model names**\n\n   * Embedding model: `all-minilm:33m`\n   * LLM model: `llama3.2`\n\n   You can change these in `app.py` when initializing `OllamaEmbeddings` and `OpenAIModel`.\n\n---\n\n## Usage\n\nLaunch the Streamlit app:\n\n```bash\nstreamlit run app.py\n```\n\n1. Open the URL shown in the console (usually `http://localhost:8501`).\n2. Enter a **GitHub repository URL** in the sidebar (e.g., `https://github.com/JustCodeIt7/GitHub_Repo_Chat`).\n3. Select file extensions to include (default: `.py, .md, .txt, .js, .html, .css, .json`).\n4. Click **Load Repository** to clone, process, and index the repo.\n5. Once loaded, ask questions in the chat interface about the repository’s contents.\n\n---\n\n## Project Structure\n\n```\n├── app.py            # Main Streamlit application\n├── requirements.txt  # Python dependencies\n├── README.md         # This documentation\n├── docs/\n│   └── chat-demo.gif # Demo GIF (optional)\n└── .gitignore        # Excludes venv, __pycache__, etc.\n```\n\n---\n\n## How It Works\n\n1. **Clone \u0026 Extract**\n\n   * `get_repo_text` clones the repository into a temporary directory.\n   * Walks through files with allowed extensions and concatenates their contents.\n\n2. **Chunking**\n\n   * `split_text` splits the combined text into overlapping chunks of \\~1000 characters.\n\n3. **Vector Store**\n\n   * `create_vectorstore` builds a FAISS index using OllamaEmbeddings on each chunk.\n\n4. **Agent \u0026 Retrieval**\n\n   * `initialize_agent` creates a PydanticAI `Agent` with an `retrieve` tool that returns the top-4 similar chunks.\n   * When a user query comes in, PydanticAI handles tool invocation (retrieval) and crafts the prompt for Ollama to answer.\n\n5. **Chat UI**\n\n   * Streamlit displays previous messages and handles user input via `st.chat_input`.\n   * Responses from the agent are streamed back into the chat interface.\n\n---\n\n## Customization\n\n* **Chunk Size \u0026 Overlap**: Adjust `chunk_size` and `overlap` in `split_text`.\n* **Number of Docs**: Change the `k` parameter in `vectorstore.similarity_search` within the `retrieve` tool.\n* **Models**: Swap out `OllamaEmbeddings` or `OpenAIModel` parameters for different model sizes or temperatures.\n* **Additional Tools**: Add more `@agent.tool` functions to perform extra tasks (e.g., code search, summary, translation).\n\n---\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request with improvements, bug fixes, or new features.\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See [LICENSE](LICENSE) for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustcodeit7%2Fgithub_repo_chat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustcodeit7%2Fgithub_repo_chat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustcodeit7%2Fgithub_repo_chat/lists"}