Spaces:
Runtime error
Runtime error
Update app.py
Browse files123456789101112131415162 unmodified lines19202122232425262728import gradioimport openaiimport os#Streaming endpointAPI_URL = "https://api.openai.com/v1/chat/completions" #os.getenv("API_URL") + "/generate_stream"#Huggingface provided GPT4 OpenAI API KeyOPENAI_API_KEY = os.getenv("OPENAI_API_KEY")messages = [{"role": "system", "content": "Below is a transcript of a call, when critiquing, please attempt to understand who the salesperson and prospect are when analyzing this transcript but do not present the transcript back to me unless you are pulling a specific quote for further instruction. Ignore any spelling issues or errors as this is a transcript that may not be 100% accurate. Do your best to fill in the gaps and error on the side of the salesperson for any potential critiques. Then act as cold call sales expert Jeb Blount and give a detailed analysis and critique of this call. Do not contextualize who you are in the beginning. Do not say I. Do not say sales expert. Do not say Jeff Blount. Begin with a quick analysis of the call. Then make sure to list strengths as well as areas that use improvement and call the areas that could use improvement as potential things to consider. End with a complimentary closing that summarizes the analysis and gives a hopeful outlook on the future but don’t say or title it as a complimentary closing. Do not analyze any holds, transfers, or waiting periods before the call with the prospect and the salesperson starts."}]def CustomChatGPT(user_input):messages.append({"role": "user", "content": user_input})response = openai.ChatCompletion.create(2 unmodified lines)ChatGPT_reply = response["choices"][0]["message"]["content"]messages.append({"role": "assistant", "content": ChatGPT_reply})return ChatGPT_replydemo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Call Feedback")demo.launch(debug=True, inbrowser=True)123456789101112131415161718192021222 unmodified lines252627282930313233343536373839import gradio as grimport openaiimport os#Streaming endpointAPI_URL = "https://api.openai.com/v1/chat/completions"#Huggingface provided GPT4 OpenAI API KeyOPENAI_API_KEY = os.getenv("OPENAI_API_KEY")messages = [{"role": "system", "content": "Below is a transcript of a call, when critiquing, please attempt to understand who the salesperson and prospect are when analyzing this transcript but do not present the transcript back to me unless you are pulling a specific quote for further instruction. Ignore any spelling issues or errors as this is a transcript that may not be 100% accurate. Do your best to fill in the gaps and error on the side of the salesperson for any potential critiques. Then act as cold call sales expert Jeb Blount and give a detailed analysis and critique of this call. Do not contextualize who you are in the beginning. Do not say I. Do not say sales expert. Do not say Jeff Blount. Begin with a quick analysis of the call. Then make sure to list strengths as well as areas that use improvement and call the areas that could use improvement as potential things to consider. End with a complimentary closing that summarizes the analysis and gives a hopeful outlook on the future but don’t say or title it as a complimentary closing. Do not analyze any holds, transfers, or waiting periods before the call with the prospect and the salesperson starts."}]def format_text(text):# replace some specific text with HTML tagstext = text.replace('[bold]', '<b>').replace('[/bold]', '</b>')text = text.replace('[italic]', '<i>').replace('[/italic]', '</i>')# ... other formattingreturn textdef CustomChatGPT(user_input):messages.append({"role": "user", "content": user_input})response = openai.ChatCompletion.create(2 unmodified lines)ChatGPT_reply = response["choices"][0]["message"]["content"]messages.append({"role": "assistant", "content": ChatGPT_reply})# Add formatted sample text to the replysample_text = "\n\n[bold]XYZ[/bold]\nThis is some sample text. [italic]It has both bold and italic formatting.[/italic]"ChatGPT_reply += sample_textChatGPT_reply = format_text(ChatGPT_reply)return ChatGPT_replydemo = gr.Interface(fn=CustomChatGPT, inputs = "text", outputs = gr.outputs.Html(), title = "Call Feedback")demo.launch(debug=True, inbrowser=True)
app.py+17-6