Spaces:
Runtime error
Runtime error
Download app.py from rmikeyjohnson314/cc: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/spaces/rmikeyjohnson314/cc/resolve/main/app.py
- Command line
-
hf download hf://spaces/rmikeyjohnson314/cc/app.py
-
curl -L -o app.py https://huggingface.co/spaces/rmikeyjohnson314/cc/resolve/main/app.py
1.51 kB
| # app.py | |
| import gradio as gr | |
| from transformers import pipeline, Conversation | |
| # Use a public coding model, e.g. CodeLlama | |
| model_name = "deepseek-ai/deepseek-coder-6.7b-instruct" | |
| chatbot = pipeline("text-generation", model=model_name) | |
| def generate_response(prompt): | |
| response = chatbot(prompt, max_length=1024, temperature=0.7)[0]['generated_text'] | |
| return response.strip() | |
| import gradio as gr | |
| iface = gr.ChatInterface(fn=generate_response, title="Cohort Developer AI", description="AI Developer for Cohort.") | |
| iface.launch() | |
| --- | |
| ### **Step 3: GitHub Integration (Auto-Deployment & Version Control)** | |
| Your AI can directly commit code to GitHub via GitHub's REST API calls. Here's how you do it simply from your AI code: | |
| ```python | |
| import requests | |
| def push_to_github(repo, file_path, content, commit_message, github_token): | |
| url = f'https://api.github.com/repos/{repo}/contents/{file_path}' | |
| headers = { | |
| 'Authorization': f'token {github_token}', | |
| 'Accept': 'application/vnd.github.v3+json', | |
| } | |
| data = { | |
| 'message': commit_message, | |
| 'content': content.encode('utf-8').decode('utf-8'), | |
| } | |
| response = requests.put(url, headers=headers, json=data) | |
| return response.json() | |
| # Example usage | |
| repo = 'your-username/cohort' | |
| file_path = 'app.py' | |
| content = open('app.py').read().encode('utf-8').decode('utf-8') | |
| commit_message = 'Update app.py by AI' | |
| github_token = 'YOUR_GITHUB_TOKEN' | |
| push_to_github(repo, file_path, content, commit_message, github_token) | |