Evidence-Bot / app.py
rhetoric-AI's picture
Update app.py
c97d108 verified
import openai
import gradio
import os
#read the api key from repository. This can be set in hugging face settings
#os.environ['secret_token'] and your windows machine in advanced settings environment variables
openai.api_key = os.getenv('secret_token')
messages = [{"role": "system", "content": "You are an evidence bot. I will write a claim in a sentence or two and you will reply only with evidence to support my claim. Each response you provide should begin with the phrase 'There is further evidence to support this claim.'"}]
def CustomChatGPT(Write_Here):
messages.append({"role": "user", "content": Write_Here})
response = response.chat.completions.create(
model = "gpt-3.5-turbo",
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 = "Evidence Bot. Write a claim to generate evidence.")
demo.launch()