Spaces:
Runtime error
Runtime error
Upload 3 files
Browse filesFiles changed (3)
- app.pyAdded+2134
- index-html.htmlAdded+587
- requirements.txtAdded+29
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134import asyncioimport base64import jsonimport osimport pathlibfrom typing import AsyncGenerator, Dict, List, Any, Tuple, Optional, Set, Literal
import gradio as grimport numpy as npfrom dotenv import load_dotenvfrom fastapi import FastAPIfrom fastapi.responses import HTMLResponsefrom fastrtc import ( AsyncStreamHandler, Stream, get_twilio_turn_credentials, wait_for_item,)from github import Githubfrom google import genaifrom google.genai.types import ( LiveConnectConfig, PrebuiltVoiceConfig, SpeechConfig, VoiceConfig,)from gradio.utils import get_spacefrom pydantic import BaseModelfrom collections import defaultdictimport base64from pathlib import Pathimport tempfilefrom tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_typeimport reimport requestsfrom datetime import datetime
# Set up pathscurrent_dir = pathlib.Path(__file__).parentindex_html_path = current_dir / "index.html"
# Load environment variablesload_dotenv()
# Configure API keysGITHUB_TOKEN = os.getenv("GITHUB_API_TOKEN")GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")TWILIO_ACCOUNT_SID = os.getenv("TWILIO_ACCOUNT_SID")TWILIO_AUTH_TOKEN = os.getenv("TWILIO_AUTH_TOKEN")
if not GITHUB_TOKEN: GITHUB_TOKEN = "YOUR_GITHUB_TOKEN" # Will be replaced by user input if not GEMINI_API_KEY: GEMINI_API_KEY = "YOUR_GEMINI_API_KEY" # Will be replaced by user input
# Initialize GitHub APIgh = None
# Configure Gemini modeldef configure_gemini(api_key): genai.configure(api_key=api_key) return genai.GenerativeModel( model_name="gemini-1.5-pro-latest", generation_config={ "temperature": 0.7, "top_p": 0.95, "top_k": 40, "max_output_tokens": 8192, }, safety_settings=[ {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"}, {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_MEDIUM_AND_ABOVE"}, {"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"}, {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"}, ] )
# Configure Gemini client for voicedef create_gemini_client(api_key): return genai.Client( api_key=api_key, http_options={"api_version": "v1alpha"}, )
# Audio encoding functiondef encode_audio(data: np.ndarray) -> str: """Encode Audio data to send to the server""" return base64.b64encode(data.tobytes()).decode("UTF-8")
# Code file extensions to analyzeRELEVANT_EXTENSIONS = { ".py", ".js", ".ts", ".jsx", ".tsx", ".java", ".cpp", ".c", ".h", ".hpp", ".rb", ".php", ".go", ".rs", ".swift", ".kt", ".cs", ".css", ".html", ".xml", ".json", ".yaml", ".yml", ".md", ".sh", ".bat"}
# Repository analysis classclass RepositoryAnalyzer: """Handles GitHub repository analysis"""
def __init__(self, repo_url: str, github_token: str): # Extract owner and repo name from URL parts = repo_url.rstrip('/').split('/') if len(parts) < 2: raise ValueError("Invalid repository URL format")
self.repo_name = parts[-1] self.owner = parts[-2] self.repo_url = repo_url self.github_token = github_token # Initialize GitHub API self.gh = Github(github_token) self.repo = self.gh.get_repo(f"{self.owner}/{self.repo_name}") self.analysis_data: Dict[str, Any] = {} # Store repository content cache self.file_content_cache = {}
def analyze(self, progress_callback=None) -> Dict[str, Any]: """Perform complete repository analysis""" try: if progress_callback: progress_callback(0.1, "Fetching basic repository information...") # Basic repository information self.analysis_data["basic_info"] = self._get_basic_info() if progress_callback: progress_callback(0.2, "Analyzing repository structure...") # Analyze repository structure self.analysis_data["structure"] = self._analyze_structure() if progress_callback: progress_callback(0.3, "Analyzing repository dependencies...") # Analyze dependencies self.analysis_data["dependencies"] = self._analyze_dependencies() if progress_callback: progress_callback(0.4, "Analyzing code patterns...") # Analyze code patterns self.analysis_data["code_patterns"] = self._analyze_code_patterns() if progress_callback: progress_callback(0.6, "Analyzing commit history...") # Analyze commit history self.analysis_data["commit_history"] = self._analyze_commits() if progress_callback: progress_callback(0.8, "Analyzing contributors...") # Get contributor statistics self.analysis_data["contributors"] = self._analyze_contributors() if progress_callback: progress_callback(0.9, "Analyzing pull requests and issues...") # Analyze pull requests and issues self.analysis_data["pull_requests"] = self._analyze_pull_requests() self.analysis_data["issues"] = self._analyze_issues() if progress_callback: progress_callback(1.0, "Analysis complete!") return self.analysis_data
except Exception as e: raise Exception(f"Error analyzing repository: {str(e)}")
def _get_basic_info(self) -> Dict[str, Any]: """Get basic repository information""" return { "name": self.repo.name, "owner": self.repo.owner.login, "description": self.repo.description or "No description available", "stars": self.repo.stargazers_count, "forks": self.repo.forks_count, "watchers": self.repo.watchers_count, "created_at": self.repo.created_at.isoformat(), "last_updated": self.repo.updated_at.isoformat(), "primary_language": self.repo.language or "Not specified", "license": self.repo.license.name if self.repo.license else "No license specified", "open_issues_count": self.repo.open_issues_count, "is_archived": self.repo.archived, "is_fork": self.repo.fork, "homepage": self.repo.homepage, "url": self.repo.html_url, "size": self.repo.size, "topics": self.repo.get_topics(), }
def _analyze_structure(self) -> Dict[str, Any]: """Analyze repository structure and organization""" structure = { "files": defaultdict(int), "directories": set(), "total_size": 0, "readme": None, "license": None, "gitignore": None, "workflow_files": [], "test_directories": [], "docs_directories": [], }
try: # Check for root-level special files try: readme_content = self.repo.get_readme() structure["readme"] = { "path": readme_content.path, "size": readme_content.size, } except: pass
try: license_content = self.repo.get_license() structure["license"] = { "path": license_content.path, "size": license_content.size, "name": license_content.license.name if license_content.license else "Unknown" } except: pass
# Analyze repository structure recursively contents = self.repo.get_contents("") while contents: content = contents.pop(0) # Identify special files if content.path.lower() == ".gitignore": structure["gitignore"] = content.path elif content.path.startswith(".github/workflows/") and content.type == "file": structure["workflow_files"].append(content.path) # Track directories if content.type == "dir": structure["directories"].add(content.path) # Identify special directories path_lower = content.path.lower() if "test" in path_lower or path_lower.endswith("tests"): structure["test_directories"].append(content.path) elif "doc" in path_lower or path_lower.endswith("docs"): structure["docs_directories"].append(content.path) # Get directory contents try: contents.extend(self.repo.get_contents(content.path)) except Exception as e: print(f"Error getting contents of directory {content.path}: {str(e)}") # Track files else: ext = Path(content.path).suffix.lower() structure["files"][ext] += 1 structure["total_size"] += content.size except Exception as e: print(f"Error analyzing structure: {str(e)}")
return { "file_types": dict(structure["files"]), "directory_count": len(structure["directories"]), "total_size": structure["total_size"], "file_count": sum(structure["files"].values()), "readme": structure["readme"], "license": structure["license"], "gitignore": structure["gitignore"], "workflow_files": structure["workflow_files"], "test_directories": structure["test_directories"], "docs_directories": structure["docs_directories"], }
def _analyze_dependencies(self) -> Dict[str, Any]: """Analyze repository dependencies""" dependencies = { "package_managers": [], "dependencies": {}, "has_lockfiles": False, } dependency_files = { "requirements.txt": "pip", "setup.py": "pip", "pyproject.toml": "poetry/pip", "Pipfile": "pipenv", "package.json": "npm", "pom.xml": "maven", "build.gradle": "gradle", "Gemfile": "bundler", "Cargo.toml": "cargo", "go.mod": "go", "composer.json": "composer", } lockfiles = [ "package-lock.json", "yarn.lock", "Pipfile.lock", "poetry.lock", "Gemfile.lock", "Cargo.lock", "composer.lock", "go.sum" ] try: for file_path, package_manager in dependency_files.items(): try: content = self.repo.get_contents(file_path) if content: dependencies["package_managers"].append(package_manager) # Parse dependencies from common files if file_path == "requirements.txt": file_content = base64.b64decode(content.content).decode('utf-8') deps = [line.strip().split('==')[0] for line in file_content.split('\n') if line.strip() and not line.strip().startswith('#')] dependencies["dependencies"]["pip"] = deps elif file_path == "package.json": file_content = base64.b64decode(content.content).decode('utf-8') pkg_json = json.loads(file_content) deps = list(pkg_json.get("dependencies", {}).keys()) dev_deps = list(pkg_json.get("devDependencies", {}).keys()) dependencies["dependencies"]["npm"] = { "dependencies": deps, "devDependencies": dev_deps } except: pass # Check for lock files for lockfile in lockfiles: try: if self.repo.get_contents(lockfile): dependencies["has_lockfiles"] = True break except: pass except Exception as e: print(f"Error analyzing dependencies: {str(e)}") return dependencies
def _analyze_code_patterns(self) -> Dict[str, Any]: """Analyze code patterns and style""" patterns = { "samples": [], "languages": defaultdict(int), "complexity_metrics": defaultdict(list), "documentation_ratio": 0, "avg_code_to_comment_ratio": 0, }
try: files = self.repo.get_contents("") analyzed = 0 total_comments = 0 total_code = 0
while files and analyzed < 10: # Analyze up to 10 files file = files.pop(0) if file.type == "dir": files.extend(self.repo.get_contents(file.path)) elif Path(file.path).suffix.lower() in RELEVANT_EXTENSIONS: try: content = base64.b64decode(file.content).decode('utf-8') lines = content.splitlines()
if not lines: continue
# Count code and comment lines code_lines = 0 comment_lines = 0 empty_lines = 0 ext = Path(file.path).suffix.lower() # Simple comment detection based on file type comment_markers = { ".py": ["#"], ".js": ["//", "/*"], ".ts": ["//", "/*"], ".jsx": ["//", "/*"], ".tsx": ["//", "/*"], ".java": ["//", "/*"], ".cpp": ["//", "/*"], ".c": ["//", "/*"], ".h": ["//", "/*"], ".hpp": ["//", "/*"], ".rb": ["#"], ".php": ["//", "/*", "#"], ".go": ["//", "/*"], ".rs": ["//", "/*"], ".swift": ["//", "/*"], ".kt": ["//", "/*"], ".cs": ["//", "/*"], } if ext in comment_markers: for line in lines: line = line.strip() if not line: empty_lines += 1 elif any(line.startswith(marker) for marker in comment_markers[ext]): comment_lines += 1 else: code_lines += 1 else: # Default counting for unknown file types code_lines = len([line for line in lines if line.strip()]) total_code += code_lines total_comments += comment_lines # Calculate metrics loc = len([line for line in lines if line.strip()]) avg_line_length = sum(len(line) for line in lines if line) / max(1, len([line for line in lines if line])) comment_ratio = comment_lines / max(1, code_lines + comment_lines)
# Store file analysis patterns["samples"].append({ "path": file.path, "language": Path(file.path).suffix[1:], "loc": loc, "code_lines": code_lines, "comment_lines": comment_lines, "empty_lines": empty_lines, "comment_ratio": round(comment_ratio, 2), "avg_line_length": round(avg_line_length, 2) })
patterns["languages"][Path(file.path).suffix[1:]] += loc patterns["complexity_metrics"]["loc"].append(loc) patterns["complexity_metrics"]["avg_line_length"].append(avg_line_length) patterns["complexity_metrics"]["comment_ratio"].append(comment_ratio)
analyzed += 1 # Store file content in cache for later use self.file_content_cache[file.path] = content
except Exception as e: print(f"Error analyzing file {file.path}: {str(e)}") continue
# Calculate aggregate metrics if analyzed > 0: patterns["documentation_ratio"] = round(sum(patterns["complexity_metrics"]["comment_ratio"]) / analyzed, 2) patterns["avg_code_to_comment_ratio"] = round(total_code / max(1, total_comments), 2)
except Exception as e: print(f"Error in code pattern analysis: {str(e)}")
return patterns
def _analyze_commits(self) -> Dict[str, Any]: """Analyze commit history and patterns""" commit_data = [] commit_times = [] commit_days = [] commit_authors = defaultdict(int) commit_messages = [] recent_activity = []
try: commits = list(self.repo.get_commits()[:100]) # Get last 100 commits
for commit in commits: try: # Get commit details commit_info = { "sha": commit.sha, "author": commit.author.login if commit.author else "Unknown", "date": commit.commit.author.date.isoformat(), "message": commit.commit.message, "changes": { "additions": commit.stats.additions, "deletions": commit.stats.deletions, } } # Track commit data commit_data.append(commit_info) commit_times.append(commit.commit.author.date.hour) commit_days.append(commit.commit.author.date.weekday()) # Track author statistics author = commit.author.login if commit.author else "Unknown" commit_authors[author] += 1 # Track commit messages commit_messages.append(commit.commit.message) # Track recent activity (last 10 commits) if len(recent_activity) < 10: recent_activity.append({ "author": author, "date": commit.commit.author.date.isoformat(), "message": commit.commit.message[:100] + ("..." if len(commit.commit.message) > 100 else ""), }) except Exception as e: print(f"Error processing commit {commit.sha}: {str(e)}") continue
# Analyze commit patterns commit_hours = defaultdict(int) for hour in commit_times: commit_hours[hour] += 1 commit_weekdays = defaultdict(int) for day in commit_days: commit_weekdays[day] += 1 # Analyze release patterns (by tag) releases = [] for tag in self.repo.get_tags()[:10]: # Get last 10 tags try: releases.append({ "name": tag.name, "commit": tag.commit.sha, "date": tag.commit.commit.author.date.isoformat(), }) except Exception as e: print(f"Error processing tag {tag.name}: {str(e)}") continue
total_commits = len(commit_data) return { "total_commits": total_commits, "commit_hours": dict(commit_hours), "commit_weekdays": dict(commit_weekdays), "avg_additions": sum(c["changes"]["additions"] for c in commit_data) / total_commits if total_commits else 0, "avg_deletions": sum(c["changes"]["deletions"] for c in commit_data) / total_commits if total_commits else 0, "commit_frequency": defaultdict(int, dict(commit_authors)), "recent_activity": recent_activity, "releases": releases, }
except Exception as e: print(f"Error in commit analysis: {str(e)}") return { "total_commits": 0, "commit_hours": {}, "commit_weekdays": {}, "avg_additions": 0, "avg_deletions": 0, "commit_frequency": {}, "recent_activity": [], "releases": [], }
def _analyze_contributors(self) -> Dict[str, Any]: """Analyze contributor statistics""" contributor_data = [] top_contributors = []
try: contributors = list(self.repo.get_contributors()) # Get all contributors for contributor in contributors: contributor_data.append({ "login": contributor.login, "contributions": contributor.contributions, "type": contributor.type, "url": contributor.html_url, }) # Sort by contributions and get top 5 top_contributors = sorted( contributor_data, key=lambda x: x["contributions"], reverse=True )[:5] except Exception as e: print(f"Error analyzing contributors: {str(e)}")
return { "total_contributors": len(contributor_data), "contributors": contributor_data, "top_contributors": top_contributors, }
def _analyze_pull_requests(self) -> Dict[str, Any]: """Analyze pull request patterns""" pr_data = { "open_prs": 0, "closed_prs": 0, "merged_prs": 0, "recent_prs": [], } try: # Count open PRs open_prs = self.repo.get_pulls(state='open') pr_data["open_prs"] = open_prs.totalCount # Count closed PRs closed_prs = self.repo.get_pulls(state='closed') pr_data["closed_prs"] = closed_prs.totalCount # Get recent PRs (last 5) recent_prs = list(self.repo.get_pulls(state='all')[:5]) for pr in recent_prs: pr_data["recent_prs"].append({ "number": pr.number, "title": pr.title, "state": pr.state, "created_at": pr.created_at.isoformat(), "author": pr.user.login if pr.user else "Unknown", "is_merged": pr.merged, "url": pr.html_url, }) # Count merged PRs from the sample if pr.merged: pr_data["merged_prs"] += 1 except Exception as e: print(f"Error analyzing pull requests: {str(e)}") return pr_data
def _analyze_issues(self) -> Dict[str, Any]: """Analyze issue patterns""" issue_data = { "open_issues": 0, "closed_issues": 0, "recent_issues": [], } try: # Count open issues open_issues = self.repo.get_issues(state='open') issue_data["open_issues"] = open_issues.totalCount # Count closed issues closed_issues = self.repo.get_issues(state='closed') issue_data["closed_issues"] = closed_issues.totalCount # Get recent issues (last 5) recent_issues = list(self.repo.get_issues(state='all')[:5]) for issue in recent_issues: # Skip pull requests (which are also returned as issues) if issue.pull_request is not None: continue issue_data["recent_issues"].append({ "number": issue.number, "title": issue.title, "state": issue.state, "created_at": issue.created_at.isoformat(), "author": issue.user.login if issue.user else "Unknown", "labels": [label.name for label in issue.labels], "url": issue.html_url, }) except Exception as e: print(f"Error analyzing issues: {str(e)}") return issue_data
def get_file_content(self, file_path: str) -> str: """Get content of a specific file, using cache if available""" if file_path in self.file_content_cache: return self.file_content_cache[file_path] try: content = self.repo.get_contents(file_path) file_content = base64.b64decode(content.content).decode('utf-8') self.file_content_cache[file_path] = file_content return file_content except Exception as e: print(f"Error getting file content for {file_path}: {str(e)}") return f"Error: Could not retrieve file content: {str(e)}" def search_code(self, query: str) -> List[Dict[str, Any]]: """Search for code in the repository""" results = [] try: # Use GitHub search API code_results = self.gh.search_code(f"repo:{self.owner}/{self.repo_name} {query}") for item in code_results[:10]: # Limit to 10 results try: file_content = self.get_file_content(item.path) # Find matching lines lines = file_content.splitlines() matching_lines = [] for i, line in enumerate(lines): if query.lower() in line.lower(): start_line = max(0, i - 2) end_line = min(len(lines), i + 3) context = "\n".join(lines[start_line:end_line]) matching_lines.append({ "line_number": i + 1, "line": line, "context": context }) results.append({ "path": item.path, "url": item.html_url, "matching_lines": matching_lines[:3], # Limit to 3 matches per file }) except Exception as e: print(f"Error processing search result {item.path}: {str(e)}") continue except Exception as e: print(f"Error searching code: {str(e)}") return results def get_file_list(self, pattern: Optional[str] = None) -> List[str]: """Get list of files in the repository, optionally filtered by pattern""" files = [] try: queue = [("", "")] # (path, directory) while queue: base_path, dir_path = queue.pop(0) full_path = f"{base_path}/{dir_path}".strip("/") try: contents = self.repo.get_contents(full_path or "") for content in contents: if content.type == "dir": new_base = full_path queue.append((new_base, content.name)) else: file_path = f"{full_path}/{content.name}" if full_path else content.name # Filter by pattern if provided if not pattern or re.search(pattern, file_path, re.IGNORECASE): files.append(file_path) except Exception as e: print(f"Error listing files in {full_path}: {str(e)}") continue except Exception as e: print(f"Error getting file list: {str(e)}") return files
# Gemini Voice Handlerclass GeminiHandler(AsyncStreamHandler): """Handler for the Gemini API voice chat"""
def __init__( self, expected_layout: Literal["mono"] = "mono", output_sample_rate: int = 24000, output_frame_size: int = 480, analysis_data: Optional[Dict[str, Any]] = None, system_prompt: Optional[str] = None, ) -> None: super().__init__( expected_layout, output_sample_rate, output_frame_size, input_sample_rate=16000, ) self.input_queue: asyncio.Queue = asyncio.Queue() self.output_queue: asyncio.Queue = asyncio.Queue() self.quit: asyncio.Event = asyncio.Event() self.analysis_data = analysis_data or {} self.system_prompt = system_prompt or ""
def copy(self) -> "GeminiHandler": return GeminiHandler( expected_layout="mono", output_sample_rate=self.output_sample_rate, output_frame_size=self.output_frame_size, analysis_data=self.analysis_data, system_prompt=self.system_prompt, )
def set_context(self, analysis_data: Dict[str, Any], system_prompt: str): """Set the repository analysis context for voice chat""" self.analysis_data = analysis_data self.system_prompt = system_prompt
async def start_up(self): if not self.phone_mode: await self.wait_for_args() api_key, voice_name = self.latest_args[1:] else: api_key, voice_name = None, "Puck"
client = genai.Client( api_key=api_key or os.getenv("GEMINI_API_KEY"), http_options={"api_version": "v1alpha"}, )
# Add context prefix if available context_prefix = "" if self.analysis_data and self.system_prompt: context_prefix = f""" {self.system_prompt} Repository Analysis Data: {json.dumps(self.analysis_data, indent=2)} Answer questions about this repository analysis. You are now in voice-based conversation mode. """
config = LiveConnectConfig( response_modalities=["AUDIO"], # type: ignore speech_config=SpeechConfig( voice_config=VoiceConfig( prebuilt_voice_config=PrebuiltVoiceConfig( voice_name=voice_name, ) ) ), prefix=context_prefix, ) try: async with client.aio.live.connect( model="gemini-2.0-flash-exp", config=config ) as session: async for audio in session.start_stream( stream=self.stream(), mime_type="audio/pcm" ): if audio.data: array = np.frombuffer(audio.data, dtype=np.int16) self.output_queue.put_nowait((self.output_sample_rate, array)) except Exception as e: print(f"Error in Gemini streaming session: {str(e)}")
async def stream(self) -> AsyncGenerator[bytes, None]: while not self.quit.is_set(): try: audio = await asyncio.wait_for(self.input_queue.get(), 0.1) yield audio except (asyncio.TimeoutError, TimeoutError): pass
async def receive(self, frame: tuple[int, np.ndarray]) -> None: _, array = frame array = array.squeeze() audio_message = encode_audio(array) self.input_queue.put_nowait(audio_message)
async def emit(self) -> tuple[int, np.ndarray] | None: return await wait_for_item(self.output_queue)
def shutdown(self) -> None: self.quit.set()
# Function to analyze repository and generate summary@retry( retry=retry_if_exception_type(Exception), stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))def analyze_repository(repo_url: str, github_token: str, gemini_api_key: str, progress=None) -> Tuple[str, str, Any]: """Analyze repository and generate LLM summary with rate limit handling""" try: # Configure Gemini model = configure_gemini(gemini_api_key) # Initialize analyzer if progress: progress(0, desc="Initializing repository analysis...") analyzer = RepositoryAnalyzer(repo_url, github_token)
# Perform analysis analysis_data = analyzer.analyze(progress)
# Generate LLM summary if progress: progress(0.95, desc="Generating analysis summary...")
system_prompt = """You are an expert code analyst with deep experience in software architecture, development practices, and team dynamics. Analyze the provided repository data and create a detailed, insightful analysis using the following markdown template:
# Repository Analysis
## 📊 Project Overview[Provide a comprehensive overview including:- Project purpose and scope- Age and maturity of the project- Current activity level and maintenance status- Key metrics (stars, forks, etc.)- Primary technologies and languages used]
## 🏗️ Architecture and Code Organization[Analyze in detail:- Repository structure and organization- Code distribution across different technologies- File and directory organization patterns- Project size and complexity metrics- Code modularity and component structure- Presence of key architectural patterns]
## 💻 Development Practices & Code Quality[Evaluate:- Coding standards and consistency- Code complexity and maintainability metrics- Documentation practices- Testing approach and coverage (if visible)- Error handling and logging practices- Use of design patterns and best practices]
## 📈 Development Workflow & History[Analyze:- Commit patterns and frequency- Release cycles and versioning- Branch management strategy- Code review practices- Continuous integration/deployment indicators- Peak development periods and cycles]
## 👥 Team Dynamics & Collaboration[Examine:- Team size and composition- Contribution patterns- Core maintainer identification- Community engagement level- Communication patterns- Collaboration efficiency]
## 🔧 Technical Depth & Innovation[Assess:- Technical sophistication level- Innovative approaches or solutions- Complex problem-solving examples- Performance optimization efforts- Security considerations- Scalability approach]
## 🚀 Project Health & Sustainability[Evaluate:- Project momentum and growth trends- Maintenance patterns- Community health indicators- Documentation completeness- Onboarding friendliness- Long-term viability indicators]
## 💡 Key Insights & Recommendations[Provide:- 3-5 key strengths identified- 3-5 potential improvement areas- Notable patterns or practices- Unique characteristics- Strategic recommendations]
Please provide detailed analysis for each section while maintaining the formatting and emojis. Support insights with specific metrics and examples from the repository data where possible."""
chat = model.start_chat(history=[]) response = chat.send_message(f"{system_prompt}\n\nRepository Analysis Data:\n{json.dumps(analysis_data, indent=2)}")
# Save analysis data if progress: progress(0.98, desc="Saving analysis results...") with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.json') as f: json.dump(analysis_data, f, indent=2) analysis_file = f.name
return response.text, analysis_file, analyzer, system_prompt
except Exception as e: error_message = f"Error analyzing repository: {str(e)}" raise Exception(error_message)
# Function to create a chat session and ask questionsdef create_chat_session(gemini_api_key: str) -> Any: """Create a new chat session for follow-up questions""" genai.configure(api_key=gemini_api_key) return genai.GenerativeModel( model_name="gemini-1.5-pro-latest", generation_config={ 'temperature': 0.7, 'top_p': 0.8, 'top_k': 40, 'max_output_tokens': 4096, } )
@retry( retry=retry_if_exception_type(Exception), stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))def ask_question(question: str, analysis_file: str, analyzer: RepositoryAnalyzer, gemini_api_key: str, chat_history: List[Tuple[str, str]]) -> List[Tuple[str, str]]: """Process a follow-up question about the analysis""" if not analysis_file or not analyzer: return chat_history + [(question, "Please analyze a repository first before asking questions.")]
try: # Load analysis data with open(analysis_file, 'r') as f: analysis_data = json.load(f)
# Initialize chat model model = create_chat_session(gemini_api_key)
# Check if this is a file content request file_request_match = re.search(r"(show|view|get|display|content of|code for)\s+(?:the\s+)?(?:file\s+)?['\"]?([^'\"]+?)['\"]?(?:\s+file)?", question.lower()) if file_request_match: file_path = file_request_match.group(2).strip() # Try to find the exact file all_files = analyzer.get_file_list() # Check for exact match if file_path in all_files: file_content = analyzer.get_file_content(file_path) return chat_history + [(question, f"Here's the content of `{file_path}`:\n\n```\n{file_content}\n```")] # Check for partial match matching_files = [f for f in all_files if file_path.lower() in f.lower()] if matching_files: if len(matching_files) == 1: file_content = analyzer.get_file_content(matching_files[0]) return chat_history + [(question, f"Here's the content of `{matching_files[0]}`:\n\n```\n{file_content}\n```")] else: file_list = "\n".join([f"- {f}" for f in matching_files[:10]]) return chat_history + [(question, f"I found multiple files matching '{file_path}'. Please specify which one you'd like to see:\n\n{file_list}{' and more...' if len(matching_files) > 10 else ''}")] # Check if this is a code search request search_request_match = re.search(r"(search|find|look for|where is)\s+(?:for\s+)?['\"]?([^'\"]+?)['\"]?(?:\s+in the code)?", question.lower()) if search_request_match: search_query = search_request_match.group(2).strip() search_results = analyzer.search_code(search_query) if search_results: result_text = f"I found {len(search_results)} files containing '{search_query}':\n\n" for result in search_results: result_text += f"**File: {result['path']}**\n" if result['matching_lines']: for match in result['matching_lines']: result_text += f"Line {match['line_number']}: `{match['line'].strip()}`\n" result_text += "\n" else: result_text += "No specific line matches found.\n\n" return chat_history + [(question, result_text)] else: return chat_history + [(question, f"I couldn't find any code matching '{search_query}' in the repository.")]
# For general questions, use the AI # Build context from chat history and current question context = "You are an expert code analyst helping users understand repository analysis results.\n\n" context += f"Repository Analysis Data:\n{json.dumps(analysis_data, indent=2)}\n\n"
# Add chat history context if chat_history: context += "Previous conversation:\n" for user_msg, assistant_msg in chat_history[-5:]: # Include last 5 messages only context += f"User: {user_msg}\nAssistant: {assistant_msg}\n"
# Add current question prompt = context + f"\nUser: {question}\nPlease provide your analysis based on the repository data:"
# Get response response = model.generate_content(prompt)
# Return in the correct tuple format for Gradio chatbot return chat_history + [(question, response.text)]
except Exception as e: error_message = f"Error processing question: {str(e)}" return chat_history + [(question, error_message)]
# Input data modelsclass InputData(BaseModel): webrtc_id: str voice_name: str api_key: str repo_url: Optional[str] = None github_token: Optional[str] = None
# Create FastAPI app and set up routesapp = FastAPI()
# Create Gemini handler for voice chatgemini_handler = GeminiHandler()
# Create voice chat streamvoice_stream = Stream( modality="audio", mode="send-receive", handler=gemini_handler, rtc_configuration=get_twilio_turn_credentials() if get_space() else None, concurrency_limit=5 if get_space() else None, time_limit=120 if get_space() else None, additional_inputs=[ gr.Textbox( label="Gemini API Key", type="password", value=os.getenv("GEMINI_API_KEY") if not get_space() else "", ), gr.Dropdown( label="Voice", choices=[ "Puck", "Charon", "Kore", "Fenrir", "Aoede", ], value="Puck", ), ],)
# Mount voice stream to appvoice_stream.mount(app)
# Current repository analysis datacurrent_analysis = { "data": None, "analyzer": None, "file": None, "summary": None, "system_prompt": None,}
@app.post("/input_hook")async def _(body: InputData): voice_stream.set_input(body.webrtc_id, body.api_key, body.voice_name) # If repo data is provided, analyze it and update the context if body.repo_url and body.github_token and current_analysis["data"] is None: try: # Analyze the repository in a background task to not block the voice connection asyncio.create_task(analyze_and_update_context(body.repo_url, body.github_token, body.api_key)) except Exception as e: print(f"Error analyzing repository: {str(e)}") # Update handler context if analysis data exists if current_analysis["data"] and current_analysis["system_prompt"]: gemini_handler.set_context(current_analysis["data"], current_analysis["system_prompt"]) return {"status": "ok"}
@app.post("/analyze_repository")async def analyze_repo(repo_url: str, github_token: str, gemini_api_key: str): try: summary, file_path, analyzer, system_prompt = await asyncio.to_thread( analyze_repository, repo_url, github_token, gemini_api_key ) # Load analysis data from file with open(file_path, 'r') as f: analysis_data = json.load(f) # Update current analysis current_analysis["data"] = analysis_data current_analysis["analyzer"] = analyzer current_analysis["file"] = file_path current_analysis["summary"] = summary current_analysis["system_prompt"] = system_prompt # Update handler context gemini_handler.set_context(analysis_data, system_prompt) return { "status": "success", "summary": summary, "file_path": file_path } except Exception as e: return { "status": "error", "message": str(e) }
async def analyze_and_update_context(repo_url: str, github_token: str, gemini_api_key: str): try: summary, file_path, analyzer, system_prompt = await asyncio.to_thread( analyze_repository, repo_url, github_token, gemini_api_key ) # Load analysis data from file with open(file_path, 'r') as f: analysis_data = json.load(f) # Update current analysis current_analysis["data"] = analysis_data current_analysis["analyzer"] = analyzer current_analysis["file"] = file_path current_analysis["summary"] = summary current_analysis["system_prompt"] = system_prompt # Update handler context gemini_handler.set_context(analysis_data, system_prompt) except Exception as e: print(f"Error analyzing repository in background: {str(e)}")
@app.post("/ask_question")async def ask_repo_question(question: str): if not current_analysis["file"] or not current_analysis["analyzer"]: return { "status": "error", "message": "Please analyze a repository first before asking questions." } try: response = await asyncio.to_thread( ask_question, question, current_analysis["file"], current_analysis["analyzer"], GEMINI_API_KEY, [] ) # Extract just the response text _, answer = response[0] return { "status": "success", "answer": answer } except Exception as e: return { "status": "error", "message": str(e) }
@app.get("/")async def index(): rtc_config = get_twilio_turn_credentials() if get_space() else None # Check if index.html exists if not index_html_path.exists(): # Create basic HTML if not exists html_content = """<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>GitHub Repository Analyzer with Voice Chat</title> <style> :root { --color-accent: #6366f1; --color-background: #0f172a; --color-surface: #1e293b; --color-text: #e2e8f0; --boxSize: 8px; --gutter: 4px; }
body { margin: 0; padding: 0; background-color: var(--color-background); color: var(--color-text); font-family: system-ui, -apple-system, sans-serif; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.container { width: 90%; max-width: 800px; background-color: var(--color-surface); padding: 2rem; border-radius: 1rem; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
.wave-container { position: relative; display: flex; min-height: 100px; max-height: 128px; justify-content: center; align-items: center; margin: 2rem 0; }
.box-container { display: flex; justify-content: space-between; height: 64px; width: 100%; }
.box { height: 100%; width: var(--boxSize); background: var(--color-accent); border-radius: 8px; transition: transform 0.05s ease; }
.controls { display: grid; gap: 1rem; margin-bottom: 2rem; }
.input-group { display: flex; flex-direction: column; gap: 0.5rem; }
label { font-size: 0.875rem; font-weight: 500; }
input, select { padding: 0.75rem; border-radius: 0.5rem; border: 1px solid rgba(255, 255, 255, 0.1); background-color: var(--color-background); color: var(--color-text); font-size: 1rem; }
button { padding: 1rem 2rem; border-radius: 0.5rem; border: none; background-color: var(--color-accent); color: white; font-weight: 600; cursor: pointer; transition: all 0.2s ease; }
button:hover { opacity: 0.9; transform: translateY(-1px); }
.icon-with-spinner { display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 180px; }
.spinner { width: 20px; height: 20px; border: 2px solid white; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.pulse-container { display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 180px; }
.pulse-circle { width: 20px; height: 20px; border-radius: 50%; background-color: white; opacity: 0.2; flex-shrink: 0; transform: translateX(-0%) scale(var(--audio-level, 1)); transition: transform 0.1s ease; }
/* Add styles for toast notifications */ .toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); padding: 16px 24px; border-radius: 4px; font-size: 14px; z-index: 1000; display: none; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); }
.toast.error { background-color: #f44336; color: white; }
.toast.warning { background-color: #ffd700; color: black; } .tabs { display: flex; margin-bottom: 1rem; } .tab { padding: 0.5rem 1rem; cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s ease; } .tab.active { border-bottom: 2px solid var(--color-accent); color: var(--color-accent); } .tab-content { display: none; } .tab-content.active { display: block; } .chat-container { height: 300px; overflow-y: auto; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 0.5rem; padding: 1rem; margin-bottom: 1rem; background-color: rgba(0, 0, 0, 0.2); } .chat-message { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); } .chat-message:last-child { border-bottom: none; } .chat-message .user { font-weight: bold; color: var(--color-accent); margin-bottom: 0.5rem; } .chat-message .bot { font-weight: bold; color: #10b981; margin-bottom: 0.5rem; } .chat-input { display: flex; gap: 0.5rem; } .chat-input input { flex: 1; } </style></head>
<body> <!-- Add toast element after body opening tag --> <div id="error-toast" class="toast"></div> <div style="text-align: center"> <h1>GitHub Repository Analyzer with Voice Chat</h1> <p>Analyze GitHub repositories and chat with the AI using voice or text</p> </div> <div class="container"> <div class="tabs"> <div class="tab active" data-tab="repo">Repository Setup</div> <div class="tab" data-tab="text">Text Chat</div> <div class="tab" data-tab="voice">Voice Chat</div> </div> <div class="tab-content active" id="repo-tab"> <div class="controls"> <div class="input-group"> <label for="github-token">GitHub API Token</label> <input type="password" id="github-token" placeholder="Enter your GitHub API token"> </div> <div class="input-group"> <label for="gemini-api-key">Gemini API Key</label> <input type="password" id="gemini-api-key" placeholder="Enter your Gemini API key"> </div> <div class="input-group"> <label for="repo-url">GitHub Repository URL</label> <input type="text" id="repo-url" placeholder="https://github.com/owner/repo"> </div> <button id="analyze-button">Analyze Repository</button> </div> <div id="analysis-result" style="white-space: pre-wrap; max-height: 400px; overflow-y: auto; display: none;"></div> </div> <div class="tab-content" id="text-tab"> <div id="chat-container" class="chat-container"></div> <div class="chat-input"> <input type="text" id="text-question" placeholder="Ask a question about the repository..."> <button id="ask-button">Ask</button> </div> </div> <div class="tab-content" id="voice-tab"> <div class="controls"> <div class="input-group"> <label for="voice">Voice</label> <select id="voice"> <option value="Puck">Puck</option> <option value="Charon">Charon</option> <option value="Kore">Kore</option> <option value="Fenrir">Fenrir</option> <option value="Aoede">Aoede</option> </select> </div> </div>
<div class="wave-container"> <div class="box-container"> <!-- Boxes will be dynamically added here --> </div> </div>
<button id="start-button">Start Voice Chat</button> </div> </div>
<audio id="audio-output"></audio>
<script> // Global variables let peerConnection; let audioContext; let dataChannel; let isRecording = false; let webrtc_id; let currentTab = 'repo'; let repositoryAnalyzed = false;
// DOM elements const startButton = document.getElementById('start-button'); const analyzeButton = document.getElementById('analyze-button'); const askButton = document.getElementById('ask-button'); const repoUrlInput = document.getElementById('repo-url'); const githubTokenInput = document.getElementById('github-token'); const geminiApiKeyInput = document.getElementById('gemini-api-key'); const voiceSelect = document.getElementById('voice'); const audioOutput = document.getElementById('audio-output'); const boxContainer = document.querySelector('.box-container'); const tabs = document.querySelectorAll('.tab'); const tabContents = document.querySelectorAll('.tab-content'); const chatContainer = document.getElementById('chat-container'); const textQuestionInput = document.getElementById('text-question'); const analysisResult = document.getElementById('analysis-result');
// Initialize audio visualization const numBars = 32; for (let i = 0; i < numBars; i++) { const box = document.createElement('div'); box.className = 'box'; boxContainer.appendChild(box); }
// Tab switching tabs.forEach(tab => { tab.addEventListener('click', () => { // First check if repository has been analyzed when switching to chat tabs if ((tab.dataset.tab === 'text' || tab.dataset.tab === 'voice') && !repositoryAnalyzed) { showError('Please analyze a repository first before chatting.'); return; } // Deactivate all tabs tabs.forEach(t => t.classList.remove('active')); tabContents.forEach(c => c.classList.remove('active')); // Activate selected tab tab.classList.add('active'); document.getElementById(`${tab.dataset.tab}-tab`).classList.add('active'); currentTab = tab.dataset.tab; }); });
// Error message display function showError(message) { const toast = document.getElementById('error-toast'); toast.textContent = message; toast.className = 'toast error'; toast.style.display = 'block';
// Hide toast after 5 seconds setTimeout(() => { toast.style.display = 'none'; }, 5000); }
// Repository analysis analyzeButton.addEventListener('click', async () => { const repoUrl = repoUrlInput.value.trim(); const githubToken = githubTokenInput.value.trim(); const geminiApiKey = geminiApiKeyInput.value.trim(); if (!repoUrl || !githubToken || !geminiApiKey) { showError('Please fill in all fields'); return; } try { analyzeButton.disabled = true; analyzeButton.textContent = 'Analyzing...'; // Call the analyze endpoint const response = await fetch('/analyze_repository', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ repo_url: repoUrl, github_token: githubToken, gemini_api_key: geminiApiKey }) }); const data = await response.json(); if (data.status === 'success') { // Display the analysis result analysisResult.textContent = data.summary; analysisResult.style.display = 'block'; repositoryAnalyzed = true; } else { showError(data.message || 'Error analyzing repository'); } } catch (err) { showError('Failed to analyze repository: ' + err.message); } finally { analyzeButton.disabled = false; analyzeButton.textContent = 'Analyze Repository'; } });
// Text chat askButton.addEventListener('click', async () => { const question = textQuestionInput.value.trim(); if (!question) { return; } // Add user message to chat addMessageToChat('You', question); textQuestionInput.value = ''; try { // Call the ask endpoint const response = await fetch('/ask_question', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ question: question }) }); const data = await response.json(); if (data.status === 'success') { // Add bot response to chat addMessageToChat('AI', data.answer); } else { addMessageToChat('AI', 'Error: ' + (data.message || 'Failed to get response')); } } catch (err) { addMessageToChat('AI', 'Error: ' + err.message); } });
// Add message to chat container function addMessageToChat(sender, message) { const messageDiv = document.createElement('div'); messageDiv.className = 'chat-message'; const senderDiv = document.createElement('div'); senderDiv.className = sender === 'You' ? 'user' : 'bot'; senderDiv.textContent = sender + ':'; const contentDiv = document.createElement('div'); contentDiv.innerHTML = formatMessage(message); messageDiv.appendChild(senderDiv); messageDiv.appendChild(contentDiv); chatContainer.appendChild(messageDiv); chatContainer.scrollTop = chatContainer.scrollHeight; }
// Format message with Markdown-like syntax function formatMessage(message) { // Convert code blocks message = message.replace(/```([^`]+)```/g, '<pre><code>$1</code></pre>'); // Convert inline code message = message.replace(/`([^`]+)`/g, '<code>$1</code>'); // Convert bold message = message.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>'); // Convert bullets message = message.replace(/- ([^\n]+)/g, '• $1<br>'); // Convert line breaks message = message.replace(/\n/g, '<br>'); return message; }
// Voice chat WebRTC setup async function setupWebRTC() { const config = __RTC_CONFIGURATION__; peerConnection = new RTCPeerConnection(config); webrtc_id = Math.random().toString(36).substring(7);
const timeoutId = setTimeout(() => { const toast = document.getElementById('error-toast'); toast.textContent = "Connection is taking longer than usual. Are you on a VPN?"; toast.className = 'toast warning'; toast.style.display = 'block';
// Hide warning after 5 seconds setTimeout(() => { toast.style.display = 'none'; }, 5000); }, 5000);
try { const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); stream.getTracks().forEach(track => peerConnection.addTrack(track, stream));
// Update audio visualization setup audioContext = new AudioContext(); analyser_input = audioContext.createAnalyser(); const source = audioContext.createMediaStreamSource(stream); source.connect(analyser_input); analyser_input.fftSize = 64; dataArray_input = new Uint8Array(analyser_input.frequencyBinCount);
function updateAudioLevel() { analyser_input.getByteFrequencyData(dataArray_input); const average = Array.from(dataArray_input).reduce((a, b) => a + b, 0) / dataArray_input.length; const audioLevel = average / 255;
const pulseCircle = document.querySelector('.pulse-circle'); if (pulseCircle) { pulseCircle.style.setProperty('--audio-level', 1 + audioLevel); }
animationId = requestAnimationFrame(updateAudioLevel); } updateAudioLevel();
// Add connection state change listener peerConnection.addEventListener('connectionstatechange', () => { console.log('connectionstatechange', peerConnection.connectionState); if (peerConnection.connectionState === 'connected') { clearTimeout(timeoutId); const toast = document.getElementById('error-toast'); toast.style.display = 'none'; } updateButtonState(); });
// Handle incoming audio peerConnection.addEventListener('track', (evt) => { if (audioOutput && audioOutput.srcObject !== evt.streams[0]) { audioOutput.srcObject = evt.streams[0]; audioOutput.play();
// Set up audio visualization on the output stream audioContext = new AudioContext(); analyser = audioContext.createAnalyser(); const source = audioContext.createMediaStreamSource(evt.streams[0]); source.connect(analyser); analyser.fftSize = 2048; dataArray = new Uint8Array(analyser.frequencyBinCount); updateVisualization(); } });
// Create data channel for messages dataChannel = peerConnection.createDataChannel('text'); dataChannel.onmessage = (event) => { const eventJson = JSON.parse(event.data); if (eventJson.type === "error") { showError(eventJson.message); } else if (eventJson.type === "send_input") { fetch('/input_hook', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ webrtc_id: webrtc_id, api_key: geminiApiKeyInput.value, voice_name: voiceSelect.value, repo_url: repoUrlInput.value, github_token: githubTokenInput.value }) }); } };
// Create and send offer const offer = await peerConnection.createOffer(); await peerConnection.setLocalDescription(offer);
await new Promise((resolve) => { if (peerConnection.iceGatheringState === "complete") { resolve(); } else { const checkState = () => { if (peerConnection.iceGatheringState === "complete") { peerConnection.removeEventListener("icegatheringstatechange", checkState); resolve(); } }; peerConnection.addEventListener("icegatheringstatechange", checkState); } });
const response = await fetch('/webrtc/offer', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ sdp: peerConnection.localDescription.sdp, type: peerConnection.localDescription.type, webrtc_id: webrtc_id, }) });
const serverResponse = await response.json();
if (serverResponse.status === 'failed') { showError(serverResponse.meta.error === 'concurrency_limit_reached' ? `Too many connections. Maximum limit is ${serverResponse.meta.limit}` : serverResponse.meta.error); stop(); startButton.textContent = 'Start Voice Chat'; return; }
await peerConnection.setRemoteDescription(serverResponse); } catch (err) { clearTimeout(timeoutId); console.error('Error setting up WebRTC:', err); showError('Failed to establish connection. Please try again.'); stop(); startButton.textContent = 'Start Voice Chat'; } }
function updateButtonState() { if (peerConnection && (peerConnection.connectionState === 'connecting' || peerConnection.connectionState === 'new')) { startButton.innerHTML = ` <div class="icon-with-spinner"> <div class="spinner"></div> <span>Connecting...</span> </div> `; } else if (peerConnection && peerConnection.connectionState === 'connected') { startButton.innerHTML = ` <div class="pulse-container"> <div class="pulse-circle"></div> <span>Stop Voice Chat</span> </div> `; } else { startButton.innerHTML = 'Start Voice Chat'; } }
function updateVisualization() { if (!analyser) return;
analyser.getByteFrequencyData(dataArray); const bars = document.querySelectorAll('.box');
for (let i = 0; i < bars.length; i++) { const barHeight = (dataArray[i] / 255) * 2; bars[i].style.transform = `scaleY(${Math.max(0.1, barHeight)})`; }
animationId = requestAnimationFrame(updateVisualization); }
function stopWebRTC() { if (peerConnection) { peerConnection.close(); } if (animationId) { cancelAnimationFrame(animationId); } if (audioContext) { audioContext.close(); } updateButtonState(); }
startButton.addEventListener('click', () => { if (!isRecording) { setupWebRTC(); startButton.classList.add('recording'); } else { stopWebRTC(); startButton.classList.remove('recording'); } isRecording = !isRecording; });
// Press Enter to send text chat message textQuestionInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') { askButton.click(); } }); </script></body>
</html>""" else: html_content = index_html_path.read_text() # Replace RTC configuration html_content = html_content.replace("__RTC_CONFIGURATION__", json.dumps(rtc_config)) return HTMLResponse(content=html_content)
# Gradio interface for web UIdef create_gradio_app(): with gr.Blocks(theme=gr.themes.Soft()) as app: gr.Markdown(""" # 🔍 GitHub Repository Analyzer with Voice Chat
Analyze any public GitHub repository using AI. The tool will: 1. 📊 Analyze repository structure, code, and development patterns 2. 💡 Generate comprehensive insights about the repository 3. 💬 Allow you to chat with AI about the repository using text or voice 4. 📁 Search code and view files in the repository Enter a GitHub repository URL and your API keys to get started. """)
with gr.Row(): with gr.Column(): repo_url = gr.Textbox( label="GitHub Repository URL", placeholder="https://github.com/owner/repo", value="" ) github_token = gr.Textbox( label="GitHub API Token", placeholder="Your GitHub API Token", type="password", value=GITHUB_TOKEN if GITHUB_TOKEN != "YOUR_GITHUB_TOKEN" else "" ) gemini_api_key = gr.Textbox( label="Gemini API Key", placeholder="Your Gemini API Key", type="password", value=GEMINI_API_KEY if GEMINI_API_KEY != "YOUR_GEMINI_API_KEY" else "" ) with gr.Row(): analyze_btn = gr.Button("🔍 Analyze Repository", variant="primary") # Add status message status_msg = gr.Markdown("", elem_id="status_message")
tabs = gr.Tabs() with tabs: with gr.TabItem("Analysis"): # Use Markdown for better formatting summary = gr.Markdown( label="Analysis Summary", value="" ) with gr.TabItem("Text Chat"): repo_chatbot = gr.Chatbot( label="Chat with Repository", height=400, show_label=True ) with gr.Row(): repo_question = gr.Textbox( label="Ask about the repository", placeholder="Ask a question, search code, or request a file...", scale=4 ) repo_ask_btn = gr.Button("💬 Ask", variant="primary", scale=1) repo_clear_btn = gr.Button("🗑️ Clear Chat", variant="secondary", scale=1) with gr.TabItem("Voice Chat"): gr.Markdown(""" ## Voice Chat with Repository Speak with an AI assistant about the repository using real-time voice chat. Click the "Open Voice Chat" button to launch the voice interface in a new tab. Note: Voice chat requires browser permission to access your microphone. """) voice_chat_btn = gr.Button("🎤 Open Voice Chat", variant="primary") # Hidden state for analysis file and analyzer analysis_file = gr.State("") analyzer_state = gr.State(None) system_prompt_state = gr.State("")
def clear_chat(): return []
def clear_outputs(): return "", [], "", None, "" def open_voice_chat(): return "Opening voice chat in a new tab...", gr.update() # Set up event handlers analyze_btn.click( fn=lambda: "⏳ Analysis in progress...", inputs=None, outputs=status_msg, queue=False ).then( analyze_repository, inputs=[repo_url, github_token, gemini_api_key], outputs=[summary, analysis_file, analyzer_state, system_prompt_state], ).then( lambda: "✅ Analysis complete! You can now chat with the repository.", inputs=None, outputs=status_msg, queue=False )
repo_ask_btn.click( ask_question, inputs=[repo_question, analysis_file, analyzer_state, gemini_api_key, repo_chatbot], outputs=[repo_chatbot], ).then( lambda: "", # Clear the question input None, repo_question, queue=False )
repo_clear_btn.click( clear_chat, inputs=None, outputs=[repo_chatbot], queue=False ) voice_chat_btn.click( open_voice_chat, inputs=None, outputs=[status_msg, voice_chat_btn], ).then( lambda: gr.update(value="Voice Chat Opened"), None, voice_chat_btn, js="""() => { window.open('/', '_blank'); return null; }""" )
return app
# Main executionif __name__ == "__main__": import uvicorn # Create Gradio interface gradio_app = create_gradio_app() # Get the Gradio FastAPI app gradio_app = gr.mount_gradio_app(app, gradio_app, path="/gradio") # Start the FastAPI server uvicorn.run(app, host="0.0.0.0", port=7860)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587<!DOCTYPE html><html lang="en">
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>GitHub Repository Voice Chat</title> <style> :root { --color-accent: #6366f1; --color-background: #0f172a; --color-surface: #1e293b; --color-text: #e2e8f0; --boxSize: 8px; --gutter: 4px; }
body { margin: 0; padding: 0; background-color: var(--color-background); color: var(--color-text); font-family: system-ui, -apple-system, sans-serif; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.container { width: 90%; max-width: 800px; background-color: var(--color-surface); padding: 2rem; border-radius: 1rem; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
.wave-container { position: relative; display: flex; min-height: 100px; max-height: 128px; justify-content: center; align-items: center; margin: 2rem 0; }
.box-container { display: flex; justify-content: space-between; height: 64px; width: 100%; }
.box { height: 100%; width: var(--boxSize); background: var(--color-accent); border-radius: 8px; transition: transform 0.05s ease; }
.controls { display: grid; gap: 1rem; margin-bottom: 2rem; }
.input-group { display: flex; flex-direction: column; gap: 0.5rem; }
label { font-size: 0.875rem; font-weight: 500; }
input, select { padding: 0.75rem; border-radius: 0.5rem; border: 1px solid rgba(255, 255, 255, 0.1); background-color: var(--color-background); color: var(--color-text); font-size: 1rem; }
button { padding: 1rem 2rem; border-radius: 0.5rem; border: none; background-color: var(--color-accent); color: white; font-weight: 600; cursor: pointer; transition: all 0.2s ease; }
button:hover { opacity: 0.9; transform: translateY(-1px); }
.icon-with-spinner { display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 180px; }
.spinner { width: 20px; height: 20px; border: 2px solid white; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.pulse-container { display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 180px; }
.pulse-circle { width: 20px; height: 20px; border-radius: 50%; background-color: white; opacity: 0.2; flex-shrink: 0; transform: translateX(-0%) scale(var(--audio-level, 1)); transition: transform 0.1s ease; }
/* Add styles for toast notifications */ .toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); padding: 16px 24px; border-radius: 4px; font-size: 14px; z-index: 1000; display: none; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); }
.toast.error { background-color: #f44336; color: white; }
.toast.warning { background-color: #ffd700; color: black; } /* Repository input section */ .repo-section { margin-bottom: 2rem; padding-bottom: 2rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); } /* Conversation section */ .conversation { background-color: rgba(0, 0, 0, 0.2); border-radius: 0.5rem; padding: 1rem; min-height: 200px; max-height: 300px; overflow-y: auto; margin-bottom: 1rem; } .message { margin-bottom: 1rem; padding: 0.5rem 1rem; border-radius: 0.5rem; } .user-message { background-color: rgba(99, 102, 241, 0.2); margin-left: 2rem; } .bot-message { background-color: rgba(16, 185, 129, 0.2); margin-right: 2rem; } </style></head>
<body> <!-- Add toast element after body opening tag --> <div id="error-toast" class="toast"></div> <div style="text-align: center"> <h1>GitHub Repository Voice Chat</h1> <p>Talk to AI about a GitHub repository using real-time voice</p> </div> <div class="container"> <div class="repo-section"> <h2>Repository Information</h2> <div class="controls"> <div class="input-group"> <label for="repo-url">GitHub Repository URL</label> <input type="text" id="repo-url" placeholder="https://github.com/owner/repo"> </div> <div class="input-group"> <label for="github-token">GitHub API Token</label> <input type="password" id="github-token" placeholder="Your GitHub API token"> </div> <button id="analyze-button">Analyze Repository</button> </div> <div id="repo-status"></div> </div> <h2>Voice Chat</h2> <div class="controls"> <div class="input-group"> <label for="api-key">Gemini API Key</label> <input type="password" id="api-key" placeholder="Enter your Gemini API key"> </div> <div class="input-group"> <label for="voice">Voice</label> <select id="voice"> <option value="Puck">Puck</option> <option value="Charon">Charon</option> <option value="Kore">Kore</option> <option value="Fenrir">Fenrir</option> <option value="Aoede">Aoede</option> </select> </div> </div>
<div class="conversation" id="conversation"> <div class="message bot-message"> Hello! I'm your GitHub repository assistant. Once you analyze a repository using the form above, you can ask me questions about it using your voice. Click the Start Recording button below to begin. </div> </div>
<div class="wave-container"> <div class="box-container"> <!-- Boxes will be dynamically added here --> </div> </div>
<button id="start-button">Start Recording</button> </div>
<audio id="audio-output"></audio>
<script> let peerConnection; let audioContext; let dataChannel; let isRecording = false; let webrtc_id; let repositoryAnalyzed = false;
const startButton = document.getElementById('start-button'); const analyzeButton = document.getElementById('analyze-button'); const apiKeyInput = document.getElementById('api-key'); const voiceSelect = document.getElementById('voice'); const repoUrlInput = document.getElementById('repo-url'); const githubTokenInput = document.getElementById('github-token'); const repoStatus = document.getElementById('repo-status'); const audioOutput = document.getElementById('audio-output'); const boxContainer = document.querySelector('.box-container'); const conversation = document.getElementById('conversation');
const numBars = 32; for (let i = 0; i < numBars; i++) { const box = document.createElement('div'); box.className = 'box'; boxContainer.appendChild(box); }
function updateButtonState() { if (peerConnection && (peerConnection.connectionState === 'connecting' || peerConnection.connectionState === 'new')) { startButton.innerHTML = ` <div class="icon-with-spinner"> <div class="spinner"></div> <span>Connecting...</span> </div> `; } else if (peerConnection && peerConnection.connectionState === 'connected') { startButton.innerHTML = ` <div class="pulse-container"> <div class="pulse-circle"></div> <span>Stop Recording</span> </div> `; } else { startButton.innerHTML = 'Start Recording'; } }
function showError(message) { const toast = document.getElementById('error-toast'); toast.textContent = message; toast.className = 'toast error'; toast.style.display = 'block';
// Hide toast after 5 seconds setTimeout(() => { toast.style.display = 'none'; }, 5000); } // Add a message to the conversation function addMessage(text, isUser = false) { const messageDiv = document.createElement('div'); messageDiv.className = isUser ? 'message user-message' : 'message bot-message'; messageDiv.textContent = text; conversation.appendChild(messageDiv); conversation.scrollTop = conversation.scrollHeight; } // Analyze repository analyzeButton.addEventListener('click', async () => { const repoUrl = repoUrlInput.value.trim(); const githubToken = githubTokenInput.value.trim(); if (!repoUrl || !githubToken) { showError('Please enter both repository URL and GitHub token'); return; } repoStatus.textContent = 'Analyzing repository...'; analyzeButton.disabled = true; try { const response = await fetch('/analyze_repository', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ repo_url: repoUrl, github_token: githubToken, gemini_api_key: apiKeyInput.value }) }); const result = await response.json(); if (result.status === 'success') { repoStatus.textContent = 'Repository analyzed successfully! You can now start voice chat.'; repoStatus.style.color = '#10b981'; repositoryAnalyzed = true; // Add message to conversation addMessage('I\'ve analyzed the repository. You can ask me questions about it now!', false); } else { repoStatus.textContent = 'Error analyzing repository: ' + result.message; repoStatus.style.color = '#f44336'; } } catch (err) { repoStatus.textContent = 'Error: ' + err.message; repoStatus.style.color = '#f44336'; } finally { analyzeButton.disabled = false; } });
async function setupWebRTC() { const config = __RTC_CONFIGURATION__; peerConnection = new RTCPeerConnection(config); webrtc_id = Math.random().toString(36).substring(7);
const timeoutId = setTimeout(() => { const toast = document.getElementById('error-toast'); toast.textContent = "Connection is taking longer than usual. Are you on a VPN?"; toast.className = 'toast warning'; toast.style.display = 'block';
// Hide warning after 5 seconds setTimeout(() => { toast.style.display = 'none'; }, 5000); }, 5000);
try { const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); stream.getTracks().forEach(track => peerConnection.addTrack(track, stream));
// Update audio visualization setup audioContext = new AudioContext(); analyser_input = audioContext.createAnalyser(); const source = audioContext.createMediaStreamSource(stream); source.connect(analyser_input); analyser_input.fftSize = 64; dataArray_input = new Uint8Array(analyser_input.frequencyBinCount);
function updateAudioLevel() { analyser_input.getByteFrequencyData(dataArray_input); const average = Array.from(dataArray_input).reduce((a, b) => a + b, 0) / dataArray_input.length; const audioLevel = average / 255;
const pulseCircle = document.querySelector('.pulse-circle'); if (pulseCircle) { console.log("audioLevel", audioLevel); pulseCircle.style.setProperty('--audio-level', 1 + audioLevel); }
animationId = requestAnimationFrame(updateAudioLevel); } updateAudioLevel();
// Add connection state change listener peerConnection.addEventListener('connectionstatechange', () => { console.log('connectionstatechange', peerConnection.connectionState); if (peerConnection.connectionState === 'connected') { clearTimeout(timeoutId); const toast = document.getElementById('error-toast'); toast.style.display = 'none'; // Add a user message indicating voice is active addMessage('Voice chat connected. You can speak now.', false); } updateButtonState(); });
// Handle incoming audio peerConnection.addEventListener('track', (evt) => { if (audioOutput && audioOutput.srcObject !== evt.streams[0]) { audioOutput.srcObject = evt.streams[0]; audioOutput.play();
// Set up audio visualization on the output stream audioContext = new AudioContext(); analyser = audioContext.createAnalyser(); const source = audioContext.createMediaStreamSource(evt.streams[0]); source.connect(analyser); analyser.fftSize = 2048; dataArray = new Uint8Array(analyser.frequencyBinCount); updateVisualization(); } });
// Create data channel for messages dataChannel = peerConnection.createDataChannel('text'); dataChannel.onmessage = (event) => { const eventJson = JSON.parse(event.data); if (eventJson.type === "error") { showError(eventJson.message); } else if (eventJson.type === "send_input") { fetch('/input_hook', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ webrtc_id: webrtc_id, api_key: apiKeyInput.value, voice_name: voiceSelect.value, repo_url: repoUrlInput.value, github_token: githubTokenInput.value }) }); } };
// Create and send offer const offer = await peerConnection.createOffer(); await peerConnection.setLocalDescription(offer);
await new Promise((resolve) => { if (peerConnection.iceGatheringState === "complete") { resolve(); } else { const checkState = () => { if (peerConnection.iceGatheringState === "complete") { peerConnection.removeEventListener("icegatheringstatechange", checkState); resolve(); } }; peerConnection.addEventListener("icegatheringstatechange", checkState); } });
const response = await fetch('/webrtc/offer', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ sdp: peerConnection.localDescription.sdp, type: peerConnection.localDescription.type, webrtc_id: webrtc_id, }) });
const serverResponse = await response.json();
if (serverResponse.status === 'failed') { showError(serverResponse.meta.error === 'concurrency_limit_reached' ? `Too many connections. Maximum limit is ${serverResponse.meta.limit}` : serverResponse.meta.error); stop(); startButton.textContent = 'Start Recording'; return; }
await peerConnection.setRemoteDescription(serverResponse); } catch (err) { clearTimeout(timeoutId); console.error('Error setting up WebRTC:', err); showError('Failed to establish connection. Please try again.'); stop(); startButton.textContent = 'Start Recording'; } }
function updateVisualization() { if (!analyser) return;
analyser.getByteFrequencyData(dataArray); const bars = document.querySelectorAll('.box');
for (let i = 0; i < bars.length; i++) { const barHeight = (dataArray[i] / 255) * 2; bars[i].style.transform = `scaleY(${Math.max(0.1, barHeight)})`; }
animationId = requestAnimationFrame(updateVisualization); }
function stopWebRTC() { if (peerConnection) { peerConnection.close(); } if (animationId) { cancelAnimationFrame(animationId); } if (audioContext) { audioContext.close(); } updateButtonState(); // Add message when voice chat ends addMessage('Voice chat ended. Click "Start Recording" to chat again.', false); }
startButton.addEventListener('click', () => { // Check if repository has been analyzed if (!repositoryAnalyzed) { showError('Please analyze a repository first by entering a URL and GitHub token above.'); return; } // Check if API key is provided if (!apiKeyInput.value.trim()) { showError('Please enter a Gemini API key.'); return; } if (!isRecording) { setupWebRTC(); startButton.classList.add('recording'); addMessage('Starting voice chat...', true); } else { stopWebRTC(); startButton.classList.remove('recording'); } isRecording = !isRecording; }); </script></body>
</html>1234567891011121314151617181920212223242526272829# Core dependenciesgradio==4.6.0PyGithub==2.1.1google-generativeai==0.7.0python-dotenv==1.0.0tenacity==8.2.3requests==2.31.0
# Voice chat dependenciesfastrtcnumpyfastapiuvicorntwilio
# Repository analysis dependenciesnltkspacytextblobmarkdownpygmentslangdetect
# Optional dependenciespydanticaiohttpbeautifulsoup4python-magicchardetapp.pyAdded+2134
index-html.htmlAdded+587
requirements.txtAdded+29