acecalisto3 commited on
Commit
e84be5f
1 Parent(s): ded0f49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -21
app.py CHANGED
@@ -1,21 +1,50 @@
 
 
1
  import subprocess
2
- import streamlit as st
3
- from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer, AutoModel, RagRetriever, AutoModelForSeq2SeqLM
 
 
 
 
 
 
 
 
 
4
  import black
5
  from pylint import lint
6
  from io import StringIO
7
  import sys
8
- import torch
9
- from huggingface_hub import hf_hub_url, cached_download, HfApi
10
 
11
- # Set your Hugging Face API key here
12
- hf_token = "YOUR_HUGGING_FACE_API_KEY" # Replace with your actual token
13
 
14
- HUGGING_FACE_REPO_URL = "https://huggingface.co/spaces/acecalisto3/DevToolKit"
 
15
  PROJECT_ROOT = "projects"
16
  AGENT_DIRECTORY = "agents"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- # Global state to manage communication between Tool Box and Workspace Chat App
19
  if 'chat_history' not in st.session_state:
20
  st.session_state.chat_history = []
21
  if 'terminal_history' not in st.session_state:
@@ -30,6 +59,7 @@ if 'current_state' not in st.session_state:
30
  'workspace_chat': {}
31
  }
32
 
 
33
  # List of top downloaded free code-generative models from Hugging Face Hub
34
  AVAILABLE_CODE_GENERATIVE_MODELS = [
35
  "bigcode/starcoder", # Popular and powerful
@@ -461,19 +491,7 @@ elif app_mode == "Workspace Chat App":
461
  # Function to create a Space on Hugging Face
462
  def create_space(api, name, description, public, files, entrypoint="launch.py"):
463
  url = f"{hf_hub_url()}spaces/{name}/prepare-repo"
464
- headers = {"Authorization": f"Bearer {api.access_token}"}````
465
-
466
- i need to integrate logic from these below, into my existing app.py above:
467
- ````import os
468
- import subprocess
469
- import streamlit as st
470
- from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer, AutoModel, RagRetriever, AutoModelForSeq2SeqLM
471
- import black
472
- from pylint import lint
473
- from io import StringIO
474
- import sys
475
- import torch
476
- from huggingface_hub import hf_hub_url, cached_download, HfApi
477
 
478
  # Set your Hugging Face API key here
479
  hf_token = "YOUR_HUGGING_FACE_API_KEY" # Replace with your actual token
 
1
+ import os
2
+ import json
3
  import subprocess
4
+ import re
5
+ import ast
6
+ import requests
7
+ from datetime import datetime
8
+
9
+ import gradio as gr
10
+ from transformers import (pipeline, AutoModelForCausalLM, AutoTokenizer, TextGenerationPipeline,
11
+ TrainingArguments, Trainer, AutoModel, RagRetriever, AutoModelForSeq2SeqLM)
12
+ import torch
13
+ import tree_sitter
14
+ from tree_sitter import Language, Parser
15
  import black
16
  from pylint import lint
17
  from io import StringIO
18
  import sys
19
+ from huggingface_hub import Repository, hf_hub_url, HfApi, snapshot_download
20
+ import tempfile
21
 
 
 
22
 
23
+ # Constants
24
+ MODEL_NAME = "bigscience/bloom"
25
  PROJECT_ROOT = "projects"
26
  AGENT_DIRECTORY = "agents"
27
+ AVAILABLE_CODE_GENERATIVE_MODELS = [
28
+ "bigcode/starcoder",
29
+ "Salesforce/codegen-350M-mono",
30
+ "microsoft/CodeGPT-small",
31
+ "google/flan-t5-xl",
32
+ "facebook/bart-large-cnn",
33
+ ]
34
+
35
+
36
+ # Load Models and Resources
37
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
38
+ model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, torch_dtype=torch.float16)
39
+ pipe = TextGenerationPipeline(model=model, tokenizer=tokenizer)
40
+
41
+ # Build Tree-sitter parser libraries (if not already built)
42
+ Language.build_library('build/my-languages.so', ['tree-sitter-python', 'tree-sitter-javascript'])
43
+ PYTHON_LANGUAGE = Language('build/my-languages.so', 'python')
44
+ JAVASCRIPT_LANGUAGE = Language('build/my-languages.so', 'javascript')
45
+ parser = Parser()
46
 
47
+ # Session State Initialization
48
  if 'chat_history' not in st.session_state:
49
  st.session_state.chat_history = []
50
  if 'terminal_history' not in st.session_state:
 
59
  'workspace_chat': {}
60
  }
61
 
62
+
63
  # List of top downloaded free code-generative models from Hugging Face Hub
64
  AVAILABLE_CODE_GENERATIVE_MODELS = [
65
  "bigcode/starcoder", # Popular and powerful
 
491
  # Function to create a Space on Hugging Face
492
  def create_space(api, name, description, public, files, entrypoint="launch.py"):
493
  url = f"{hf_hub_url()}spaces/{name}/prepare-repo"
494
+ headers = {"Authorization": f"Bearer {api.access_token}"}
 
 
 
 
 
 
 
 
 
 
 
 
495
 
496
  # Set your Hugging Face API key here
497
  hf_token = "YOUR_HUGGING_FACE_API_KEY" # Replace with your actual token