Rahatara commited on
Commit
4c2616b
·
verified ·
1 Parent(s): b0cf6ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -9
app.py CHANGED
@@ -4,12 +4,10 @@ import os
4
 
5
  client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
6
 
7
- SYSTEM_PROMPT = """You are an expert storyboard generator. Create detailed storyboards with:
8
- - Shot numbers, visual descriptions, camera angles
9
- - Actions, dialogue, sound effects, timing
10
- Format as markdown tables. Be creative and cinematic."""
11
 
12
- def respond(message, history):
13
  messages = [{"role": "system", "content": SYSTEM_PROMPT}]
14
 
15
  for h in history:
@@ -21,16 +19,16 @@ def respond(message, history):
21
 
22
  try:
23
  response = client.chat.completions.create(
24
- model="llama-3.3-70b-versatile",
25
  messages=messages,
26
- temperature=0.9,
27
- max_completion_tokens=2048,
28
  )
29
  return response.choices[0].message.content
30
  except Exception as e:
31
  return f"Error: {str(e)}"
32
 
33
- # Simple ChatInterface - most compatible
34
  demo = gr.ChatInterface(
35
  fn=respond,
36
  title="🎬 Storyboard Generator AI",
@@ -40,6 +38,36 @@ demo = gr.ChatInterface(
40
  "Generate a horror movie opening scene storyboard",
41
  "Design a storyboard for a romantic comedy meet-cute at a bookstore",
42
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  theme="soft",
44
  )
45
 
 
4
 
5
  client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
6
 
7
+ SYSTEM_PROMPT = """You are an expert in storyboarding. Provide structured and insightful responses to queries
8
+ about creating and refining storyboards"""
 
 
9
 
10
+ def respond(message, history, model, temperature, max_tokens):
11
  messages = [{"role": "system", "content": SYSTEM_PROMPT}]
12
 
13
  for h in history:
 
19
 
20
  try:
21
  response = client.chat.completions.create(
22
+ model=model,
23
  messages=messages,
24
+ temperature=temperature,
25
+ max_completion_tokens=max_tokens,
26
  )
27
  return response.choices[0].message.content
28
  except Exception as e:
29
  return f"Error: {str(e)}"
30
 
31
+ # ChatInterface with additional inputs for parameters
32
  demo = gr.ChatInterface(
33
  fn=respond,
34
  title="🎬 Storyboard Generator AI",
 
38
  "Generate a horror movie opening scene storyboard",
39
  "Design a storyboard for a romantic comedy meet-cute at a bookstore",
40
  ],
41
+ additional_inputs=[
42
+ gr.Dropdown(
43
+ choices=[
44
+ "llama-3.3-70b-versatile",
45
+ "llama-3.1-70b-versatile",
46
+ "llama-3.1-8b-instant",
47
+ "mixtral-8x7b-32768",
48
+ "gemma2-9b-it"
49
+ ],
50
+ value="llama-3.3-70b-versatile",
51
+ label="Model",
52
+ info="Select the AI model to use"
53
+ ),
54
+ gr.Slider(
55
+ minimum=0,
56
+ maximum=2,
57
+ value=0.9,
58
+ step=0.1,
59
+ label="Temperature",
60
+ info="Controls randomness. Lower = more focused, Higher = more creative"
61
+ ),
62
+ gr.Slider(
63
+ minimum=256,
64
+ maximum=8192,
65
+ value=2048,
66
+ step=256,
67
+ label="Max Tokens",
68
+ info="Maximum length of the response"
69
+ ),
70
+ ],
71
  theme="soft",
72
  )
73