randeom commited on
Commit
36655d1
·
verified ·
1 Parent(s): dfa35d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -19
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, job_profession):
7
- system_prompt = f"You are a People Generator. You generate profiles based on user input. Please ensure that all responses are written in the second-person perspective. For example, a response should be structured as follows: 'You are (Name), (Age) years old from (Country), and an expert in the field of {job_profession}.' This format must be strictly followed in all outputs."
8
- prompt = f"<s>[SYS] {system_prompt} [/SYS][INST] {message} [/INST]</s>"
 
 
9
  return prompt
10
 
11
- def generate(message, job_profession, temperature=0.9, max_new_tokens=4192, top_p=0.95, repetition_penalty=1.0):
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("", actual_job) # message should be empty here if we're using job from input
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
- job_dropdown = gr.Dropdown(
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>GPT Prompt Generator<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=[message_input, job_dropdown],
62
  outputs=output_area
63
  )
64
 
65
  gr.Markdown("""
66
  ---
67
  ### Meta Information
68
- **Project Title**: GPT Prompt Generator
69
 
70
- **Github**: [https://github.com/pacnimo/gpt-prompt-generator](https://github.com/pacnimo/gpt-prompt-generator)
71
 
72
- **Description**: GPT Prompt Generator is Free and Easy to Use. Create a GPT Prompt Based on the Profession. 1 Click Prompt Generator.
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