Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,16 +60,41 @@
|
|
| 60 |
# chatbot = gr.ChatInterface(YourCoder_chatbot, title="YourCoder Chatbot", description="Enter piece of code to generate a code review!")
|
| 61 |
# chatbot.launch()
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
import gradio as gr
|
|
|
|
| 64 |
|
| 65 |
-
#
|
| 66 |
-
#
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
#
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
|
|
|
|
|
|
| 60 |
# chatbot = gr.ChatInterface(YourCoder_chatbot, title="YourCoder Chatbot", description="Enter piece of code to generate a code review!")
|
| 61 |
# chatbot.launch()
|
| 62 |
|
| 63 |
+
# import gradio as gr
|
| 64 |
+
|
| 65 |
+
# # def YourCoder_chatbot(message, history):
|
| 66 |
+
# # gr.load("models/bigcode/starcoder")
|
| 67 |
+
|
| 68 |
+
# # chatbot = gr.ChatInterface(YourCoder_chatbot, title="YourCoder Chatbot", description="Enter piece of code to generate a code review!")
|
| 69 |
+
# chatbot = gr.Interface(fn=gr.load("models/bigcode/starcoder"), inputs=[gr.Textbox(label="Insert Code Snippet",lines=5)],
|
| 70 |
+
# outputs=[gr.Textbox(label="Review Here",lines=8)],
|
| 71 |
+
# title="Code Reviewer"
|
| 72 |
+
# )
|
| 73 |
+
# # gr.load("models/bigcode/starcoder").launch()
|
| 74 |
+
|
| 75 |
+
# chatbot.launch()
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
#####################
|
| 79 |
+
import os
|
| 80 |
import gradio as gr
|
| 81 |
+
from transformers import pipeline
|
| 82 |
|
| 83 |
+
# Get the token from environment variables
|
| 84 |
+
# token = os.getenv("HUGGINGFACE_TOKEN")
|
| 85 |
+
# if token is None:
|
| 86 |
+
# raise ValueError("Hugging Face token is not set in the environment variables.")
|
| 87 |
|
| 88 |
+
# Load the model from the Hugging Face Model Hub with authentication
|
| 89 |
+
generator = pipeline('text-generation', model='bigcode/starcoder', use_auth_token=token)
|
| 90 |
+
|
| 91 |
+
# Define the prediction function
|
| 92 |
+
def generate_text(prompt):
|
| 93 |
+
result = generator(prompt, max_length=50)
|
| 94 |
+
return result[0]['generated_text']
|
| 95 |
+
|
| 96 |
+
# Create the Gradio interface
|
| 97 |
+
iface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
| 98 |
|
| 99 |
+
# Launch the app
|
| 100 |
+
iface.launch()
|