Norod78 commited on
Commit
64778e5
·
verified ·
1 Parent(s): 797e99d
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -90,6 +90,32 @@ def format_conversation_history(chat_history):
90
 
91
  @spaces.GPU(duration=120)
92
  def generate_response(input_data, chat_history, max_new_tokens, system_prompt, temperature, top_p, top_k, repetition_penalty):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  if isinstance(input_data, dict) and "text" in input_data:
94
  text = input_data["text"]
95
  files = input_data.get("files", [])
 
90
 
91
  @spaces.GPU(duration=120)
92
  def generate_response(input_data, chat_history, max_new_tokens, system_prompt, temperature, top_p, top_k, repetition_penalty):
93
+ """
94
+ Creates silly song lyrics in Hebrew based on user input and conversation history.
95
+
96
+ Args:
97
+ input_data (dict or str):
98
+ - If dict: must include 'text' (str) and optional 'files' (list of image/video file paths).
99
+ - If str: treated as plain text input.
100
+ chat_history (list of dict):
101
+ Sequence of past messages, each with keys 'role' and 'content'.
102
+ max_new_tokens (int):
103
+ Maximum number of tokens to generate for the response.
104
+ system_prompt (str):
105
+ Optional system-level instruction to guide the style and content of the response.
106
+ temperature (float):
107
+ Sampling temperature; higher values yield more diverse outputs.
108
+ top_p (float):
109
+ Nucleus sampling threshold for cumulative probability selection.
110
+ top_k (int):
111
+ Limits sampling to the top_k most likely tokens at each step.
112
+ repetition_penalty (float):
113
+ Penalty factor to discourage the model from repeating the same tokens.
114
+
115
+ Yields:
116
+ str: Streaming chunks of the generated Hebrew song lyrics in real time.
117
+ """
118
+
119
  if isinstance(input_data, dict) and "text" in input_data:
120
  text = input_data["text"]
121
  files = input_data.get("files", [])