mgbam commited on
Commit
072365a
·
verified ·
1 Parent(s): 9ab6f28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -1,15 +1,14 @@
1
  # app.py
2
  """
3
- Main application file for SHASHA AI, a Gradio‑based AI code‑generation tool.
4
-
5
- Only change: reduce logo width so the banner isn’t full‑width.
6
  """
7
 
8
  import gradio as gr
9
  from typing import Optional, Dict, List, Tuple, Any
10
  import os
11
 
12
- # --- Local module imports ---
13
  from constants import (
14
  HTML_SYSTEM_PROMPT,
15
  TRANSFORMERS_JS_SYSTEM_PROMPT,
@@ -30,7 +29,6 @@ from utils import (
30
  )
31
  from deploy import send_to_sandbox
32
 
33
- # --- Aliases ---
34
  History = List[Tuple[str, str]]
35
  Model = Dict[str, Any]
36
 
@@ -63,15 +61,16 @@ def generation_code(
63
  )
64
  model_id = current_model["id"]
65
  provider = (
66
- "openai" if model_id.startswith("openai/") or model_id in {"gpt-4","gpt-3.5-turbo"}
67
- else "gemini" if model_id.startswith(("gemini/","google/"))
68
  else "fireworks-ai" if model_id.startswith("fireworks-ai/")
69
  else "auto"
70
  )
71
 
72
  msgs = history_to_messages(history, system_prompt)
73
  context = query
74
- if file: context += f"\n\n[Attached file]\n{extract_text_from_file(file)[:5000]}"
 
75
  if website_url:
76
  wtext = extract_website_content(website_url)
77
  if not wtext.startswith("Error"):
@@ -79,7 +78,7 @@ def generation_code(
79
  msgs.append({"role":"user","content":enhance_query_with_search(context, enable_search)})
80
 
81
  client = get_inference_client(model_id, provider)
82
- resp = client.chat.completions.create(model=model_id, messages=msgs, max_tokens=16000, temperature=0.1)
83
  content = resp.choices[0].message.content
84
 
85
  except Exception as e:
@@ -117,10 +116,10 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"),
117
  initial_model = AVAILABLE_MODELS[0]
118
  model_state = gr.State(initial_model)
119
 
 
120
  if os.path.exists(LOGO_PATH):
121
- gr.Image(value=LOGO_PATH, height=70, width=70,
122
- show_label=False, container=False,
123
- elem_id="banner_logo")
124
 
125
  gr.Markdown("# 🚀 Shasha AI", elem_id="main_title")
126
  gr.Markdown("Your AI partner for generating, modifying, and understanding code.", elem_id="subtitle")
 
1
  # app.py
2
  """
3
+ Main application file for SHASHA AI (Gradio).
4
+ Only change: enlarge logo to 120 × 120 px.
 
5
  """
6
 
7
  import gradio as gr
8
  from typing import Optional, Dict, List, Tuple, Any
9
  import os
10
 
11
+ # --- Local imports ---
12
  from constants import (
13
  HTML_SYSTEM_PROMPT,
14
  TRANSFORMERS_JS_SYSTEM_PROMPT,
 
29
  )
30
  from deploy import send_to_sandbox
31
 
 
32
  History = List[Tuple[str, str]]
33
  Model = Dict[str, Any]
34
 
 
61
  )
62
  model_id = current_model["id"]
63
  provider = (
64
+ "openai" if model_id.startswith("openai/") or model_id in {"gpt-4","gpt-3.5-turbo"}
65
+ else "gemini" if model_id.startswith(("gemini/","google/"))
66
  else "fireworks-ai" if model_id.startswith("fireworks-ai/")
67
  else "auto"
68
  )
69
 
70
  msgs = history_to_messages(history, system_prompt)
71
  context = query
72
+ if file:
73
+ context += f"\n\n[Attached file]\n{extract_text_from_file(file)[:5000]}"
74
  if website_url:
75
  wtext = extract_website_content(website_url)
76
  if not wtext.startswith("Error"):
 
78
  msgs.append({"role":"user","content":enhance_query_with_search(context, enable_search)})
79
 
80
  client = get_inference_client(model_id, provider)
81
+ resp = client.chat.completions.create(model=model_id, messages=msgs,max_tokens=16000,temperature=0.1)
82
  content = resp.choices[0].message.content
83
 
84
  except Exception as e:
 
116
  initial_model = AVAILABLE_MODELS[0]
117
  model_state = gr.State(initial_model)
118
 
119
+ # enlarged logo (120×120 px)
120
  if os.path.exists(LOGO_PATH):
121
+ gr.Image(value=LOGO_PATH, height=120, width=120,
122
+ show_label=False, container=False)
 
123
 
124
  gr.Markdown("# 🚀 Shasha AI", elem_id="main_title")
125
  gr.Markdown("Your AI partner for generating, modifying, and understanding code.", elem_id="subtitle")