Spaces:
Runtime error

CallFeedBack / app.py
FT-BT's picture
Update app.py
d7ebc25
Raw History Blame Contribute Delete
2.37 kB
import gradio
import openai
import os
#Streaming endpoint
API_URL = "https://api.openai.com/v1/chat/completions" #os.getenv("API_URL") + "/generate_stream"
#Huggingface provided GPT4 OpenAI API Key
OPENAI_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(call_transcript):
messages.append({"role": "user", "content": call_transcript})
response = openai.ChatCompletion.create(
model = "gpt-4",
messages = messages
)
ChatGPT_reply = response["choices"][0]["message"]["content"]
messages.append({"role": "assistant", "content": ChatGPT_reply})
return ChatGPT_reply
demo = gradio.Interface(
fn=CustomChatGPT,
inputs="text",
outputs="text",
title="Call Feedback",
description="""<p align="left">Please create a call transcript <a href="https://huggingface.co/spaces/sanchit-gandhi/whisper-jax" target="_blank">here</a> by selecting the audio file tab and using the call .wav file. <br> Then cut and paste the entire call transcript below in quotes - i.e. just put an " at the beginning and end of the entire transcript, the AI will discern who is speaking.</p center>
""",
)
demo.launch(debug=True, inbrowser=True)