File size: 1,055 Bytes
6a03d08
 
 
 
 
73a471b
6a03d08
 
 
 
 
 
 
2b463bc
6a03d08
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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()