Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
model_name = "curiouscurrent/omnicode"
|
| 6 |
text_generator = pipeline("text-generation", model=model_name)
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
def generate_response(prompt):
|
| 11 |
-
history.append(prompt)
|
| 12 |
-
final_prompt = "\n".join(history)
|
| 13 |
-
|
| 14 |
# Generate response
|
| 15 |
-
response = text_generator(
|
| 16 |
-
|
| 17 |
return response
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load your text generation model from Hugging Face
|
| 5 |
model_name = "curiouscurrent/omnicode"
|
| 6 |
text_generator = pipeline("text-generation", model=model_name)
|
| 7 |
|
| 8 |
+
def generate_response(input_prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# Generate response
|
| 10 |
+
response = text_generator(input_prompt, max_length=100)[0]['generated_text']
|
|
|
|
| 11 |
return response
|
| 12 |
|
| 13 |
+
# Create Gradio interface
|
| 14 |
+
input_prompt = gr.inputs.Textbox(lines=5, label="Input Prompt")
|
| 15 |
+
output_text = gr.outputs.Textbox(label="Response")
|
| 16 |
+
|
| 17 |
+
gr.Interface(
|
| 18 |
+
generate_response,
|
| 19 |
+
inputs=input_prompt,
|
| 20 |
+
outputs=output_text,
|
| 21 |
+
title="OmniCode",
|
| 22 |
+
description="Multi Programming coding assistant.",
|
| 23 |
+
theme="compact"
|
| 24 |
+
).launch()
|