Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the agent-builder model
|
5 |
+
model_name = "dnnsdunca/agent-builder"
|
6 |
+
agent = pipeline("text-generation", model=model_name)
|
7 |
+
|
8 |
+
def generate_response(prompt):
|
9 |
+
response = agent(prompt, max_length=200, num_return_sequences=1)
|
10 |
+
return response[0]['generated_text']
|
11 |
+
|
12 |
+
# Define the Gradio interface
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=generate_response,
|
15 |
+
inputs="text",
|
16 |
+
outputs="text",
|
17 |
+
title="Agent Builder",
|
18 |
+
description="This app uses the dnnsdunca/agent-builder model to generate responses based on your input prompts.",
|
19 |
+
examples=[
|
20 |
+
["What is the weather like today?"],
|
21 |
+
["Write a Python function to reverse a string."]
|
22 |
+
]
|
23 |
+
)
|
24 |
+
|
25 |
+
# Launch the app
|
26 |
+
if __name__ == "__main__":
|
27 |
+
iface.launch()
|