Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -80,7 +80,9 @@ I am confident that I can leverage my expertise to assist you in developing and
|
|
| 80 |
return self._hf_api.whoami(token=hf_token) is not None
|
| 81 |
|
| 82 |
def process_input(input_text: str) -> str:
|
| 83 |
-
|
|
|
|
|
|
|
| 84 |
response = chatbot(input_text, max_length=50, num_return_sequences=1)[0]['generated_text']
|
| 85 |
return response
|
| 86 |
|
|
@@ -130,8 +132,10 @@ def display_ai_guide_chat(chat_history: List[tuple[str, str]]):
|
|
| 130 |
st.markdown(f"<div class='chat-message agent'>{agent_message}</div>", unsafe_allow_html=True)
|
| 131 |
st.markdown("</div>", unsafe_allow_html=True)
|
| 132 |
|
|
|
|
|
|
|
| 133 |
# Load the CodeGPT model for code completion
|
| 134 |
-
code_generator = pipeline("text-generation", model="microsoft/CodeGPT-small-py", tokenizer=
|
| 135 |
|
| 136 |
def analyze_code(code: str) -> List[str]:
|
| 137 |
hints = []
|
|
@@ -156,7 +160,8 @@ def analyze_code(code: str) -> List[str]:
|
|
| 156 |
|
| 157 |
def get_code_completion(prompt: str) -> str:
|
| 158 |
# Generate code completion based on the current code input
|
| 159 |
-
|
|
|
|
| 160 |
return completions[0]['generated_text']
|
| 161 |
|
| 162 |
def lint_code(code: str) -> List[str]:
|
|
|
|
| 80 |
return self._hf_api.whoami(token=hf_token) is not None
|
| 81 |
|
| 82 |
def process_input(input_text: str) -> str:
|
| 83 |
+
# Load the DialoGPT tokenizer explicitly
|
| 84 |
+
chatbot_tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium", clean_up_tokenization_spaces=True)
|
| 85 |
+
chatbot = pipeline("text-generation", model="microsoft/DialoGPT-medium", tokenizer=chatbot_tokenizer)
|
| 86 |
response = chatbot(input_text, max_length=50, num_return_sequences=1)[0]['generated_text']
|
| 87 |
return response
|
| 88 |
|
|
|
|
| 132 |
st.markdown(f"<div class='chat-message agent'>{agent_message}</div>", unsafe_allow_html=True)
|
| 133 |
st.markdown("</div>", unsafe_allow_html=True)
|
| 134 |
|
| 135 |
+
# Load the CodeGPT tokenizer explicitly
|
| 136 |
+
code_generator_tokenizer = AutoTokenizer.from_pretrained("microsoft/CodeGPT-small-py", clean_up_tokenization_spaces=True)
|
| 137 |
# Load the CodeGPT model for code completion
|
| 138 |
+
code_generator = pipeline("text-generation", model="microsoft/CodeGPT-small-py", tokenizer=code_generator_tokenizer)
|
| 139 |
|
| 140 |
def analyze_code(code: str) -> List[str]:
|
| 141 |
hints = []
|
|
|
|
| 160 |
|
| 161 |
def get_code_completion(prompt: str) -> str:
|
| 162 |
# Generate code completion based on the current code input
|
| 163 |
+
# Use max_new_tokens instead of max_length
|
| 164 |
+
completions = code_generator(prompt, max_new_tokens=50, num_return_sequences=1)
|
| 165 |
return completions[0]['generated_text']
|
| 166 |
|
| 167 |
def lint_code(code: str) -> List[str]:
|