Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
|
|
4 |
client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")
|
5 |
|
6 |
-
def format_prompt(message,
|
7 |
-
system_prompt =
|
8 |
-
|
|
|
|
|
9 |
return prompt
|
10 |
|
11 |
-
def generate(
|
12 |
-
# Parse the input to determine job profession based on the presence of a message.
|
13 |
-
actual_job = message if message else job_profession
|
14 |
-
|
15 |
temperature = float(temperature)
|
16 |
if temperature < 1e-2:
|
17 |
temperature = 1e-2
|
@@ -26,7 +26,7 @@ def generate(message, job_profession, temperature=0.9, max_new_tokens=4192, top_
|
|
26 |
"seed": 42,
|
27 |
}
|
28 |
|
29 |
-
formatted_prompt = format_prompt("",
|
30 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
31 |
output = ""
|
32 |
|
@@ -46,30 +46,25 @@ with gr.Blocks(css=css) as gpt:
|
|
46 |
with gr.Row():
|
47 |
with gr.Column(scale=2):
|
48 |
gr.HTML("<h1>Settings</h1>")
|
49 |
-
|
50 |
-
label="Choose a job profession",
|
51 |
-
choices=["Relationship Expert", "Sales Manager", "Blue Team Hacker", "Senior Web Developer", "C++ Developer", "Article Author", "News Anchor", "Finance Advisor"],
|
52 |
-
value="Relationship Expert" # Initial value
|
53 |
-
)
|
54 |
with gr.Column(scale=3):
|
55 |
-
gr.HTML("<h1><center>
|
56 |
-
message_input = gr.Textbox(label="Input your message (overrides job dropdown)", placeholder="Type a job profession here to override the dropdown...")
|
57 |
generate_button = gr.Button("Generate")
|
58 |
output_area = gr.Textbox(label="AI Response", interactive=False, lines=10)
|
59 |
generate_button.click(
|
60 |
fn=generate,
|
61 |
-
inputs=[
|
62 |
outputs=output_area
|
63 |
)
|
64 |
|
65 |
gr.Markdown("""
|
66 |
---
|
67 |
### Meta Information
|
68 |
-
**Project Title**:
|
69 |
|
70 |
-
**Github**: [https://github.com/pacnimo/gpt-prompt-generator](https://github.com/pacnimo/
|
71 |
|
72 |
-
**Description**:
|
73 |
|
74 |
**Footer**: © 2024 by [pacnimo](https://github.com/pacnimo/). All rights reserved.
|
75 |
""") # Meta, project description, and footer added here
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
4 |
+
# Initialize the HuggingFace Inference Client with the specified model
|
5 |
client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")
|
6 |
|
7 |
+
def format_prompt(message, logo_request):
|
8 |
+
system_prompt = """
|
9 |
+
You are an advanced language model designed to create detailed and creative image prompts for logo generation. Based on the user's input, generate an elaborate and descriptive image prompt that can be used to create a high-quality logo. Ensure that the prompt is clear, imaginative, and provides specific details that will guide the logo creation process effectively.
|
10 |
+
"""
|
11 |
+
prompt = f"<s>[SYS] {system_prompt} [/SYS][INST] {logo_request} [/INST]</s>"
|
12 |
return prompt
|
13 |
|
14 |
+
def generate(logo_request, temperature=0.9, max_new_tokens=512, top_p=0.95, repetition_penalty=1.0):
|
|
|
|
|
|
|
15 |
temperature = float(temperature)
|
16 |
if temperature < 1e-2:
|
17 |
temperature = 1e-2
|
|
|
26 |
"seed": 42,
|
27 |
}
|
28 |
|
29 |
+
formatted_prompt = format_prompt("", logo_request)
|
30 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
31 |
output = ""
|
32 |
|
|
|
46 |
with gr.Row():
|
47 |
with gr.Column(scale=2):
|
48 |
gr.HTML("<h1>Settings</h1>")
|
49 |
+
logo_input = gr.Textbox(label="Input your logo request", placeholder="Describe the logo you want...")
|
|
|
|
|
|
|
|
|
50 |
with gr.Column(scale=3):
|
51 |
+
gr.HTML("<h1><center>Logo Prompt Generator<h1><center>")
|
|
|
52 |
generate_button = gr.Button("Generate")
|
53 |
output_area = gr.Textbox(label="AI Response", interactive=False, lines=10)
|
54 |
generate_button.click(
|
55 |
fn=generate,
|
56 |
+
inputs=[logo_input],
|
57 |
outputs=output_area
|
58 |
)
|
59 |
|
60 |
gr.Markdown("""
|
61 |
---
|
62 |
### Meta Information
|
63 |
+
**Project Title**: Logo Prompt Generator
|
64 |
|
65 |
+
**Github**: [https://github.com/pacnimo/gpt-prompt-generator](https://github.com/pacnimo/)
|
66 |
|
67 |
+
**Description**: Logo Prompt Generator is Free and Easy to Use. Create a GPT Prompt Based on the Logo Request. 1 Click Prompt Generator.
|
68 |
|
69 |
**Footer**: © 2024 by [pacnimo](https://github.com/pacnimo/). All rights reserved.
|
70 |
""") # Meta, project description, and footer added here
|