File size: 902 Bytes
6a20884
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
import openai 

# Replace "YOUR_OPENAI_API_KEY" with your actual OpenAI API key
openai_api_key = "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"


def chatbot(question):
    message_log = [
        {"role": "user", "content": question}
    ]
    
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo-16k",
        messages=message_log,
        max_tokens=8800,
        request_timeout=35,
        stop=None,
        temperature=0.9
    )

    return response.choices[0].message.content

# Create the Gradio interface
iface = gr.Interface(
    fn=chatbot,
    inputs=gr.components.Textbox(lines=7, placeholder="Enter your question here"),
    outputs="text",
    title="Frost AI ChatBot: Your Knowledge Companion Powered-by ChatGPT",
    description="Ask any question about rahasak research papers"
)

# Launch the Gradio interface
iface.launch(share=True)