Spaces:
Sleeping
Sleeping
Canvas_2 ready basic version
Browse files132 unmodified lines13313413513613713872 unmodified lines2112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472 unmodified lines250251252253254255256132 unmodified linesthe user in a single space formatHave the user review all the beats and confirm if they are happy with the beats or if they want to make further changes"""dataset_file_name = settings.DATA_FILE72 unmodified linesdef predict(message, history, feedback, btn):history.append({"role": "system", "content": system_prompt_canvas_1})history.append({"role": "user", "content": message})stream = client.chat.completions.create(messages=history,# model="Meta-Llama-3.1-70B-Instruct-8k",model ="Meta-Llama-3.3-70B-Instruct",temperature= 0.8,stream=True)chunks = []for chunk in stream:chunks.append(chunk.choices[0].delta.content or "")yield "".join(chunks)with gr.Blocks(fill_height=True) as demo:# Textbox to display the outline, initially hiddenfile_display = gr.Textbox(label="Outline",placeholder="The story outline...",lines=10,visible=False)chatinterface = gr.ChatInterface(predict,type="messages",title="scripti",examples=[[{"text": "What would YOU like to write today?"}]],show_progress="full",)feedback= gr.Textbox(label = "Feedback", placeholder = "Help us make scripti better, provide feedback here..") # render = Falsebtn = gr.Button(value="Share feedback") # render= Falsecallback.setup([chatinterface.chatbot, feedback], "evals")# btn.click(lambda *args: callback.flag(list(args)),2 unmodified lineslambda: None, None, feedback, queue= False)clear_button= gr.ClearButton()clear_button.click(lambda *args: (None, None), outputs=[chatinterface.chatbot, feedback])# create_beatsheet_button = gr.Button("Create Beat sheet")demo.launch()132 unmodified lines13313413513613713813914072 unmodified lines2132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752 unmodified lines278279280281282283284285286287288289290291292293294295296297298299132 unmodified linesthe user in a single space formatHave the user review all the beats and confirm if they are happy with the beats or if they want to make further changesThe below conversation happened between user and an expert screen writer assistant so far where user and their screen writer assistant came up witha high level story outline, and key Story Beats:"""dataset_file_name = settings.DATA_FILE72 unmodified linesdef predict(message, history, feedback, btn):history.append({"role": "system", "content": system_prompt_canvas_1})history.append({"role": "user", "content": message})print ("-----------------------------FIRST PROMPT", history)stream = client.chat.completions.create(messages=history,model="Meta-Llama-3.1-70B-Instruct-8k",# model ="Meta-Llama-3.3-70B-Instruct",temperature= 0.8,stream=True)chunks = []for chunk in stream:chunks.append(chunk.choices[0].delta.content or "")yield "".join(chunks)def predict_beat_sheet(message, history_beatsheet, canvas_1_context):# print ("canvas_1_context:", canvas_1_context)system_prompt = f"{system_prompt_canvas_2}\n ### {canvas_1_context} ###"# system_prompt = f"{system_prompt_canvas_2}"history_beatsheet.append({"role": "system", "content": system_prompt})history_beatsheet.append({"role": "user", "content": message})print ("-----------------------------ALL TOEGTEHER PROMPT", history_beatsheet)stream = client.chat.completions.create(messages=history_beatsheet,model="Meta-Llama-3.1-70B-Instruct-8k",# model ="Meta-Llama-3.3-70B-Instruct",temperature= 0.8,stream=True)chunks = []for chunk in stream:chunks.append(chunk.choices[0].delta.content or "")yield "".join(chunks)# return "HHAHAHA"def show_beat_sheet(canvas_1_history):inference_output= str(canvas_1_history)canvas_1_context= str(canvas_1_history)return gr.update(visible= True), inference_output, canvas_1_context, gr.update(visible= True)with gr.Blocks(fill_height=True) as demo:canvas_1_context = gr.Textbox(label="canvas_1_context_stuff", render= False)with gr.Column() as train_section:# gr.Markdown("## Train")chatinterface = gr.ChatInterface(predict,type="messages",title="scripti",examples=[[{"text": "What would YOU like to write today?"}]],show_progress="full",# additional_outputs=[canvas_1_context])feedback= gr.Textbox(label = "Feedback", placeholder = "Help us make scripti better, provide feedback here..", render = False) # render = Falsebtn = gr.Button(value="Share feedback", render = False) # render= Falsecallback.setup([chatinterface.chatbot, feedback], "evals")# btn.click(lambda *args: callback.flag(list(args)),2 unmodified lineslambda: None, None, feedback, queue= False)clear_button= gr.ClearButton()clear_button.click(lambda *args: (None, None), outputs=[chatinterface.chatbot, feedback])create_beatsheet_button = gr.Button("Create Beat sheet")with gr.Column(visible=False) as inference_section:gr.Markdown("## Beat sheet")inference_output = gr.Textbox(label="Inference Output")canvas_1_context.render()# print("Anything here:",inference_output.value)chatinterface_beatsheet = gr.ChatInterface(predict_beat_sheet,type="messages",title="scripti_beatsheet",examples=[[{"text": "Lets write beat today"}]],show_progress="full",additional_inputs=[canvas_1_context])create_beatsheet_button.click(fn=show_beat_sheet, inputs= [chatinterface.chatbot], outputs=[inference_section, inference_output, canvas_1_context, canvas_1_context])demo.launch()
app.py+57-14